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.

Remove Vitest campaigns tests superseded by Playwright API specs

Kiran K8e0207a6570a
diff --git a/apps/web/tests/campaigns/index.test.ts b/apps/web/tests/campaigns/index.test.ts
deleted file mode 100644
index a32365c8ae..0000000000
--- a/apps/web/tests/campaigns/index.test.ts
+++ /dev/null
@@ -1,208 +0,0 @@
-import { Campaign, CampaignList } from "@/lib/types";
-import { updateCampaignSchema } from "@/lib/zod/schemas/campaigns";
-import { E2E_PARTNER_GROUP } from "tests/utils/resource";
-import { describe, expect, onTestFinished, test } from "vitest";
-import * as z from "zod/v4";
-import { IntegrationHarness } from "../utils/integration";
-
-const campaign: z.infer<typeof updateCampaignSchema> = {
- name: "Updated Test Campaign",
- subject: "Updated Test Subject",
- triggerCondition: {
- attribute: "totalConversions",
- operator: "gte",
- value: 50,
- },
- bodyJson: {
- type: "doc",
- content: [
- {
- type: "paragraph",
- content: [
- {
- type: "text",
- text: "Test campaign body",
- },
- ],
- },
- ],
- },
-};
-
-const expectedCampaign: Partial<Campaign> = {
- ...campaign,
- type: "transactional",
- status: expect.any(String),
- preview: null,
- from: null,
- scheduledAt: null,
- groups: [{ id: E2E_PARTNER_GROUP.id }],
- createdAt: expect.any(String),
- updatedAt: expect.any(String),
-};
-
-describe.sequential("/campaigns/**", async () => {
- const h = new IntegrationHarness();
- const { http } = await h.init();
-
- let campaignId = "";
-
- test("POST /campaigns - create draft campaign", async () => {
- const { status, data } = await http.post<{ id: string }>({
- path: "/campaigns",
- body: {
- type: "transactional",
- },
- });
-
- expect(status).toEqual(201);
- expect(data).toMatchObject({
- id: expect.any(String),
- });
-
- campaignId = data.id;
- });
-
- test("PATCH /campaigns/[campaignId] - update campaign content", async () => {
- const { status, data: updatedCampaign } = await http.patch<Campaign>({
- path: `/campaigns/${campaignId}`,
- body: {
- ...campaign,
- groupIds: [E2E_PARTNER_GROUP.id],
- },
- });
-
- expect(status).toEqual(200);
- expect(updatedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "draft",
- });
- });
-
- test("GET /campaigns/[campaignId] - make sure the draft campaign is created", async () => {
- const { status, data: fetchedCampaign } = await http.get<Campaign>({
- path: `/campaigns/${campaignId}`,
- });
-
- expect(status).toEqual(200);
- expect(fetchedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "draft",
- });
- });
-
- test("PATCH /campaigns/[campaignId] - publish campaign", async () => {
- const { status, data: publishedCampaign } = await http.patch<Campaign>({
- path: `/campaigns/${campaignId}`,
- body: {
- status: "active",
- },
- });
-
- expect(status).toEqual(200);
- expect(publishedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "active",
- });
- });
-
- test("PATCH /campaigns/[campaignId] - pause campaign", async () => {
- const { status, data: pausedCampaign } = await http.patch<Campaign>({
- path: `/campaigns/${campaignId}`,
- body: {
- status: "paused",
- },
- });
-
- expect(status).toEqual(200);
- expect(pausedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "paused",
- });
- });
-
- test("PATCH /campaigns/[campaignId] - resume campaign", async () => {
- const { status, data: resumedCampaign } = await http.patch<Campaign>({
- path: `/campaigns/${campaignId}`,
- body: {
- status: "active",
- },
- });
-
- expect(status).toEqual(200);
- expect(resumedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "active",
- });
- });
-
- test("POST /campaigns/[campaignId]/duplicate - duplicate campaign", async () => {
- const { status, data } = await http.post<{ id: string }>({
- path: `/campaigns/${campaignId}/duplicate`,
- });
-
- expect(status).toEqual(200);
- expect(data.id).toBeDefined();
-
- onTestFinished(async () => {
- await h.deleteCampaign(data.id);
- });
-
- const { data: duplicatedCampaign } = await http.get<Campaign>({
- path: `/campaigns/${data.id}`,
- });
-
- expect(duplicatedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: data.id,
- name: `${expectedCampaign.name} (copy)`,
- status: "draft",
- });
- });
-
- test("GET /campaigns - list campaigns", async () => {
- const { status, data: campaigns } = await http.get<CampaignList[]>({
- path: "/campaigns",
- });
-
- expect(status).toEqual(200);
- expect(Array.isArray(campaigns)).toBe(true);
- expect(campaigns.length).toBeGreaterThan(0);
-
- const campaign = campaigns.find((c) => c.id === campaignId);
-
- expect(campaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- });
- });
-
- test("GET /campaigns/[campaignId] - get single campaign", async () => {
- const { status, data: fetchedCampaign } = await http.get<Campaign>({
- path: `/campaigns/${campaignId}`,
- });
-
- expect(status).toEqual(200);
- expect(fetchedCampaign).toStrictEqual({
- ...expectedCampaign,
- id: campaignId,
- status: "active",
- });
- });
-
- test("DELETE /campaigns/[campaignId] - delete campaign", async () => {
- const { status, data } = await http.delete<{ id: string }>({
- path: `/campaigns/${campaignId}`,
- });
-
- expect(status).toEqual(200);
- expect(data).toStrictEqual({
- id: campaignId,
- });
- });
-});