@@ -3,12 +3,13 @@ import { clean, tmpdir } from "../utils/helpers"
3
3
import * as path from "path"
4
4
import { promises as fs } from "fs"
5
5
6
+ const routes = [ "/" , "/vscode" , "/vscode/" ]
7
+
6
8
describe ( "VS Code Routes" , [ "--disable-workspace-trust" ] , { } , async ( ) => {
7
9
const testName = "integrated-terminal"
8
10
test . beforeAll ( async ( ) => {
9
11
await clean ( testName )
10
12
} )
11
- const routes = [ "/" , "/vscode" , "/vscode/" ]
12
13
13
14
test ( "should load all route variations" , async ( { codeServerPage } ) => {
14
15
for ( const route of routes ) {
@@ -63,7 +64,7 @@ describe("VS Code Routes with code-workspace", ["--disable-workspace-trust", COD
63
64
await clean ( testName )
64
65
} )
65
66
66
- test . only ( "should redirect to the passed in folder using human-readable query" , async ( { codeServerPage } ) => {
67
+ test ( "should redirect to the passed in folder using human-readable query" , async ( { codeServerPage } ) => {
67
68
const url = new URL ( codeServerPage . page . url ( ) )
68
69
expect ( url . pathname ) . toBe ( "/" )
69
70
expect ( url . search ) . toBe ( `?folder=${ CODE_FOLDER_DIR } ` )
@@ -84,3 +85,44 @@ describe(
84
85
} )
85
86
} ,
86
87
)
88
+
89
+ describe (
90
+ "VS Code Routes with no workspace or folder" ,
91
+ [ "--disable-workspace-trust" ] ,
92
+ { } ,
93
+ async ( ) => {
94
+ test ( "should redirect to last query folder/workspace" , async ( { codeServerPage } ) => {
95
+ const folder = process . env . CODE_FOLDER_DIR
96
+ const workspace = process . env . CODE_WORKSPACE_DIR
97
+ await codeServerPage . navigate ( `/?folder=${ folder } &workspace=${ workspace } ` )
98
+
99
+ // If you visit again without query parameters it will re-attach them by
100
+ // redirecting. It should always redirect to the same route.
101
+ for ( const route of routes ) {
102
+ await codeServerPage . navigate ( route )
103
+ const url = new URL ( codeServerPage . page . url ( ) )
104
+ expect ( url . pathname ) . toBe ( route )
105
+ expect ( url . search ) . toBe ( `?folder=${ folder } &workspace=${ workspace } ` )
106
+ }
107
+ } )
108
+ } ,
109
+ )
110
+
111
+ describe (
112
+ "VS Code Routes with no workspace or folder" ,
113
+ [ "--disable-workspace-trust" ] ,
114
+ { } ,
115
+ async ( ) => {
116
+ test ( "should not redirect if ew passed in" , async ( { codeServerPage } ) => {
117
+ const folder = process . env . CODE_FOLDER_DIR
118
+ const workspace = process . env . CODE_WORKSPACE_DIR
119
+ await codeServerPage . navigate ( `/?folder=${ folder } &workspace=${ workspace } ` )
120
+
121
+ // Closing the folder should stop the redirecting.
122
+ await codeServerPage . navigate ( "/?ew=true" )
123
+ let url = new URL ( codeServerPage . page . url ( ) )
124
+ expect ( url . pathname ) . toBe ( "/" )
125
+ expect ( url . search ) . toBe ( "?ew=true" )
126
+ } )
127
+ } ,
128
+ )
0 commit comments