Skip to content

Commit 3092183

Browse files
authored
e2e: notebook infra/cleanup (#9831)
### Summary The objective of this PR was to update some of the e2e Positron Notebook infra to make the tests more maintainable and reliable (fixed some flakes). I also removed a quite a few hardcoded waits that weren't necessary once the assertions were improved. I will be keeping an eye on them to quickly address any upcoming flakes. ### QA Notes @:positron-notebooks
1 parent 174c607 commit 3092183

19 files changed

+1000
-1236
lines changed

test/e2e/fixtures/test-setup/settings.fixtures.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export function SettingsFixture(app: Application) {
2929
}
3030

3131
if (waitForReady) {
32+
await app.code.driver.page.waitForTimeout(3000);
33+
await app.code.driver.page.locator('.monaco-workbench').waitFor({ state: 'visible' });
3234
await app.workbench.sessions.expectNoStartUpMessaging();
3335
}
3436
},

test/e2e/infra/workbench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ export class Workbench {
115115
this.output = new Output(code, this.quickaccess, this.quickInput);
116116
this.console = new Console(code, this.quickInput, this.quickaccess, this.hotKeys, this.contextMenu);
117117
this.modals = new Modals(code, this.toasts, this.console);
118+
this.clipboard = new Clipboard(code, this.hotKeys);
118119
this.sessions = new Sessions(code, this.quickaccess, this.quickInput, this.console);
119120
this.notebooks = new Notebooks(code, this.quickInput, this.quickaccess, this.hotKeys);
120121
this.notebooksVscode = new VsCodeNotebooks(code, this.quickInput, this.quickaccess, this.hotKeys);
121-
this.notebooksPositron = new PositronNotebooks(code, this.quickInput, this.quickaccess, this.hotKeys);
122+
this.notebooksPositron = new PositronNotebooks(code, this.quickInput, this.quickaccess, this.hotKeys, this.clipboard);
122123
this.welcome = new Welcome(code);
123-
this.clipboard = new Clipboard(code, this.hotKeys);
124124
this.terminal = new Terminal(code, this.quickaccess, this.clipboard);
125125
this.viewer = new Viewer(code);
126126
this.editor = new Editor(code);

test/e2e/pages/clipboard.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,38 @@ export class Clipboard {
1616
// Seed the clipboard
1717
await this.setClipboardText(seed);
1818

19-
// Invoke the copy hotkey
20-
await this.hotKeys.copy();
21-
2219
// Wait until clipboard value differs from the seed
2320
await expect
24-
.poll(async () => (await this.getClipboardText()) ?? '', {
21+
.poll(async () => {
22+
await this.hotKeys.copy();
23+
return (await this.getClipboardText()) ?? '';
24+
}, {
2525
message: 'clipboard should change after copy',
2626
timeout: timeoutMs,
2727
intervals: [100, 150, 200, 300, 500, 800],
2828
})
2929
.not.toBe(seed);
3030
}
3131

32+
async cut(timeoutMs = 5000): Promise<void> {
33+
const seed = '__SEED__';
34+
// Seed the clipboard
35+
await this.setClipboardText(seed);
36+
37+
// Wait until clipboard value differs from the seed
38+
await this.hotKeys.cut();
39+
40+
await expect
41+
.poll(async () => {
42+
return (await this.getClipboardText()) ?? '';
43+
}, {
44+
message: 'clipboard should change after cut',
45+
timeout: timeoutMs,
46+
intervals: [100, 150, 200, 300, 500, 800],
47+
})
48+
.not.toBe(seed);
49+
}
50+
3251
async paste(): Promise<void> {
3352
await this.hotKeys.paste();
3453
}

test/e2e/pages/hotKeys.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,15 @@ export class HotKeys {
201201
await this.pressHotKeys('Cmd+J K', 'Open workspace settings JSON', true);
202202
}
203203

204-
public async reloadWindow() {
204+
public async reloadWindow(waitForReady = false) {
205205
await this.pressHotKeys('Cmd+R R', 'Reload window');
206+
207+
// wait for workbench to disappear, reappear and be ready
208+
await this.code.driver.page.waitForTimeout(3000);
209+
await this.code.driver.page.locator('.monaco-workbench').waitFor({ state: 'visible' });
210+
if (waitForReady) {
211+
await expect(this.code.driver.page.locator('text=/^Starting up|^Starting|^Preparing|^Discovering( \\w+)? interpreters|starting\\.$/i')).toHaveCount(0, { timeout: 90000 });
212+
}
206213
}
207214

208215
public async openWelcomeWalkthrough() {

test/e2e/pages/notebooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class Notebooks {
119119
});
120120
}
121121

122-
async addCodeToCellAtIndex(code: string, cellIndex = 0, delay = 0) {
122+
async addCodeToCellAtIndex(cellIndex: number, code: string, delay = 0) {
123123
await test.step('Add code to first cell', async () => {
124124
await this.selectCellAtIndex(cellIndex);
125125
await this.typeInEditor(code, delay);

0 commit comments

Comments
 (0)