Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix tests

Steven Tey5d549ea79509
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index d465373f75..5b4f45d740 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -42,9 +42,10 @@ export const POST = withWorkspaceEdge(
});
if (!ok) {
- throw new DubApiError({
- code: "conflict",
- message: `Invoice with ID ${invoiceId} already processed, skipping...`,
+ return NextResponse.json({
+ eventName,
+ customer: null,
+ sale: null,
});
}
}
diff --git a/apps/web/tests/tracks/track-sale.test.ts b/apps/web/tests/tracks/track-sale.test.ts
index f85cb22a21..3ca4ea2099 100644
--- a/apps/web/tests/tracks/track-sale.test.ts
+++ b/apps/web/tests/tracks/track-sale.test.ts
@@ -51,12 +51,13 @@ test("POST /track/sale", async () => {
invoiceId: sale.invoiceId,
});
- // An externalId that does not exist should return a 304 status code
+ // An invoiceId that is already processed should return null customer and sale
const response2 = await http.post<TrackSaleResponse>({
path: "/track/sale",
body: {
...sale,
- externalId: "external-id-that-does-not-exist",
+ externalId: E2E_CUSTOMER_EXTERNAL_ID,
+ invoiceId: sale.invoiceId,
},
});
@@ -66,4 +67,21 @@ test("POST /track/sale", async () => {
customer: null,
sale: null,
});
+
+ // An externalId that does not exist should return null customer and sale
+ const response3 = await http.post<TrackSaleResponse>({
+ path: "/track/sale",
+ body: {
+ ...sale,
+ invoiceId: `INV_${randomId()}`,
+ externalId: "external-id-that-does-not-exist",
+ },
+ });
+
+ expect(response3.status).toEqual(200);
+ expect(response3.data).toStrictEqual({
+ eventName: "Subscription",
+ customer: null,
+ sale: null,
+ });
});