@@ -37,6 +37,7 @@ export class CodeServer {
3737 private process : Promise < CodeServerProcess > | undefined
3838 public readonly logger : Logger
3939 private closed = false
40+ private workspaceDir : Promise < string > | undefined
4041
4142 constructor ( name : string , private readonly codeServerArgs : string [ ] ) {
4243 this . logger = logger . named ( name )
@@ -54,11 +55,18 @@ export class CodeServer {
5455 return address
5556 }
5657
58+ async dir ( ) : Promise < string > {
59+ if ( ! this . workspaceDir ) {
60+ this . workspaceDir = tmpdir ( workspaceDir )
61+ }
62+ return this . workspaceDir
63+ }
64+
5765 /**
5866 * Create a random workspace and seed it with settings.
5967 */
6068 private async createWorkspace ( ) : Promise < string > {
61- const dir = await tmpdir ( workspaceDir )
69+ const dir = await this . dir ( )
6270 await fs . mkdir ( path . join ( dir , "User" ) )
6371 await fs . writeFile (
6472 path . join ( dir , "User/settings.json" ) ,
@@ -190,6 +198,10 @@ export class CodeServerPage {
190198 return this . codeServer . address ( )
191199 }
192200
201+ dir ( ) {
202+ return this . codeServer . dir ( )
203+ }
204+
193205 /**
194206 * Navigate to code-server.
195207 */
@@ -280,6 +292,22 @@ export class CodeServerPage {
280292 await this . page . waitForSelector ( "textarea.xterm-helper-textarea" )
281293 }
282294
295+ /**
296+ * Open a file by using menus.
297+ */
298+ async openFile ( file : string ) {
299+ await this . navigateMenus ( [ "File" , "Open File" ] )
300+ await this . navigatePicker ( [ path . basename ( file ) ] )
301+ await this . waitForTab ( file )
302+ }
303+
304+ /**
305+ * Wait for a tab to open for the specified file.
306+ */
307+ async waitForTab ( file : string ) : Promise < void > {
308+ return this . page . waitForSelector ( `.tab :text("${ path . basename ( file ) } ")` )
309+ }
310+
283311 /**
284312 * Navigate to the command palette via menus then execute a command by typing
285313 * it then clicking the match from the results.
0 commit comments