Skip to content

Commit 3760c86

Browse files
committed
fix workspace path & misc
1 parent 0c735a2 commit 3760c86

9 files changed

+55
-52
lines changed

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: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,37 @@ 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 expect
39+
.poll(async () => {
40+
await this.hotKeys.cut();
41+
return (await this.getClipboardText()) ?? '';
42+
}, {
43+
message: 'clipboard should change after cut',
44+
timeout: timeoutMs,
45+
intervals: [100, 150, 200, 300, 500, 800],
46+
})
47+
.not.toBe(seed);
48+
}
49+
3250
async paste(): Promise<void> {
3351
await this.hotKeys.paste();
3452
}

test/e2e/pages/notebooksPositron.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Notebooks } from './notebooks';
77
import { Code } from '../infra/code';
88
import { QuickInput } from './quickInput';
99
import { QuickAccess } from './quickaccess';
10+
import { Clipboard } from './clipboard.js';
1011
import test, { expect, Locator } from '@playwright/test';
1112
import { HotKeys } from './hotKeys.js';
1213

@@ -49,7 +50,7 @@ export class PositronNotebooks extends Notebooks {
4950
cellInfoToolTipOrder = this.cellInfoToolTip.getByLabel('Execution order');
5051
cellInfoToolTipCompleted = this.cellInfoToolTip.getByLabel('Execution completed');
5152

52-
constructor(code: Code, quickinput: QuickInput, quickaccess: QuickAccess, hotKeys: HotKeys) {
53+
constructor(code: Code, quickinput: QuickInput, quickaccess: QuickAccess, hotKeys: HotKeys, private clipboard: Clipboard) {
5354
super(code, quickinput, quickaccess, hotKeys);
5455
}
5556

@@ -124,6 +125,20 @@ export class PositronNotebooks extends Notebooks {
124125
await this.expectToBeVisible();
125126
}
126127

128+
/**
129+
* Create a new Positron notebook.
130+
* @param numCellsToAdd - Number of cells to add after creating the notebook (default: 0).
131+
*/
132+
async newNotebook(numCellsToAdd = 0): Promise<void> {
133+
await this.createNewNotebook();
134+
await this.expectToBeVisible();
135+
if (numCellsToAdd > 0) {
136+
for (let i = 0; i < numCellsToAdd; i++) {
137+
await this.addCodeToCell(i, `# Cell ${i}`);
138+
}
139+
}
140+
}
141+
127142
/**
128143
* @override
129144
* Action: Select a cell at the specified index.
@@ -180,6 +195,7 @@ export class PositronNotebooks extends Notebooks {
180195
* Action: Move the mouse away from the notebook area to close any open tooltips/popups.
181196
*/
182197
async moveMouseAway(): Promise<void> {
198+
await this.code.driver.page.waitForTimeout(500);
183199
await this.code.driver.page.mouse.move(0, 0);
184200
};
185201

@@ -252,13 +268,13 @@ export class PositronNotebooks extends Notebooks {
252268

253269
switch (action) {
254270
case 'copy':
255-
await this.hotKeys.copy();
271+
await this.clipboard.copy();
256272
break;
257273
case 'cut':
258-
await this.hotKeys.cut();
274+
await this.clipboard.cut();
259275
break;
260276
case 'paste':
261-
await this.hotKeys.paste();
277+
await this.clipboard.paste();
262278
break;
263279
case 'undo':
264280
await this.hotKeys.undo();

test/e2e/tests/notebook/cell-deletion-action-bar.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,13 @@ test.describe('Positorn Notebooks: Cell Deletion Action Bar Behavior', {
2626
});
2727

2828
test('Cell deletion using action bar', async function ({ app, settings }) {
29-
const { notebooks, notebooksPositron } = app.workbench;
29+
const { notebooksPositron } = app.workbench;
3030

3131
// ========================================
3232
// Setup: Create 6 cells with distinct content
3333
// ========================================
3434
await test.step(' Test Setup: Create notebook', async () => {
35-
await notebooks.createNewNotebook();
36-
await notebooksPositron.expectToBeVisible();
37-
38-
await notebooksPositron.addCodeToCell(0, '# Cell 0');
39-
await notebooksPositron.addCodeToCell(1, '# Cell 1');
40-
await notebooksPositron.addCodeToCell(2, '# Cell 2');
41-
await notebooksPositron.addCodeToCell(3, '# Cell 3');
42-
await notebooksPositron.addCodeToCell(4, '# Cell 4');
43-
await notebooksPositron.addCodeToCell(5, '# Cell 5');
44-
45-
// Verify we have 6 cells
35+
await notebooksPositron.newNotebook(6);
4636
await notebooksPositron.expectCellCountToBe(6);
4737
});
4838

test/e2e/tests/notebook/notebook-focus-and-selection.test.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,15 @@ test.describe('Notebook Focus and Selection', {
2323

2424
test.beforeEach(async function ({ app }) {
2525
const { notebooksPositron } = app.workbench;
26-
27-
// Create a fresh notebook with 5 cells for each test
28-
await notebooksPositron.createNewNotebook();
29-
await notebooksPositron.expectToBeVisible();
30-
31-
// Add 5 cells with distinct content
32-
await notebooksPositron.addCodeToCell(0, 'print("Cell 0")');
33-
await notebooksPositron.addCodeToCell(1, 'print("Cell 1")');
34-
await notebooksPositron.addCodeToCell(2, 'print("Cell 2")');
35-
await notebooksPositron.addCodeToCell(3, 'print("Cell 3")');
36-
await notebooksPositron.addCodeToCell(4, 'print("Cell 4")');
26+
await notebooksPositron.newNotebook(5);
3727
await notebooksPositron.expectCellCountToBe(5);
3828
});
3929

4030
test.afterEach(async function ({ hotKeys }) {
4131
await hotKeys.closeAllEditors();
4232
});
4333

44-
test('Keyboard behavior with notebook cells', async function ({ app }) {
34+
test('Notebook keyboard behavior with cells', async function ({ app }) {
4535
const { notebooksPositron } = app.workbench;
4636

4737
await test.step('Test 1: Arrow Down navigation moves focus to next cell', async () => {
@@ -148,7 +138,4 @@ test.describe('Notebook Focus and Selection', {
148138
await notebooksPositron.expectCellContentAtIndexToContain(5, 'new cell content');
149139
});
150140
});
151-
152-
153-
154141
});

test/e2e/tests/notebook/notebook-large-python.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test.describe('Large Python Notebook', {
2424
const { notebooks, layouts } = app.workbench;
2525

2626
// open the large Python notebook and run all cells
27-
await openDataFile(join(app.workspacePathOrFolder, 'workspaces', 'large_py_notebook', 'spotify.ipynb'));
27+
await openDataFile(join('workspaces', 'large_py_notebook', 'spotify.ipynb'));
2828
await notebooks.selectInterpreter('Python');
2929
await notebooks.runAllCells(120000);
3030

test/e2e/tests/notebook/notebook-large-r.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test.describe('Large R Notebook', {
2323
const { notebooks, layouts } = app.workbench;
2424

2525
// open the large R notebook and run all cells
26-
await openDataFile(join(app.workspacePathOrFolder, 'workspaces', 'large_r_notebook', 'spotify.ipynb'));
26+
await openDataFile(join('workspaces', 'large_r_notebook', 'spotify.ipynb'));
2727
await notebooks.selectInterpreter('R');
2828
await notebooks.runAllCells(120000);
2929

test/e2e/tests/notebook/positron-notebook-copy-paste.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,7 @@ test.describe('Positron Notebooks: Cell Copy-Paste Behavior', {
3333
// Setup: Create notebook with 5 cells and distinct content
3434
// ========================================
3535
await test.step('Test Setup: Create notebook and add cells', async () => {
36-
// Setup: Create notebook and select kernel once
37-
await notebooksPositron.createNewNotebook();
38-
await notebooksPositron.expectToBeVisible();
39-
40-
// Setup: Create 5 cells with distinct content
41-
await notebooksPositron.addCodeToCell(0, '# Cell 0');
42-
await notebooksPositron.addCodeToCell(1, '# Cell 1');
43-
await notebooksPositron.addCodeToCell(2, '# Cell 2');
44-
await notebooksPositron.addCodeToCell(3, '# Cell 3');
45-
await notebooksPositron.addCodeToCell(4, '# Cell 4');
46-
47-
// Verify we have 5 cells
36+
await notebooksPositron.newNotebook(5);
4837
await notebooksPositron.expectCellCountToBe(5);
4938
});
5039

test/e2e/tests/notebook/positron-notebook-editor.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ test.describe('Positron Notebooks: Open & Save', {
2929
});
3030
});
3131

32-
test.afterEach(async function ({ hotKeys }) {
32+
test.afterEach(async function ({ app, settings, hotKeys }) {
33+
await app.workbench.notebooksPositron.enableFeature(settings, {
34+
editor: 'default',
35+
});
3336
await hotKeys.closeAllEditors();
3437
});
3538

0 commit comments

Comments
 (0)