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 the tags

Kiran K1dc586a8dd7c
diff --git a/apps/web/tests/tags/list-tags.test.ts b/apps/web/tests/tags/list-tags.test.ts
index 56038f3286..be8a4ba6ac 100644
--- a/apps/web/tests/tags/list-tags.test.ts
+++ b/apps/web/tests/tags/list-tags.test.ts
@@ -1,5 +1,6 @@
import { Tag } from "@prisma/client";
import { expect, test } from "vitest";
+import { randomId } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
test("GET /tags", async (ctx) => {
@@ -7,38 +8,32 @@ test("GET /tags", async (ctx) => {
const { workspace, http } = await h.init();
const { workspaceId } = workspace;
- const tagsToCreate = [
- { tag: "news", color: "red" },
- { tag: "work", color: "green" },
- ];
+ const newTag = {
+ tag: randomId(),
+ color: "red",
+ };
- for (const { tag, color } of tagsToCreate) {
- await http.post<Tag>({
- path: "/tags",
- query: { workspaceId },
- body: { tag, color },
- });
- }
+ const { data: tagCreated } = await http.post<Tag>({
+ path: "/tags",
+ query: { workspaceId },
+ body: newTag,
+ });
- // Fetch the list of tags
const { status, data: tags } = await http.get<Tag[]>({
path: "/tags",
query: { workspaceId },
});
expect(status).toEqual(200);
- expect(tags).toStrictEqual([
- {
- id: expect.any(String),
- name: "news",
- color: "red",
- },
- {
- id: expect.any(String),
- name: "work",
- color: "green",
- },
- ]);
+ expect(tags).toEqual(
+ expect.arrayContaining([
+ {
+ id: tagCreated.id,
+ name: tagCreated.name,
+ color: tagCreated.color,
+ },
+ ]),
+ );
- await Promise.all(tags.map((tag) => h.deleteTag(tag.id)));
+ await h.deleteTag(tagCreated.id);
});
diff --git a/apps/web/tests/utils/helpers.ts b/apps/web/tests/utils/helpers.ts
new file mode 100644
index 0000000000..e573a55771
--- /dev/null
+++ b/apps/web/tests/utils/helpers.ts
@@ -0,0 +1 @@
+export const randomId = () => Math.random().toString(36).substr(2, 9);
\ No newline at end of file
diff --git a/apps/web/tests/utils/schema.ts b/apps/web/tests/utils/schema.ts
index b3a4e12e25..75a639a4b0 100644
--- a/apps/web/tests/utils/schema.ts
+++ b/apps/web/tests/utils/schema.ts
@@ -38,9 +38,11 @@ export const expectedTag: Partial<Tag> = {
updatedAt: expect.any(String),
};
+// TODO:
+// Make it dynamic based on the plan
export const expectedWorkspace: Partial<Project> = {
- logo: expect.any(Symbol),
- plan: expect.any(Number),
+ logo: expect.any(String) || null,
+ plan: expect.any(String),
stripeId: null,
usage: expect.any(Number),
usageLimit: 1000,