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.

Add tests for reserved workspace slug suffixes

Rafi50efff53bf2c
diff --git a/apps/web/tests/misc/workspace-slug-suffix.test.ts b/apps/web/tests/misc/workspace-slug-suffix.test.ts
new file mode 100644
index 0000000000..82fcc049d5
--- /dev/null
+++ b/apps/web/tests/misc/workspace-slug-suffix.test.ts
@@ -0,0 +1,27 @@
+import { createWorkspaceSchema } from "@/lib/zod/schemas/workspaces";
+import { describe, expect, it } from "vitest";
+
+function parseSlug(slug: string) {
+ return createWorkspaceSchema.safeParseAsync({ name: "Acme", slug });
+}
+
+describe("createWorkspaceSchema slug", () => {
+ it("rejects slugs ending in -staging or -sandbox", async () => {
+ for (const slug of ["acme-staging", "acme-sandbox"]) {
+ const result = await parseSlug(slug);
+
+ expect(result.success).toBe(false);
+ expect(result.error?.issues[0]?.message).toBe(
+ "Slugs ending in -staging or -sandbox are reserved",
+ );
+ }
+ });
+
+ it("allows staging or sandbox elsewhere in the slug", async () => {
+ for (const slug of ["acme", "staging-acme", "acme-sandboxes"]) {
+ const result = await parseSlug(slug);
+
+ expect(result.success).toBe(true);
+ }
+ });
+});