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.

retrieve workspace

Kiran K67f02a1138ee
diff --git a/apps/web/tests/workspaces/retrieve-workspace.error.test.ts b/apps/web/tests/workspaces/retrieve-workspace.error.test.ts
new file mode 100644
index 0000000000..4ad156a623
--- /dev/null
+++ b/apps/web/tests/workspaces/retrieve-workspace.error.test.ts
@@ -0,0 +1,26 @@
+import { Project } from "@prisma/client";
+import { describe, expect, test } from "vitest";
+import { HttpClient } from "../utils/http";
+import { IntegrationHarness } from "../utils/integration";
+
+// TODO:
+// Retrieve workspace not owned by current user
+
+test("retrieve a workspace by invalid slug or id", async (ctx) => {
+ const h = new IntegrationHarness(ctx);
+ const { workspace, apiKey } = await h.init();
+
+ const http = new HttpClient({
+ baseUrl: h.baseUrl,
+ headers: {
+ Authorization: `Bearer ${apiKey.token}`,
+ },
+ });
+
+ const { status, data: error } = await http.get<Project>({
+ path: `/workspaces/xxxx`,
+ });
+
+ expect(status).toEqual(404);
+ // Add error
+});
\ No newline at end of file
diff --git a/apps/web/tests/workspaces/retrieve-workspace.test.ts b/apps/web/tests/workspaces/retrieve-workspace.test.ts
index 21ba8862ee..9910b09522 100644
--- a/apps/web/tests/workspaces/retrieve-workspace.test.ts
+++ b/apps/web/tests/workspaces/retrieve-workspace.test.ts
@@ -3,30 +3,46 @@ import { describe, expect, test } from "vitest";
import { HttpClient } from "../utils/http";
import { IntegrationHarness } from "../utils/integration";
-describe("retrieve a workspace", async () => {
- test("by id", async (ctx) => {
- const h = new IntegrationHarness(ctx);
- const { workspace, apiKey } = await h.init();
-
- const http = new HttpClient({
- baseUrl: h.baseUrl,
- headers: {
- Authorization: `Bearer ${apiKey.token}`,
- },
- });
-
- const { status, data: workspaceFetched } = await http.get<Project>({
- path: `/workspaces/${workspace.id}`,
- });
-
- expect(status).toEqual(200);
- expect(workspaceFetched).toEqual({
- workspace,
- domains: [],
- });
-
- // await http.delete({
- // path: `/workspaces/ws_${workspace.id}`,
- // });
+test("retrieve a workspace by id", async (ctx) => {
+ const h = new IntegrationHarness(ctx);
+ const { workspace, apiKey } = await h.init();
+
+ const http = new HttpClient({
+ baseUrl: h.baseUrl,
+ headers: {
+ Authorization: `Bearer ${apiKey.token}`,
+ },
+ });
+
+ const { status, data: workspaceFetched } = await http.get<Project>({
+ path: `/workspaces/${workspace.id}`,
});
+
+ expect(status).toEqual(200);
+ expect(workspaceFetched).toEqual({
+ workspace,
+ domains: [],
+ })
});
+
+test("retrieve a workspace by slug", async (ctx) => {
+ const h = new IntegrationHarness(ctx);
+ const { workspace, apiKey } = await h.init();
+
+ const http = new HttpClient({
+ baseUrl: h.baseUrl,
+ headers: {
+ Authorization: `Bearer ${apiKey.token}`,
+ },
+ });
+
+ const { status, data: workspaceFetched } = await http.get<Project>({
+ path: `/workspaces/${workspace.slug}`,
+ });
+
+ expect(status).toEqual(200);
+ expect(workspaceFetched).toEqual({
+ workspace,
+ domains: [],
+ })
+});
\ No newline at end of file