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.

Refactor tests to use randomTagName for tag generation

Kiran Kd189bf5de724
diff --git a/apps/web/tests/links/bulk-update-link.test.ts b/apps/web/tests/links/bulk-update-link.test.ts
index f69b589388..a7982954e6 100644
--- a/apps/web/tests/links/bulk-update-link.test.ts
+++ b/apps/web/tests/links/bulk-update-link.test.ts
@@ -1,6 +1,6 @@
import { Link, Tag } from "@dub/prisma/client";
import { afterAll, expect, test } from "vitest";
-import { randomId } from "../utils/helpers";
+import { randomId, randomTagName } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
import { E2E_LINK } from "../utils/resource";
import { expectedLink } from "../utils/schema";
@@ -34,7 +34,7 @@ test("PATCH /links/bulk", async (ctx) => {
.concat(["xxx"])
.filter(Boolean);
- const tagName = randomId();
+ const tagName = randomTagName();
const { data: tag } = await http.post<Tag>({
path: "/tags",
query: { workspaceId },
diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.ts
index aeb3ebde4c..60771297c6 100644
--- a/apps/web/tests/links/create-link.test.ts
+++ b/apps/web/tests/links/create-link.test.ts
@@ -1,7 +1,7 @@
import { Link, Tag } from "@dub/prisma/client";
import { IntegrationHarnessOld } from "tests/utils/integration-old";
import { afterAll, describe, expect, test } from "vitest";
-import { randomId } from "../utils/helpers";
+import { randomId, randomTagName } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
import { E2E_LINK, E2E_WEBHOOK_ID } from "../utils/resource";
import { LinkSchema, expectedLink } from "../utils/schema";
@@ -312,8 +312,8 @@ describe.sequential("POST /links", async () => {
test("tags", async () => {
const tagsToCreate = [
- { tag: randomId(), color: "red" },
- { tag: randomId(), color: "green" },
+ { tag: randomTagName(), color: "red" },
+ { tag: randomTagName(), color: "green" },
];
const response = await Promise.all(
diff --git a/apps/web/tests/tags/create-tag.test.ts b/apps/web/tests/tags/create-tag.test.ts
index bd6cb2f71e..7d75e31455 100644
--- a/apps/web/tests/tags/create-tag.test.ts
+++ b/apps/web/tests/tags/create-tag.test.ts
@@ -1,6 +1,6 @@
import { Tag } from "@dub/prisma/client";
import { afterAll, expect, test } from "vitest";
-import { randomId } from "../utils/helpers";
+import { randomTagName } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
test("POST /tags", async (ctx) => {
@@ -8,7 +8,7 @@ test("POST /tags", async (ctx) => {
const { http } = await h.init();
const newTag = {
- name: randomId(),
+ name: randomTagName(),
color: "red",
};
diff --git a/apps/web/tests/tags/list-tags.test.ts b/apps/web/tests/tags/list-tags.test.ts
index 7e2f0a527b..7c2380d24d 100644
--- a/apps/web/tests/tags/list-tags.test.ts
+++ b/apps/web/tests/tags/list-tags.test.ts
@@ -1,6 +1,6 @@
import { Tag } from "@dub/prisma/client";
import { expect, test } from "vitest";
-import { randomId } from "../utils/helpers";
+import { randomTagName } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
test("GET /tags", async (ctx) => {
@@ -8,7 +8,7 @@ test("GET /tags", async (ctx) => {
const { http } = await h.init();
const newTag = {
- tag: randomId(),
+ tag: randomTagName(),
color: "red",
};
diff --git a/apps/web/tests/utils/helpers.ts b/apps/web/tests/utils/helpers.ts
index 3c082b4f98..ba002698c0 100644
--- a/apps/web/tests/utils/helpers.ts
+++ b/apps/web/tests/utils/helpers.ts
@@ -15,3 +15,7 @@ export const randomCustomer = () => {
avatar: `https://api.dicebear.com/9.x/notionists/png?seed=${customerId}`,
};
};
+
+export const randomTagName = () => {
+ return `e2e-${randomId()}`;
+};