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 group move test to use "between" instead of "gte"

Steven Teye4211b613602
diff --git a/apps/web/tests/workflows/award-bounty-workflow.test.ts b/apps/web/tests/workflows/award-bounty-workflow.test.ts
index 0c85be6726..4d739a5ab3 100644
--- a/apps/web/tests/workflows/award-bounty-workflow.test.ts
+++ b/apps/web/tests/workflows/award-bounty-workflow.test.ts
@@ -1,71 +1,74 @@
import { EnrolledPartnerProps } from "@/lib/types";
import { Bounty } from "@dub/prisma/client";
-import { describe, expect, test, onTestFinished } from "vitest";
+import { describe, expect, onTestFinished, test } from "vitest";
import { randomEmail } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
-import { trackLeads } from "./utils/track-leads";
+import { trackLeads } from "./utils/track-e2e-lead";
import { verifyBountySubmission } from "./utils/verify-bounty-submission";
describe.sequential("Workflow - AwardBounty", async () => {
const h = new IntegrationHarness();
const { http } = await h.init();
- test("Workflow executes when partner reaches goal", { timeout: 90000 }, async () => {
- const { status: bountyStatus, data: bounty } = await http.post<Bounty>({
- path: "/bounties",
- body: {
- name: "E2E Performance Bounty - Goal Reached",
- description: "Get 2 leads to earn $10",
- type: "performance",
- startsAt: new Date().toISOString(),
- endsAt: null,
- rewardAmount: 1000,
- performanceScope: "new",
- groupIds: [],
- performanceCondition: {
- attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ test(
+ "Workflow executes when partner reaches goal",
+ { timeout: 90000 },
+ async () => {
+ const { status: bountyStatus, data: bounty } = await http.post<Bounty>({
+ path: "/bounties",
+ body: {
+ name: "E2E Performance Bounty - Goal Reached",
+ description: "Get 2 leads to earn $10",
+ type: "performance",
+ startsAt: new Date().toISOString(),
+ endsAt: null,
+ rewardAmount: 1000,
+ performanceScope: "new",
+ groupIds: [],
+ performanceCondition: {
+ attribute: "totalLeads",
+ operator: "gte",
+ value: 2,
+ },
},
- },
- });
+ });
- expect(bountyStatus).toEqual(200);
+ expect(bountyStatus).toEqual(200);
- onTestFinished(async () => {
- await h.deleteBounty(bounty.id);
- });
+ onTestFinished(async () => {
+ await h.deleteBounty(bounty.id);
+ });
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Goal",
- email: randomEmail(),
- },
- });
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Goal",
+ email: randomEmail(),
+ },
+ });
- expect(partnerStatus).toEqual(201);
- expect(partner.links).not.toBeNull();
- expect(partner.links!.length).toBeGreaterThan(0);
+ expect(partnerStatus).toEqual(201);
+ expect(partner.links).not.toBeNull();
+ expect(partner.links!.length).toBeGreaterThan(0);
- const partnerLink = partner.links![0];
+ const partnerLink = partner.links![0];
- await trackLeads(http, partnerLink, 3);
+ await trackLeads(http, partnerLink, 3);
- const submission = await verifyBountySubmission({
- http,
- bountyId: bounty.id,
- partnerId: partner.id,
- expectedStatus: "submitted",
- minPerformanceCount: 2,
- });
+ const submission = await verifyBountySubmission({
+ http,
+ bountyId: bounty.id,
+ partnerId: partner.id,
+ expectedStatus: "submitted",
+ minPerformanceCount: 2,
+ });
- expect(submission.status).toBe("submitted");
- expect(submission.performanceCount).toBeGreaterThanOrEqual(2);
- expect(submission.completedAt).not.toBeNull();
- });
+ expect(submission.status).toBe("submitted");
+ expect(submission.performanceCount).toBeGreaterThanOrEqual(2);
+ expect(submission.completedAt).not.toBeNull();
+ },
+ );
test("Workflow doesn't execute when goal not reached", async () => {
const { status: bountyStatus, data: bounty } = await http.post<Bounty>({
@@ -93,15 +96,14 @@ describe.sequential("Workflow - AwardBounty", async () => {
await h.deleteBounty(bounty.id);
});
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Not Reached",
- email: randomEmail(),
- },
- });
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Not Reached",
+ email: randomEmail(),
+ },
+ });
expect(partnerStatus).toEqual(201);
expect(partner.links).not.toBeNull();
@@ -164,15 +166,14 @@ describe.sequential("Workflow - AwardBounty", async () => {
body: { disabledAt: new Date().toISOString() },
});
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Disabled",
- email: randomEmail(),
- },
- });
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Disabled",
+ email: randomEmail(),
+ },
+ });
expect(partnerStatus).toEqual(201);
expect(partner.links).not.toBeNull();
@@ -191,63 +192,66 @@ describe.sequential("Workflow - AwardBounty", async () => {
expect(submissions).toHaveLength(0);
});
- test("No duplicate execution on multiple triggers", { timeout: 90000 }, async () => {
- const { status: bountyStatus, data: bounty } = await http.post<Bounty>({
- path: "/bounties",
- body: {
- name: "E2E Performance Bounty - No Duplicates",
- description: "Get 2 leads to earn $10",
- type: "performance",
- startsAt: new Date().toISOString(),
- endsAt: null,
- rewardAmount: 1000,
- performanceScope: "new",
- groupIds: [],
- performanceCondition: {
- attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ test(
+ "No duplicate execution on multiple triggers",
+ { timeout: 90000 },
+ async () => {
+ const { status: bountyStatus, data: bounty } = await http.post<Bounty>({
+ path: "/bounties",
+ body: {
+ name: "E2E Performance Bounty - No Duplicates",
+ description: "Get 2 leads to earn $10",
+ type: "performance",
+ startsAt: new Date().toISOString(),
+ endsAt: null,
+ rewardAmount: 1000,
+ performanceScope: "new",
+ groupIds: [],
+ performanceCondition: {
+ attribute: "totalLeads",
+ operator: "gte",
+ value: 2,
+ },
},
- },
- });
-
- expect(bountyStatus).toEqual(200);
-
- onTestFinished(async () => {
- await h.deleteBounty(bounty.id);
- });
-
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - No Dup",
- email: randomEmail(),
- },
- });
-
- expect(partnerStatus).toEqual(201);
- expect(partner.links).not.toBeNull();
-
- const partnerLink = partner.links![0];
-
- await trackLeads(http, partnerLink, 5);
-
- await verifyBountySubmission({
- http,
- bountyId: bounty.id,
- partnerId: partner.id,
- expectedStatus: "submitted",
- minPerformanceCount: 2,
- });
-
- const { data: submissions } = await http.get<any[]>({
- path: `/bounties/${bounty.id}/submissions`,
- query: { partnerId: partner.id },
- });
-
- expect(submissions).toHaveLength(1);
- expect(submissions[0].status).toBe("submitted");
- });
+ });
+
+ expect(bountyStatus).toEqual(200);
+
+ onTestFinished(async () => {
+ await h.deleteBounty(bounty.id);
+ });
+
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - No Dup",
+ email: randomEmail(),
+ },
+ });
+
+ expect(partnerStatus).toEqual(201);
+ expect(partner.links).not.toBeNull();
+
+ const partnerLink = partner.links![0];
+
+ await trackLeads(http, partnerLink, 5);
+
+ await verifyBountySubmission({
+ http,
+ bountyId: bounty.id,
+ partnerId: partner.id,
+ expectedStatus: "submitted",
+ minPerformanceCount: 2,
+ });
+
+ const { data: submissions } = await http.get<any[]>({
+ path: `/bounties/${bounty.id}/submissions`,
+ query: { partnerId: partner.id },
+ });
+
+ expect(submissions).toHaveLength(1);
+ expect(submissions[0].status).toBe("submitted");
+ },
+ );
});
diff --git a/apps/web/tests/workflows/move-group-workflow.test.ts b/apps/web/tests/workflows/move-group-workflow.test.ts
index a39c977bfb..90d10f6f05 100644
--- a/apps/web/tests/workflows/move-group-workflow.test.ts
+++ b/apps/web/tests/workflows/move-group-workflow.test.ts
@@ -1,12 +1,11 @@
import { EnrolledPartnerProps } from "@/lib/types";
import { RESOURCE_COLORS } from "@/ui/colors";
-import { randomValue } from "@dub/utils";
import { PartnerGroup } from "@dub/prisma/client";
-import { describe, expect, test, onTestFinished } from "vitest";
+import { randomValue } from "@dub/utils";
+import { describe, expect, onTestFinished, test } from "vitest";
import { randomEmail } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
-import { E2E_PROGRAM } from "../utils/resource";
-import { trackLeads } from "./utils/track-leads";
+import { trackE2ELead } from "./utils/track-e2e-lead";
import { verifyPartnerGroupMove } from "./utils/verify-partner-group-move";
async function cleanupOrphanedGroup(
@@ -21,7 +20,6 @@ async function cleanupOrphanedGroup(
describe.sequential("Workflow - MoveGroup", async () => {
const h = new IntegrationHarness();
const { http } = await h.init();
- const programId = E2E_PROGRAM.id;
const { data: allGroupsForCleanup } = await http.get<PartnerGroup[]>({
path: "/groups",
@@ -31,16 +29,15 @@ describe.sequential("Workflow - MoveGroup", async () => {
const slug = "e2e-target-config";
await cleanupOrphanedGroup(http, slug, allGroupsForCleanup);
- const { status: targetStatus, data: targetGroup } = await http.post<
- PartnerGroup
- >({
- path: "/groups",
- body: {
- name: "E2E Target Group - Config Test",
- slug,
- color: randomValue(RESOURCE_COLORS),
- },
- });
+ const { status: targetStatus, data: targetGroup } =
+ await http.post<PartnerGroup>({
+ path: "/groups",
+ body: {
+ name: "E2E Target Group - Config Test",
+ slug,
+ color: randomValue(RESOURCE_COLORS),
+ },
+ });
expect(targetStatus).toEqual(201);
@@ -54,8 +51,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
moveRules: [
{
attribute: "totalLeads",
- operator: "gte",
- value: 10,
+ operator: "between",
+ value: { min: 3, max: 5 },
},
],
},
@@ -80,8 +77,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
const workflowConditions = workflow.triggerConditions as any[];
expect(workflowConditions).toHaveLength(1);
expect(workflowConditions[0].attribute).toBe("totalLeads");
- expect(workflowConditions[0].operator).toBe("gte");
- expect(workflowConditions[0].value).toBe(10);
+ expect(workflowConditions[0].operator).toBe("between");
+ expect(workflowConditions[0].value).toStrictEqual({ min: 3, max: 5 });
});
test("Workflow is deleted when move rules are removed", async () => {
@@ -109,8 +106,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
moveRules: [
{
attribute: "totalLeads",
- operator: "gte",
- value: 5,
+ operator: "between",
+ value: { min: 2, max: 3 },
},
],
},
@@ -153,16 +150,15 @@ describe.sequential("Workflow - MoveGroup", async () => {
expect(existingGroups.length).toBeGreaterThan(0);
const sourceGroup = existingGroups[0];
- const { status: targetStatus, data: targetGroup } = await http.post<
- PartnerGroup
- >({
- path: "/groups",
- body: {
- name: "E2E Target Group - Disabled Move",
- slug,
- color: randomValue(RESOURCE_COLORS),
- },
- });
+ const { status: targetStatus, data: targetGroup } =
+ await http.post<PartnerGroup>({
+ path: "/groups",
+ body: {
+ name: "E2E Target Group - Disabled Move",
+ slug,
+ color: randomValue(RESOURCE_COLORS),
+ },
+ });
expect(targetStatus).toEqual(201);
@@ -176,8 +172,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
moveRules: [
{
attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ operator: "between",
+ value: { min: 2, max: 3 },
},
],
},
@@ -198,23 +194,22 @@ describe.sequential("Workflow - MoveGroup", async () => {
body: { disabledAt: new Date().toISOString() },
});
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Disabled Move",
- email: randomEmail(),
- groupId: sourceGroup.id,
- },
- });
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Disabled Move",
+ email: randomEmail(),
+ groupId: sourceGroup.id,
+ },
+ });
expect(partnerStatus).toEqual(201);
expect(partner.links).not.toBeNull();
const partnerLink = partner.links![0];
- await trackLeads(http, partnerLink, 3);
+ await trackE2ELead(http, partnerLink);
await new Promise((resolve) => setTimeout(resolve, 10000));
@@ -236,16 +231,15 @@ describe.sequential("Workflow - MoveGroup", async () => {
expect(existingGroups.length).toBeGreaterThan(0);
const sourceGroup = existingGroups[0];
- const { status: targetStatus, data: targetGroup } = await http.post<
- PartnerGroup
- >({
- path: "/groups",
- body: {
- name: "E2E Target Group - Not Met",
- slug,
- color: randomValue(RESOURCE_COLORS),
- },
- });
+ const { status: targetStatus, data: targetGroup } =
+ await http.post<PartnerGroup>({
+ path: "/groups",
+ body: {
+ name: "E2E Target Group - Not Met",
+ slug,
+ color: randomValue(RESOURCE_COLORS),
+ },
+ });
expect(targetStatus).toEqual(201);
@@ -259,8 +253,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
moveRules: [
{
attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ operator: "between",
+ value: { min: 4, max: 5 },
},
],
},
@@ -268,23 +262,22 @@ describe.sequential("Workflow - MoveGroup", async () => {
expect(patchStatus).toEqual(200);
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Not Met",
- email: randomEmail(),
- groupId: sourceGroup.id,
- },
- });
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Not Met",
+ email: randomEmail(),
+ groupId: sourceGroup.id,
+ },
+ });
expect(partnerStatus).toEqual(201);
expect(partner.links).not.toBeNull();
const partnerLink = partner.links![0];
- await trackLeads(http, partnerLink, 1);
+ await trackE2ELead(http, partnerLink);
await new Promise((resolve) => setTimeout(resolve, 10000));
@@ -295,148 +288,152 @@ describe.sequential("Workflow - MoveGroup", async () => {
expect(partnerAfter.groupId).toBe(sourceGroup.id);
});
- test("Workflow executes when conditions are met - partner moves to target group", { timeout: 90000 }, async () => {
- const slug = "e2e-target-exec";
- await cleanupOrphanedGroup(http, slug, allGroupsForCleanup);
-
- const { data: existingGroups } = await http.get<PartnerGroup[]>({
- path: "/groups",
- });
-
- expect(existingGroups.length).toBeGreaterThan(0);
- const sourceGroup = existingGroups[0];
-
- const { status: targetStatus, data: targetGroup } = await http.post<
- PartnerGroup
- >({
- path: "/groups",
- body: {
- name: "E2E Target Group - Move Execution",
- slug,
- color: randomValue(RESOURCE_COLORS),
- },
- });
-
- expect(targetStatus).toEqual(201);
-
- onTestFinished(async () => {
- await http.delete({ path: `/groups/${targetGroup.id}` });
- });
-
- const { status: patchStatus } = await http.patch({
- path: `/groups/${targetGroup.id}`,
- body: {
- moveRules: [
- {
- attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ test(
+ "Workflow executes when conditions are met - partner moves to target group",
+ { timeout: 90000 },
+ async () => {
+ const slug = "e2e-target-exec";
+ await cleanupOrphanedGroup(http, slug, allGroupsForCleanup);
+
+ const { data: existingGroups } = await http.get<PartnerGroup[]>({
+ path: "/groups",
+ });
+
+ expect(existingGroups.length).toBeGreaterThan(0);
+ const sourceGroup = existingGroups[0];
+
+ const { status: targetStatus, data: targetGroup } =
+ await http.post<PartnerGroup>({
+ path: "/groups",
+ body: {
+ name: "E2E Target Group - Move Execution",
+ slug,
+ color: randomValue(RESOURCE_COLORS),
},
- ],
- },
- });
-
- expect(patchStatus).toEqual(200);
-
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - Move Execution",
- email: randomEmail(),
- groupId: sourceGroup.id,
- },
- });
-
- expect(partnerStatus).toEqual(201);
- expect(partner.links).not.toBeNull();
- expect(partner.groupId).toBe(sourceGroup.id);
-
- const partnerLink = partner.links![0];
-
- await trackLeads(http, partnerLink, 3);
-
- await verifyPartnerGroupMove({
- http,
- partnerId: partner.id,
- expectedGroupId: targetGroup.id,
- });
- });
-
- test("No duplicate group moves on multiple triggers", { timeout: 90000 }, async () => {
- const slug = "e2e-target-no-dup";
- await cleanupOrphanedGroup(http, slug, allGroupsForCleanup);
-
- const { data: existingGroups } = await http.get<PartnerGroup[]>({
- path: "/groups",
- });
-
- expect(existingGroups.length).toBeGreaterThan(0);
- const sourceGroup = existingGroups[0];
-
- const { status: targetStatus, data: targetGroup } = await http.post<
- PartnerGroup
- >({
- path: "/groups",
- body: {
- name: "E2E Target Group - No Dup Move",
- slug,
- color: randomValue(RESOURCE_COLORS),
- },
- });
-
- expect(targetStatus).toEqual(201);
-
- onTestFinished(async () => {
- await http.delete({ path: `/groups/${targetGroup.id}` });
- });
-
- const { status: patchStatus } = await http.patch({
- path: `/groups/${targetGroup.id}`,
- body: {
- moveRules: [
- {
- attribute: "totalLeads",
- operator: "gte",
- value: 2,
+ });
+
+ expect(targetStatus).toEqual(201);
+
+ onTestFinished(async () => {
+ await http.delete({ path: `/groups/${targetGroup.id}` });
+ });
+
+ const { status: patchStatus } = await http.patch({
+ path: `/groups/${targetGroup.id}`,
+ body: {
+ moveRules: [
+ {
+ attribute: "totalLeads",
+ operator: "between",
+ value: { min: 2, max: 3 },
+ },
+ ],
+ },
+ });
+
+ expect(patchStatus).toEqual(200);
+
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - Move Execution",
+ email: randomEmail(),
+ groupId: sourceGroup.id,
},
- ],
- },
- });
-
- expect(patchStatus).toEqual(200);
+ });
+
+ expect(partnerStatus).toEqual(201);
+ expect(partner.links).not.toBeNull();
+ expect(partner.groupId).toBe(sourceGroup.id);
+
+ const partnerLink = partner.links![0];
+
+ await trackE2ELead(http, partnerLink);
+
+ await verifyPartnerGroupMove({
+ http,
+ partnerId: partner.id,
+ expectedGroupId: targetGroup.id,
+ });
+ },
+ );
+
+ test(
+ "No duplicate group moves on multiple triggers",
+ { timeout: 90000 },
+ async () => {
+ const slug = "e2e-target-no-dup";
+ await cleanupOrphanedGroup(http, slug, allGroupsForCleanup);
+
+ const { data: existingGroups } = await http.get<PartnerGroup[]>({
+ path: "/groups",
+ });
+
+ expect(existingGroups.length).toBeGreaterThan(0);
+ const sourceGroup = existingGroups[0];
+
+ const { status: targetStatus, data: targetGroup } =
+ await http.post<PartnerGroup>({
+ path: "/groups",
+ body: {
+ name: "E2E Target Group - No Dup Move",
+ slug,
+ color: randomValue(RESOURCE_COLORS),
+ },
+ });
+
+ expect(targetStatus).toEqual(201);
+
+ onTestFinished(async () => {
+ await http.delete({ path: `/groups/${targetGroup.id}` });
+ });
+
+ const { status: patchStatus } = await http.patch({
+ path: `/groups/${targetGroup.id}`,
+ body: {
+ moveRules: [
+ {
+ attribute: "totalLeads",
+ operator: "between",
+ value: { min: 2, max: 3 },
+ },
+ ],
+ },
+ });
+
+ expect(patchStatus).toEqual(200);
+
+ const { status: partnerStatus, data: partner } =
+ await http.post<EnrolledPartnerProps>({
+ path: "/partners",
+ body: {
+ name: "E2E Test Partner - No Dup Move",
+ email: randomEmail(),
+ groupId: sourceGroup.id,
+ },
+ });
- const { status: partnerStatus, data: partner } = await http.post<
- EnrolledPartnerProps
- >({
- path: "/partners",
- body: {
- name: "E2E Test Partner - No Dup Move",
- email: randomEmail(),
- groupId: sourceGroup.id,
- },
- });
+ expect(partnerStatus).toEqual(201);
+ expect(partner.links).not.toBeNull();
- expect(partnerStatus).toEqual(201);
- expect(partner.links).not.toBeNull();
+ const partnerLink = partner.links![0];
- const partnerLink = partner.links![0];
+ await trackE2ELead(http, partnerLink);
- await trackLeads(http, partnerLink, 5);
+ await verifyPartnerGroupMove({
+ http,
+ partnerId: partner.id,
+ expectedGroupId: targetGroup.id,
+ });
- await verifyPartnerGroupMove({
- http,
- partnerId: partner.id,
- expectedGroupId: targetGroup.id,
- });
+ const { data: partnerAfter } = await http.get<EnrolledPartnerProps>({
+ path: `/partners/${partner.id}`,
+ });
- const { data: partnerAfter } = await http.get<EnrolledPartnerProps>({
- path: `/partners/${partner.id}`,
- });
-
- expect(partnerAfter.groupId).toBe(targetGroup.id);
- });
+ expect(partnerAfter.groupId).toBe(targetGroup.id);
+ },
+ );
test("Multiple move rules can be configured (AND operator)", async () => {
const slug = "e2e-multi-rules";
@@ -463,13 +460,13 @@ describe.sequential("Workflow - MoveGroup", async () => {
moveRules: [
{
attribute: "totalLeads",
- operator: "gte",
- value: 10,
+ operator: "between",
+ value: { min: 2, max: 3 },
},
{
attribute: "totalConversions",
- operator: "gte",
- value: 5,
+ operator: "between",
+ value: { min: 1, max: 2 },
},
],
},
@@ -487,8 +484,8 @@ describe.sequential("Workflow - MoveGroup", async () => {
const workflowConditions = workflow.triggerConditions as any[];
expect(workflowConditions).toHaveLength(2);
expect(workflowConditions[0].attribute).toBe("totalLeads");
- expect(workflowConditions[0].value).toBe(10);
+ expect(workflowConditions[0].value).toStrictEqual({ min: 2, max: 3 });
expect(workflowConditions[1].attribute).toBe("totalConversions");
- expect(workflowConditions[1].value).toBe(5);
+ expect(workflowConditions[1].value).toStrictEqual({ min: 1, max: 2 });
});
});
diff --git a/apps/web/tests/workflows/utils/track-e2e-lead.ts b/apps/web/tests/workflows/utils/track-e2e-lead.ts
new file mode 100644
index 0000000000..1452fb5ece
--- /dev/null
+++ b/apps/web/tests/workflows/utils/track-e2e-lead.ts
@@ -0,0 +1,31 @@
+import { expect } from "vitest";
+import { E2E_TRACK_CLICK_HEADERS } from "../../utils/resource";
+
+export async function trackE2ELead(
+ http: any,
+ partnerLink: { domain: string; key: string },
+) {
+ const { status: clickStatus, data: clickData } = await http.post({
+ path: "/track/click",
+ headers: E2E_TRACK_CLICK_HEADERS,
+ body: {
+ domain: partnerLink.domain,
+ key: partnerLink.key,
+ },
+ });
+
+ expect(clickStatus).toEqual(200);
+ expect(clickData.clickId).toBeDefined();
+
+ const { status: leadStatus } = await http.post({
+ path: "/track/lead",
+ body: {
+ clickId: clickData.clickId,
+ eventName: `Signup-${Date.now()}`,
+ customerExternalId: `e2e-customer-${Date.now()}`,
+ customerEmail: `[email protected]`,
+ },
+ });
+
+ expect(leadStatus).toEqual(200);
+}
diff --git a/apps/web/tests/workflows/utils/track-leads.ts b/apps/web/tests/workflows/utils/track-leads.ts
deleted file mode 100644
index 353665ed8a..0000000000
--- a/apps/web/tests/workflows/utils/track-leads.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { expect } from "vitest";
-import { E2E_TRACK_CLICK_HEADERS } from "../../utils/resource";
-
-export async function trackLeads(
- http: any,
- partnerLink: { domain: string; key: string },
- count: number,
-) {
- for (let i = 0; i < count; i++) {
- const { status: clickStatus, data: clickData } = await http.post({
- path: "/track/click",
- headers: E2E_TRACK_CLICK_HEADERS,
- body: {
- domain: partnerLink.domain,
- key: partnerLink.key,
- },
- });
-
- expect(clickStatus).toEqual(200);
- expect(clickData.clickId).toBeDefined();
-
- const { status: leadStatus } = await http.post({
- path: "/track/lead",
- body: {
- clickId: clickData.clickId,
- eventName: `Signup-${i}-${Date.now()}`,
- customerExternalId: `e2e-customer-${i}-${Date.now()}`,
- customerEmail: `customer${i}@example.com`,
- },
- });
-
- expect(leadStatus).toEqual(200);
-
- await new Promise((resolve) => setTimeout(resolve, 200));
- }
-}