Skip to content

Commit c0fa92d

Browse files
committed
Merge setup and navigate functions
Whenever we navigate we probably want to make sure the editor is ready so might as well just have one function.
1 parent 0e78a14 commit c0fa92d

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

test/e2e/baseFixture.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export const test = base.extend<TestFixtures>({
7070
// made too). In these cases just accept.
7171
page.on("dialog", (d) => d.accept())
7272

73-
const codeServerPage = new CodeServerPage(codeServer, page)
74-
await codeServerPage.setup(authenticated)
73+
const codeServerPage = new CodeServerPage(codeServer, page, authenticated)
74+
await codeServerPage.navigate()
7575
await use(codeServerPage)
7676
},
7777
})

test/e2e/models/CodeServer.ts

+14-17
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ export class CodeServer {
194194
export class CodeServerPage {
195195
private readonly editorSelector = "div.monaco-workbench"
196196

197-
constructor(private readonly codeServer: CodeServer, public readonly page: Page) {
197+
constructor(
198+
private readonly codeServer: CodeServer,
199+
public readonly page: Page,
200+
private readonly authenticated: boolean,
201+
) {
198202
this.page.on("console", (message) => {
199203
this.codeServer.logger.debug(message)
200204
})
@@ -215,11 +219,18 @@ export class CodeServerPage {
215219
}
216220

217221
/**
218-
* Navigate to a code-server endpoint. By default go to the root.
222+
* Navigate to a code-server endpoint (root by default). Then wait for the
223+
* editor to become available.
219224
*/
220225
async navigate(endpoint = "/") {
221226
const to = new URL(endpoint, await this.codeServer.address())
222227
await this.page.goto(to.toString(), { waitUntil: "networkidle" })
228+
229+
// If we aren't authenticated we'll see a login page so we can't wait until
230+
// the editor is ready.
231+
if (this.authenticated) {
232+
await this.reloadUntilEditorIsReady()
233+
}
223234
}
224235

225236
/**
@@ -456,21 +467,7 @@ export class CodeServerPage {
456467
}
457468

458469
/**
459-
* Navigates to code-server then reloads until the editor is ready.
460-
*
461-
* It is recommended to run setup before using this model in any tests.
462-
*/
463-
async setup(authenticated: boolean, endpoint = "/") {
464-
await this.navigate(endpoint)
465-
// If we aren't authenticated we'll see a login page so we can't wait until
466-
// the editor is ready.
467-
if (authenticated) {
468-
await this.reloadUntilEditorIsReady()
469-
}
470-
}
471-
472-
/**
473-
* Execute a command in t root of the instance's workspace directory.
470+
* Execute a command in the root of the instance's workspace directory.
474471
*/
475472
async exec(command: string): Promise<void> {
476473
await util.promisify(cp.exec)(command, {

0 commit comments

Comments
 (0)