Skip to content

Commit

Permalink
Smoke test: reticulate (#5419)
Browse files Browse the repository at this point in the history
Basic reticulate test.
* Creates a python repl from R
* Waits for python to be ready
* Sets x = 100
* Goes back to R console
* Sets R variable y equal to the python variable x
* Checks value and type of y

### QA Notes

All smoke tests should pass
  • Loading branch information
testlabauto authored Nov 20, 2024
1 parent 3a75032 commit e168eb2
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions test/smoke/src/areas/positron/reticulate/reticulate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------------------------
* Copyright (C) 2024 Posit Software, PBC. All rights reserved.
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/

import { expect } from '@playwright/test';
import { Application, PositronRFixtures, PositronUserSettingsFixtures, UserSetting } from '../../../../../automation';
import { setupAndStartApp } from '../../../test-runner/test-hooks';

// In order to run this test on Windows, I think we need to set the env var:
// RETICULATE_PYTHON
// to the installed python path
describe('Reticulate #web', () => {
setupAndStartApp();
let app: Application;
let userSettings: PositronUserSettingsFixtures;

describe('Reticulate', () => {
before(async function () {
app = this.app as Application;

try {

await PositronRFixtures.SetupFixtures(this.app as Application);

userSettings = new PositronUserSettingsFixtures(app);

// remove this once https://github.com/posit-dev/positron/issues/5226
// is resolved
const kernelSupervisorSetting: UserSetting = ['positronKernelSupervisor.enable', 'false'];
const reticulateSetting: UserSetting = ['positron.reticulate.enabled', 'true'];

await userSettings.setUserSettings([
kernelSupervisorSetting,
reticulateSetting
]
);

} catch (e) {
this.app.code.driver.takeScreenshot('reticulateSetup');
throw e;
}
});

after(async function () {
await userSettings.unsetUserSettings();

});

it('R - Verify Basic Reticulate Functionality [C...]', async function () {

await app.workbench.positronConsole.pasteCodeToConsole('reticulate::repl_python()');
await app.workbench.positronConsole.sendEnterKey();

try {
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Yes/no/cancel')));
await app.workbench.positronConsole.typeToConsole('no');
await app.workbench.positronConsole.sendEnterKey();

} catch {
// Prompt did not appear
}

await app.workbench.positronConsole.waitForReady('>>>');

await app.workbench.positronConsole.pasteCodeToConsole('x=100');
await app.workbench.positronConsole.sendEnterKey();

await PositronRFixtures.SetupFixtures(this.app as Application);

await app.workbench.positronConsole.pasteCodeToConsole('y<-reticulate::py$x');
await app.workbench.positronConsole.sendEnterKey();

await app.workbench.positronLayouts.enterLayout('fullSizedAuxBar');

await expect(async () => {
const variablesMap = await app.workbench.positronVariables.getFlatVariables();
expect(variablesMap.get('y')).toStrictEqual({ value: '100', type: 'int' });
}).toPass({ timeout: 60000 });

});
});
});

0 comments on commit e168eb2

Please sign in to comment.