Skip to content

Commit aa4a635

Browse files
committed
switch to executeCode
1 parent 7681753 commit aa4a635

File tree

3 files changed

+22
-30
lines changed

3 files changed

+22
-30
lines changed

test/e2e/pages/quickInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class QuickInput {
4040
});
4141
}
4242

43-
async waitForQuickInputOpened({ timeout = 10000 }: { timeout?: number } = {}): Promise<void> {
43+
async waitForQuickInputOpened({ timeout = 3000 }: { timeout?: number } = {}): Promise<void> {
4444
await expect(this.code.driver.page.locator(QuickInput.QUICK_INPUT_INPUT)).toBeVisible({ timeout });
4545
}
4646

test/e2e/pages/quickaccess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class QuickAccess {
139139

140140
// Await for quick input widget opened
141141
try {
142-
await this.quickInput.waitForQuickInputOpened();
142+
await this.quickInput.waitForQuickInputOpened({ timeout: 3000 });
143143
} catch (err) {
144144
await this.code.driver.page.keyboard.press('Escape');
145145
throw err;

test/e2e/tests/reticulate/helpers/verifyReticulateFunction.ts

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { expect } from '@playwright/test';
76
import { Application } from '../../../infra/index.js';
7+
import { expect } from '../../_test.setup.js';
88

99
export const RETICULATE_SESSION = 'Python (reticulate)';
1010

@@ -18,50 +18,42 @@ export async function verifyReticulateFunctionality(
1818
const { console, sessions, variables } = app.workbench;
1919

2020
// Create a variable x in Python session
21-
await sessions.select(pythonSessionId, true);
22-
await runCodeExpectVariable(app, `x=${xValue}`, { name: 'x', value: xValue });
21+
await expect(async () => {
22+
await console.executeCode('Python', `x = ${xValue}`);
23+
await variables.expectVariableToBe('x', xValue, 2000);
24+
}, 'Can create variable in Python session').toPass();
2325

2426
// Switch to the R session and create an R variable `y` by accessing the Python
2527
// variable `x` through reticulate.
26-
await console.clearButton.click();
27-
await sessions.select(rSessionId);
28-
await runCodeExpectVariable(app, 'y<-reticulate::py$x', { name: 'y', value: xValue });
28+
await expect(async () => {
29+
await console.executeCode('R', 'y<-reticulate::py$x');
30+
await variables.expectVariableToBe('y', xValue, 2000);
31+
}, 'Can access Python variable x from R').toPass();
2932

3033
// Clear the console again and re-check to ensure the R-side variable persists.
3134
await console.clearButton.click();
3235
await variables.expectVariableToBe('y', xValue);
3336

3437
// Verify able to overwrite the R variable `y` with an integer literal on the R side.
35-
await runCodeExpectVariable(app, `y <- ${yValue}L`, { name: 'y', value: yValue });
38+
await expect(async () => {
39+
await console.executeCode('R', `y <- ${yValue}L`);
40+
await variables.expectVariableToBe('y', yValue, 2000);
41+
}, 'Can overwrite the R variable').toPass();
3642

3743
// Verify executing reticulate::repl_python() moves focus to the reticulate session
3844
await console.pasteCodeToConsole(`reticulate::repl_python(input = "z = ${zValue}")`, true);
3945
await sessions.expectSessionPickerToBe(pythonSessionId, 20000);
4046
await console.clearButton.click();
4147

4248
// Print the R variable r.y (should reflect the R-side value) and ensure it appears in the console
43-
await runCodeExpectOutput(app, 'print(r.y)', yValue);
44-
45-
// Print the Python variable z (created via repl_python) and ensure it appears as well
46-
await runCodeExpectOutput(app, 'print(z)', zValue);
47-
}
48-
49-
async function runCodeExpectVariable(app: Application, code: string, variable: { name: string; value: string } = { name: '', value: '' }) {
50-
const { console, variables } = app.workbench;
51-
5249
await expect(async () => {
53-
await console.sendInterrupt();
54-
await console.pasteCodeToConsole(code, true);
55-
await variables.expectVariableToBe(variable.name, variable.value, 2000);
56-
}, 'Run code and wait for variable to be present').toPass({ timeout: 10000 });
57-
}
58-
59-
async function runCodeExpectOutput(app: Application, commmand: string, value: string) {
60-
const { console } = app.workbench;
50+
await console.executeCode('Python', 'print(r.y)');
51+
await console.waitForConsoleContents(yValue, { timeout: 5000 });
52+
}, 'Can print the R variable r.y from Python').toPass();
6153

54+
// Print the Python variable z (created via repl_python) and ensure it appears as well
6255
await expect(async () => {
63-
await console.sendInterrupt();
64-
await console.pasteCodeToConsole(commmand, true);
65-
await console.waitForConsoleContents(value, { timeout: 2000 });
66-
}, 'Run code and expect console output').toPass({ timeout: 10000 });
56+
await console.executeCode('Python', 'print(z)');
57+
await console.waitForConsoleContents(zValue, { timeout: 5000 });
58+
}, 'Can print the Python variable z from Python').toPass();
6759
}

0 commit comments

Comments
 (0)