Skip to content

Commit 9e93eb0

Browse files
committed
Fix tests
1 parent b093806 commit 9e93eb0

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

site/src/modules/apps/apps.test.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,23 @@ describe("getAppHref", () => {
2121
expect(href).toBe(externalApp.url);
2222
});
2323

24-
it("returns the URL with the session token replaced when external app needs session token ", () => {
24+
it("returns the URL with the session token replaced when external app needs session token", () => {
25+
const externalApp = {
26+
...MockWorkspaceApp,
27+
external: true,
28+
url: `vscode://example.com?token=${SESSION_TOKEN_PLACEHOLDER}`,
29+
};
30+
const href = getAppHref(externalApp, {
31+
host: "*.apps-host.tld",
32+
path: "/path-base",
33+
agent: MockWorkspaceAgent,
34+
workspace: MockWorkspace,
35+
token: "user-session-token",
36+
});
37+
expect(href).toBe("vscode://example.com?token=user-session-token");
38+
});
39+
40+
it("doesn't return the URL with the session token replaced when using the HTTP protocol", () => {
2541
const externalApp = {
2642
...MockWorkspaceApp,
2743
external: true,
@@ -34,7 +50,7 @@ describe("getAppHref", () => {
3450
workspace: MockWorkspace,
3551
token: "user-session-token",
3652
});
37-
expect(href).toBe("https://example.com?token=user-session-token");
53+
expect(href).toBe(externalApp.url);
3854
});
3955

4056
it("returns a path when app doesn't use a subdomain", () => {
@@ -49,7 +65,7 @@ describe("getAppHref", () => {
4965
path: "/path-base",
5066
});
5167
expect(href).toBe(
52-
"/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/",
68+
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
5369
);
5470
});
5571

@@ -62,10 +78,10 @@ describe("getAppHref", () => {
6278
host: "*.apps-host.tld",
6379
agent: MockWorkspaceAgent,
6480
workspace: MockWorkspace,
65-
path: "/path-base",
81+
path: "",
6682
});
6783
expect(href).toBe(
68-
"/path-base/@username/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la",
84+
`/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`,
6985
);
7086
});
7187

@@ -81,7 +97,7 @@ describe("getAppHref", () => {
8197
workspace: MockWorkspace,
8298
path: "/path-base",
8399
});
84-
expect(href).toBe("https://hellocoder.apps-host.tld/");
100+
expect(href).toBe("http://hellocoder.apps-host.tld/");
85101
});
86102

87103
it("returns a path when app has a subdomain but no subdomain name", () => {
@@ -97,7 +113,7 @@ describe("getAppHref", () => {
97113
path: "/path-base",
98114
});
99115
expect(href).toBe(
100-
"/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/",
116+
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
101117
);
102118
});
103119
});

0 commit comments

Comments
 (0)