The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Cover deleting discount codes by id or alphanumeric code.
Kiran K5cd20afe50c5
diff --git a/apps/web/playwright/api/discount-codes/discount-codes.spec.ts b/apps/web/playwright/api/discount-codes/discount-codes.spec.tsindex 110b4bcd3a..6def2c2381 100644--- a/apps/web/playwright/api/discount-codes/discount-codes.spec.ts+++ b/apps/web/playwright/api/discount-codes/discount-codes.spec.ts@@ -483,7 +483,7 @@ test("GET /discount-codes – unknown partner", async ({ api, program }) => {});});-test("DELETE /discount-codes/{id}", async ({ api }) => {+test("DELETE /discount-codes/{idOrCode} – by id", async ({ api }) => {let partnerId: string | undefined;try {@@ -501,17 +501,39 @@ test("DELETE /discount-codes/{id}", async ({ api }) => {}});-test("DELETE /discount-codes/{id} – not found", async ({ api }) => {- const { status, data } = await api.delete(- "/api/discount-codes/dcode_does_not_exist",- );-- expect(status).toEqual(404);- expect(data).toEqual({- error: {- code: "not_found",- message: "Discount code (dcode_does_not_exist) not found.",- doc_url: "https://dub.co/docs/api-reference/errors#not-found",- },- });+test("DELETE /discount-codes/{idOrCode} – by code", async ({ api }) => {+ let partnerId: string | undefined;++ try {+ const created = await createDiscountCode(api);+ partnerId = created.partner.id;++ const { status, data } = await api.delete<{ id: string }>(+ `/api/discount-codes/${created.data.code}`,+ );++ expect(status).toEqual(200);+ expect(data).toEqual({ id: created.data.id });+ } finally {+ await deletePartner(partnerId);+ }});++for (const idOrCode of ["dcode_does_not_exist", "CODE_DOES_NOT_EXIST"]) {+ test(`DELETE /discount-codes/{idOrCode} – not found (${idOrCode})`, async ({+ api,+ }) => {+ const { status, data } = await api.delete(+ `/api/discount-codes/${idOrCode}`,+ );++ expect(status).toEqual(404);+ expect(data).toEqual({+ error: {+ code: "not_found",+ message: `Discount code (${idOrCode}) not found.`,+ doc_url: "https://dub.co/docs/api-reference/errors#not-found",+ },+ });+ });+}