From e168eb22c2558c4060867809038bef3dc443ffb9 Mon Sep 17 00:00:00 2001 From: Christopher Mead Date: Wed, 20 Nov 2024 09:40:56 -0700 Subject: [PATCH] Smoke test: reticulate (#5419) 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 --- .../positron/reticulate/reticulate.test.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test/smoke/src/areas/positron/reticulate/reticulate.test.ts diff --git a/test/smoke/src/areas/positron/reticulate/reticulate.test.ts b/test/smoke/src/areas/positron/reticulate/reticulate.test.ts new file mode 100644 index 00000000000..b5818ca4ee4 --- /dev/null +++ b/test/smoke/src/areas/positron/reticulate/reticulate.test.ts @@ -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 }); + + }); + }); +});