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 folder link access error scenarios

Kiran Kd9813b5ae19b
diff --git a/apps/web/tests/links/folder-link-access.test.ts b/apps/web/tests/links/folder-link-access.test.ts
index 14b41eddf6..12c445c968 100644
--- a/apps/web/tests/links/folder-link-access.test.ts
+++ b/apps/web/tests/links/folder-link-access.test.ts
@@ -3,6 +3,7 @@ import { describe, expect, test } from "vitest";
import { IntegrationHarness } from "../utils/integration";
import {
E2E_LINK,
+ E2E_NO_ACCESS_FOLDER_ID,
E2E_READ_ONLY_FOLDER_ID,
E2E_READ_ONLY_FOLDER_LINK_ID,
} from "../utils/resource";
@@ -199,4 +200,40 @@ describe.sequential("Folder Access Tests", async () => {
},
});
});
+
+ test("access links within an invalid folder", async () => {
+ const { status, data } = await http.get({
+ path: "/links",
+ query: {
+ folderId: "fold_invalid",
+ },
+ });
+
+ expect(status).toEqual(404);
+ expect(data).toEqual({
+ error: {
+ code: "not_found",
+ message: "Folder not found.",
+ doc_url: "https://dub.co/docs/api-reference/errors#not-found",
+ },
+ });
+ });
+
+ test("access links within a folder with no access", async () => {
+ const { status, data } = await http.get({
+ path: "/links",
+ query: {
+ folderId: E2E_NO_ACCESS_FOLDER_ID,
+ },
+ });
+
+ expect(status).toEqual(403);
+ expect(data).toEqual({
+ error: {
+ code: "forbidden",
+ message: "You are not allowed to perform this action on this folder.",
+ doc_url: "https://dub.co/docs/api-reference/errors#forbidden",
+ },
+ });
+ });
});
diff --git a/apps/web/tests/utils/resource.ts b/apps/web/tests/utils/resource.ts
index e9cca05ad3..37780bafa1 100644
--- a/apps/web/tests/utils/resource.ts
+++ b/apps/web/tests/utils/resource.ts
@@ -7,3 +7,8 @@ export const E2E_CLICK_ID = "GWGrkftJdYlZD2mq";
export const E2E_CUSTOMER_ID = "cm25onzuv0001s1bbxchrc0ae";
export const E2E_CUSTOMER_EXTERNAL_ID = "cus_jTrfVKYN3Buc3F80JoqBiY0g";
export const E2E_WEBHOOK_ID = "wh_MHR7sZXXtZ7keBaNYZ30rQ0v";
+
+// Folders specific
+export const E2E_READ_ONLY_FOLDER_ID = "fold_XgAYzHjSq6z0X5R60cXymphU"; // Folder without write access
+export const E2E_NO_ACCESS_FOLDER_ID = "fold_CPXCwj8wBWd222NuQ2zEGZHj"; // Folder with no access
+export const E2E_READ_ONLY_FOLDER_LINK_ID = "link_9pBo2gl0gIKIjOSDZRcVK6lH"; // Link in folder without write access