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.

Merge branch 'main' into playwright-campaigns-api-tests

Kiran K9401437ff005
diff --cc apps/web/playwright/api/bounties/bounties.spec.ts
index 806a847641,2dee72deef..f5f5bc3219
--- a/apps/web/playwright/api/bounties/bounties.spec.ts
+++ b/apps/web/playwright/api/bounties/bounties.spec.ts
@@@ -68,8 -90,42 +86,9 @@@ const expectedBountyDefaults =
performanceCondition: null,
performanceScope: null,
socialMetricsLastSyncedAt: null,
+ partnerTags: [],
};
-const unprocessable = (message: string) => ({
- status: 422,
- data: {
- error: {
- code: "unprocessable_entity",
- message,
- doc_url: "https://dub.co/docs/api-reference/errors#unprocessable-entity",
- },
- },
-});
-
-const badRequest = (message: string) => ({
- status: 400,
- data: {
- error: {
- code: "bad_request",
- message,
- doc_url: "https://dub.co/docs/api-reference/errors#bad-request",
- },
- },
-});
-
-const notFound = (bountyId: string) => ({
- status: 404,
- data: {
- error: {
- code: "not_found",
- message: `Bounty ${bountyId} not found.`,
- doc_url: "https://dub.co/docs/api-reference/errors#not-found",
- },
- },
-});
-
test("POST /bounties", async ({ api, program }) => {
let id: string | undefined;
const body = bountyPayload(program);
@@@ -736,14 -794,114 +768,119 @@@ test("POST /bounties – invalid group
await api.post("/api/bounties", {
...bountyPayload(program, { groupIds: ["invalid-group-id"] }),
}),
- ).toEqual(badRequest("Invalid group IDs detected: invalid-group-id"));
+ ).toEqual(
+ apiError({
+ code: "bad_request",
+ message: "Invalid group IDs detected: invalid-group-id",
+ }),
+ );
});
+ test("POST /bounties – invalid partner tag IDs", async ({ api, program }) => {
+ expect(
+ await api.post("/api/bounties", {
+ ...bountyPayload(program, {
+ partnerTagIds: ["invalid-partner-tag-id"],
+ }),
+ }),
+ ).toEqual(
+ badRequest("Invalid partner tag IDs detected: invalid-partner-tag-id"),
+ );
+ });
+
+ test("POST /bounties – with partnerTagIds null returns empty partnerTags", async ({
+ api,
+ program,
+ }) => {
+ let id: string | undefined;
+
+ try {
+ const { status, data } = await createBounty(api, program, {
+ partnerTagIds: null,
+ });
+ id = data.id;
+
+ expect(status).toEqual(200);
+ expect(data.partnerTags).toEqual([]);
+ } finally {
+ await deleteBounty(api, id);
+ }
+ });
+
+ test("POST /bounties – with valid partnerTagIds", async ({ api, program }) => {
+ let id: string | undefined;
+ let partnerTagId: string | undefined;
+
+ try {
+ const partnerTag = await createPartnerTag(program.id);
+ partnerTagId = partnerTag.id;
+
+ const { status, data } = await createBounty(api, program, {
+ partnerTagIds: [partnerTag.id],
+ });
+ id = data.id;
+
+ expect(status).toEqual(200);
+ expect(data.partnerTags).toEqual([{ id: partnerTag.id }]);
+ } finally {
+ await deleteBounty(api, id);
+ await deletePartnerTag(partnerTagId);
+ }
+ });
+
+ test("PATCH /bounties/{bountyId} – clear partner tags", async ({
+ api,
+ program,
+ }) => {
+ let id: string | undefined;
+ let partnerTagId: string | undefined;
+
+ try {
+ const partnerTag = await createPartnerTag(program.id);
+ partnerTagId = partnerTag.id;
+
+ const { data: created } = await createBounty(api, program, {
+ partnerTagIds: [partnerTag.id],
+ });
+ id = created.id;
+
+ expect(created.partnerTags).toEqual([{ id: partnerTag.id }]);
+
+ const { status, data } = await api.patch<BountyJson>(
+ `/api/bounties/${id}`,
+ { partnerTagIds: null },
+ );
+
+ expect(status).toEqual(200);
+ expect(data.partnerTags).toEqual([]);
+ } finally {
+ await deleteBounty(api, id);
+ await deletePartnerTag(partnerTagId);
+ }
+ });
+
+ test("PATCH /bounties/{bountyId} – invalid partner tag IDs", async ({
+ api,
+ program,
+ }) => {
+ let id: string | undefined;
+
+ try {
+ const { data: created } = await createBounty(api, program);
+ id = created.id;
+
+ expect(
+ await api.patch(`/api/bounties/${id}`, {
+ partnerTagIds: ["invalid-partner-tag-id"],
+ }),
+ ).toEqual(
+ badRequest("Invalid partner tag IDs detected: invalid-partner-tag-id"),
+ );
+ } finally {
+ await deleteBounty(api, id);
+ }
+ });
+
test("POST /bounties – maxSubmissions below minimum is rejected", async ({
api,
program,