Skip to content

Commit

Permalink
E2E tests: various missed MS dependencies (#5868)
Browse files Browse the repository at this point in the history
Cleanup of various tests/POMs where MS dependencies were still present.

### QA Notes

All tests pass.
  • Loading branch information
testlabauto authored Jan 2, 2025
1 parent 88fbe17 commit 4c10da4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { fail } from 'assert';
import { Application } from '../../application';
import { InterpreterInfo, InterpreterType } from '../utils/positronInterpreterInfo';
import { InterpreterType } from '../utils/positronInterpreterInfo';
import { expect } from '@playwright/test';

/*
Expand Down Expand Up @@ -37,12 +37,12 @@ export class PositronPythonFixtures {
await this.app.workbench.positronConsole.logConsoleContents();
}

async startAndGetPythonInterpreter(installIPyKernelIfPrompted: boolean = false): Promise<InterpreterInfo | undefined> {
async startAndGetPythonInterpreter(installIPyKernelIfPrompted: boolean = false): Promise<void> {
const desiredPython = process.env.POSITRON_PY_VER_SEL;
if (desiredPython === undefined) {
fail('Please be sure to set env var POSITRON_PY_VER_SEL to the UI text corresponding to the Python version for the test');
}
const interpreterInfo = await this.app.workbench.positronConsole.selectAndGetInterpreter(InterpreterType.Python, desiredPython);
await this.app.workbench.positronConsole.selectInterpreter(InterpreterType.Python, desiredPython);

if (
installIPyKernelIfPrompted &&
Expand All @@ -53,8 +53,6 @@ export class PositronPythonFixtures {

await expect(this.app.workbench.positronConsole.activeConsole.getByText('>>>')).toBeVisible({ timeout: 30000 });
await this.app.workbench.positronConsole.logConsoleContents();

return interpreterInfo;
}

}
30 changes: 2 additions & 28 deletions test/automation/src/positron/positronConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { expect, Locator } from '@playwright/test';
import { Code } from '../code';
import { PositronQuickAccess } from './positronQuickaccess';
import { PositronQuickInput } from './positronQuickInput';
import { InterpreterInfo, InterpreterType } from './utils/positronInterpreterInfo';
import { IElement } from '../driver';
import { InterpreterType } from './utils/positronInterpreterInfo';

const CONSOLE_INPUT = '.console-input';
const ACTIVE_CONSOLE_INSTANCE = '.console-instance[style*="z-index: auto"]';
Expand Down Expand Up @@ -46,7 +45,7 @@ export class PositronConsole {
this.suggestionList = this.code.driver.page.locator(SUGGESTION_LIST);
}

async selectInterpreter(desiredInterpreterType: InterpreterType, desiredInterpreterString: string, skipWait: boolean = false): Promise<IElement | undefined> {
async selectInterpreter(desiredInterpreterType: InterpreterType, desiredInterpreterString: string, skipWait: boolean = false): Promise<undefined> {

// don't try to start a new interpreter if one is currently starting up
if (!skipWait) {
Expand Down Expand Up @@ -74,31 +73,6 @@ export class PositronConsole {
return;
}

async selectAndGetInterpreter(
desiredInterpreterType: InterpreterType,
desiredInterpreter: string
): Promise<InterpreterInfo | undefined> {
const interpreterElem = await this.selectInterpreter(
desiredInterpreterType,
desiredInterpreter,
true
);

if (interpreterElem) {
// The aria-label looks something like: Python 3.10.4 64-bit ('3.10.4'), ~/.pyenv/versions/3.10.4/bin/python, Pyenv
const rawInfo = interpreterElem.attributes['aria-label'].split(',');
const hasSource = rawInfo.length > 2;
return {
type: desiredInterpreterType, // e.g. InterpreterType.Python
version: rawInfo[0].trim(), // e.g. Python 3.10.4 64-bit ('3.10.4')
path: rawInfo[1].trim(), // e.g. ~/.pyenv/versions/3.10.4/bin/python
source: hasSource ? rawInfo[2].trim() : '', // e.g. Pyenv
} satisfies InterpreterInfo;
}

return undefined;
}

async executeCode(languageName: string, code: string, prompt: string): Promise<void> {

await expect(async () => {
Expand Down
10 changes: 5 additions & 5 deletions test/automation/src/positron/positronDataExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ export class PositronDataExplorer {

async maximizeDataExplorer(collapseSummary: boolean = false): Promise<void> {
await this.workbench.positronLayouts.enterLayout('stacked');
await this.workbench.quickaccess.runCommand('workbench.action.toggleSidebarVisibility');
await this.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await this.workbench.quickaccess.runCommand('workbench.action.togglePanel');
await this.workbench.positronQuickaccess.runCommand('workbench.action.toggleSidebarVisibility');
await this.workbench.positronQuickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await this.workbench.positronQuickaccess.runCommand('workbench.action.togglePanel');

if (collapseSummary) {
await this.collapseSummary();
}
}

async collapseSummary(): Promise<void> {
await this.workbench.quickaccess.runCommand('workbench.action.positronDataExplorer.collapseSummary');
await this.workbench.positronQuickaccess.runCommand('workbench.action.positronDataExplorer.collapseSummary');
}

async expandSummary(): Promise<void> {
await this.workbench.quickaccess.runCommand('workbench.action.positronDataExplorer.expandSummary');
await this.workbench.positronQuickaccess.runCommand('workbench.action.positronDataExplorer.expandSummary');
}
}
2 changes: 1 addition & 1 deletion test/automation/src/positron/positronLayouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class PositronLayouts {
* @param layout Known layout to enter.
*/
async enterLayout(layout: keyof typeof positronLayoutPresets): Promise<void> {
await this.workbench.quickaccess.runCommand(positronLayoutPresets[layout], { keepOpen: true });
await this.workbench.positronQuickaccess.runCommand(positronLayoutPresets[layout], { keepOpen: true });
}

/**
Expand Down
13 changes: 6 additions & 7 deletions test/automation/src/positron/positronPopups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ export class PositronPopups {
try {
this.code.logger.log('Checking for install Renv modal dialog box');
// fail fast if the renv install modal is not present
await this.code.waitForTextContent(
POSITRON_MODAL_DIALOG_BOX_TITLE,
'Missing R package',
undefined,
50
);
await this.waitForModalDialogTitle('Missing R package');

if (install) {
this.code.logger.log('Installing Renv');
await this.code.driver.page.locator(POSITRON_MODAL_DIALOG_BOX_OK).click();
Expand Down Expand Up @@ -146,6 +142,9 @@ export class PositronPopups {
* @param title The title to wait for.
*/
async waitForModalDialogTitle(title: string) {
await this.code.waitForTextContent(POSITRON_MODAL_DIALOG_BOX_TITLE, title);
await expect(async () => {
const textContent = await this.code.driver.page.locator(POSITRON_MODAL_DIALOG_BOX_TITLE).textContent();
expect(textContent).toContain(title);
}).toPass({ timeout: 30000 });
}
}
2 changes: 1 addition & 1 deletion test/e2e/areas/top-action-bar/top-action-bar-save.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe('Top Action Bar - Save Actions', {
await app.workbench.positronQuickaccess.openFile(join(app.workspacePathOrFolder, fileName));
await app.workbench.positronQuickaccess.runCommand('workbench.action.keepEditor', { keepOpen: false });
await app.workbench.positronEditors.selectTab(fileName);
await app.workbench.editor.waitForTypeInEditor(fileName, 'Puppies frolicking in a meadow of wildflowers');
await app.workbench.positronEditor.waitForTypeInEditor(fileName, 'Puppies frolicking in a meadow of wildflowers');
// The file is now "dirty" and the save buttons should be enabled
await app.workbench.positronEditors.waitForTab(fileName, true);
await expect(async () => {
Expand Down

0 comments on commit 4c10da4

Please sign in to comment.