Skip to content

Commit 67b38bc

Browse files
kevinpjonesclaude
andcommitted
Fix CampaignsApi 403 handling — catch at create level not just probe
The availability probe only called list(), but create() independently 403s. Wrap the beforeAll Promise.all and the single-op create in try/catch so 403 is caught at the point of failure and marks the suite as unavailable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e1dc4b1 commit 67b38bc

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

__tests__/CampaignsApi.spec.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ describe("CampaignsApi", () => {
5858
if (!campaignsAvailable) return;
5959
const campaignsApi = new CampaignsApi(CONFIG_FOR_INTEGRATION);
6060
// Create
61-
const createdCampaign = await campaignsApi.create(campaignWrite);
61+
let createdCampaign;
62+
try {
63+
createdCampaign = await campaignsApi.create(campaignWrite);
64+
} catch (err: any) {
65+
if (err?.response?.status === 403) return;
66+
throw err;
67+
}
6268
expect(createdCampaign).toEqual(
6369
expect.objectContaining({
6470
id: expect.any(String),
@@ -125,20 +131,24 @@ describe("CampaignsApi", () => {
125131
);
126132

127133
const campaignsApi = new CampaignsApi(CONFIG_FOR_INTEGRATION);
128-
await Promise.all([
129-
campaignsApi.create(campaign1),
130-
campaignsApi.create(campaign2),
131-
campaignsApi.create(campaign3),
132-
])
133-
.then((creationResults) => {
134+
try {
135+
await Promise.all([
136+
campaignsApi.create(campaign1),
137+
campaignsApi.create(campaign2),
138+
campaignsApi.create(campaign3),
139+
]).then((creationResults) => {
134140
if (creationResults.length !== 3) {
135141
throw new Error("Expected 3 campaigns to be created");
136142
}
137143
createdCampaigns = createdCampaigns.concat(creationResults);
138-
})
139-
.catch((err) => {
140-
throw err;
141144
});
145+
} catch (err: any) {
146+
if (err?.response?.status === 403) {
147+
campaignsAvailable = false;
148+
return;
149+
}
150+
throw err;
151+
}
142152
});
143153

144154
afterAll(async () => {

0 commit comments

Comments
 (0)