1
1
import { describe , test , expect } from "./baseFixture"
2
- import { clean } from "../utils/helpers"
2
+ import { clean , getMaybeProxiedPathname } from "../utils/helpers"
3
3
import { REVERSE_PROXY_BASE_PATH } from "../utils/constants"
4
4
5
5
const routes = [ "/" , "/vscode" , "/vscode/" ]
@@ -16,13 +16,8 @@ describe("VS Code Routes", ["--disable-workspace-trust"], {}, async () => {
16
16
17
17
// Check there were no redirections
18
18
const url = new URL ( codeServerPage . page . url ( ) )
19
- if ( process . env . USE_PROXY === "1" ) {
20
- // Behind proxy, path will be /<port/ide + route
21
- const pathWithoutProxy = url . pathname . split ( `/${ REVERSE_PROXY_BASE_PATH } ` ) [ 1 ]
22
- expect ( pathWithoutProxy ) . toBe ( route )
23
- } else {
24
- expect ( url . pathname ) . toBe ( route )
25
- }
19
+ const pathname = getMaybeProxiedPathname ( url )
20
+ expect ( pathname ) . toBe ( route )
26
21
27
22
// TODO@jsjoeio
28
23
// now that we are in a proper browser instead of scraping the HTML we
@@ -48,7 +43,8 @@ const CODE_WORKSPACE_DIR = process.env.CODE_WORKSPACE_DIR || ""
48
43
describe ( "VS Code Routes with code-workspace" , [ "--disable-workspace-trust" , CODE_WORKSPACE_DIR ] , { } , async ( ) => {
49
44
test ( "should redirect to the passed in workspace using human-readable query" , async ( { codeServerPage } ) => {
50
45
const url = new URL ( codeServerPage . page . url ( ) )
51
- expect ( url . pathname ) . toBe ( "/" )
46
+ const pathname = getMaybeProxiedPathname ( url )
47
+ expect ( pathname ) . toBe ( "/" )
52
48
expect ( url . search ) . toBe ( `?workspace=${ CODE_WORKSPACE_DIR } ` )
53
49
} )
54
50
} )
@@ -57,7 +53,8 @@ const CODE_FOLDER_DIR = process.env.CODE_FOLDER_DIR || ""
57
53
describe ( "VS Code Routes with code-workspace" , [ "--disable-workspace-trust" , CODE_FOLDER_DIR ] , { } , async ( ) => {
58
54
test ( "should redirect to the passed in folder using human-readable query" , async ( { codeServerPage } ) => {
59
55
const url = new URL ( codeServerPage . page . url ( ) )
60
- expect ( url . pathname ) . toBe ( "/" )
56
+ const pathname = getMaybeProxiedPathname ( url )
57
+ expect ( pathname ) . toBe ( "/" )
61
58
expect ( url . search ) . toBe ( `?folder=${ CODE_FOLDER_DIR } ` )
62
59
} )
63
60
} )
@@ -74,7 +71,8 @@ describe(
74
71
await codeServerPage . navigate ( `/` )
75
72
76
73
const url = new URL ( codeServerPage . page . url ( ) )
77
- expect ( url . pathname ) . toBe ( "/" )
74
+ const pathname = getMaybeProxiedPathname ( url )
75
+ expect ( pathname ) . toBe ( "/" )
78
76
expect ( url . search ) . toBe ( "" )
79
77
} )
80
78
} ,
@@ -91,7 +89,8 @@ describe("VS Code Routes with no workspace or folder", ["--disable-workspace-tru
91
89
for ( const route of routes ) {
92
90
await codeServerPage . navigate ( route )
93
91
const url = new URL ( codeServerPage . page . url ( ) )
94
- expect ( url . pathname ) . toBe ( route )
92
+ const pathname = getMaybeProxiedPathname ( url )
93
+ expect ( pathname ) . toBe ( route )
95
94
expect ( url . search ) . toBe ( `?folder=${ folder } &workspace=${ workspace } ` )
96
95
}
97
96
} )
@@ -106,7 +105,8 @@ describe("VS Code Routes with no workspace or folder", ["--disable-workspace-tru
106
105
// Closing the folder should stop the redirecting.
107
106
await codeServerPage . navigate ( "/?ew=true" )
108
107
let url = new URL ( codeServerPage . page . url ( ) )
109
- expect ( url . pathname ) . toBe ( "/" )
108
+ const pathname = getMaybeProxiedPathname ( url )
109
+ expect ( pathname ) . toBe ( "/" )
110
110
expect ( url . search ) . toBe ( "?ew=true" )
111
111
} )
112
112
} )
0 commit comments