Skip to content

Commit ee2e8b5

Browse files
authored
Gracefully handle appdistribution:testers:list returning no testers (#8349)
1 parent b84c135 commit ee2e8b5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/appdistribution/client.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ describe("distribution", () => {
169169
});
170170
expect(nock.isDone()).to.be.true;
171171
});
172+
173+
it("should gracefully handle no testers", async () => {
174+
nock(appDistributionOrigin()).get(`/v1/${projectName}/testers`).reply(200, {});
175+
176+
await expect(appDistributionClient.listTesters(projectName)).to.eventually.deep.eq({
177+
testers: [],
178+
});
179+
expect(nock.isDone()).to.be.true;
180+
});
172181
});
173182

174183
describe("uploadRelease", () => {

src/appdistribution/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class AppDistributionClient {
152152
throw new FirebaseError(`Client request failed to list testers ${err}`);
153153
}
154154

155-
for (const t of apiResponse.body.testers) {
155+
for (const t of apiResponse.body.testers ?? []) {
156156
listTestersResponse.testers.push({
157157
name: t.name,
158158
displayName: t.displayName,
@@ -212,7 +212,7 @@ export class AppDistributionClient {
212212
const apiResponse = await client.get<ListGroupsResponse>(`${projectName}/groups`, {
213213
queryParams,
214214
});
215-
listGroupsResponse.groups.push(...(apiResponse.body.groups || []));
215+
listGroupsResponse.groups.push(...(apiResponse.body.groups ?? []));
216216
pageToken = apiResponse.body.nextPageToken;
217217
} catch (err) {
218218
throw new FirebaseError(`Client failed to list groups ${err}`);

0 commit comments

Comments
 (0)