Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e-test: replace with PositronQuickAccess #5789

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineConfig<CustomTestOptions>({
},
reporter: process.env.CI
? [
// eslint-disable-next-line local/code-no-dangerous-type-assertions
['@midleman/github-actions-reporter', <GitHubActionOptions>{
title: '',
useDetails: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PositronUserSettingsFixtures {
]);

// Close the settings editor
await this.app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await this.app.workbench.positronQuickaccess.runCommand('workbench.action.closeActiveEditor');

// Restart the application if requested, to apply the settings
if (restartApp) {
Expand Down
5 changes: 2 additions & 3 deletions test/automation/src/positron/positronConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/


import { expect, Locator } from '@playwright/test';
import { Code } from '../code';
import { QuickAccess } from '../quickaccess';
import { PositronQuickAccess } from './positronQuickaccess';

const CONNECTIONS_CONTAINER = '.connections-items-container';
const CONNECTIONS_ITEM = '.connections-item';
Expand All @@ -22,7 +21,7 @@ export class PositronConnections {
connectionItems: Locator;
resumeConnectionButton: Locator;

constructor(private code: Code, private quickaccess: QuickAccess) {
constructor(private code: Code, private quickaccess: PositronQuickAccess) {
this.deleteConnectionButton = code.driver.page.getByLabel('Delete Connection');
this.disconnectButton = code.driver.page.getByLabel('Disconnect');
this.connectIcon = code.driver.page.locator('.codicon-arrow-circle-right');
Expand Down
6 changes: 3 additions & 3 deletions test/automation/src/positron/positronConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import { expect, Locator } from '@playwright/test';
import { Code } from '../code';
import { QuickAccess } from '../quickaccess';
import { QuickInput } from '../quickinput';
import { PositronQuickAccess } from './positronQuickaccess';
import { PositronQuickInput } from './positronQuickInput';
import { InterpreterInfo, InterpreterType } from './utils/positronInterpreterInfo';
import { IElement } from '../driver';

Expand Down Expand Up @@ -37,7 +37,7 @@ export class PositronConsole {
return this.code.driver.getLocator(EMPTY_CONSOLE).getByText('There is no interpreter running');
}

constructor(private code: Code, private quickaccess: QuickAccess, private quickinput: QuickInput) {
constructor(private code: Code, private quickaccess: PositronQuickAccess, private quickinput: PositronQuickInput) {
this.barPowerButton = this.code.driver.page.getByLabel('Shutdown console');
this.barRestartButton = this.code.driver.page.getByLabel('Restart console');
this.barClearButton = this.code.driver.page.getByLabel('Clear console');
Expand Down
6 changes: 3 additions & 3 deletions test/automation/src/positron/positronNewProjectWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { fail } from 'assert';
import { expect } from '@playwright/test';
import { Code } from '../code';
import { QuickAccess } from '../quickaccess';
import { PositronQuickAccess } from './positronQuickaccess';

// Selector for the pre-selected dropdown item in the project wizard
const PROJECT_WIZARD_PRESELECTED_DROPDOWN_ITEM =
Expand Down Expand Up @@ -53,7 +53,7 @@ export class PositronNewProjectWizard {
private nextButton = this.code.driver.getLocator(PROJECT_WIZARD_DEFAULT_BUTTON).getByText('Next');
private createButton = this.code.driver.getLocator(PROJECT_WIZARD_DEFAULT_BUTTON).getByText('Create');

constructor(private code: Code, private quickaccess: QuickAccess) {
constructor(private code: Code, private quickaccess: PositronQuickAccess) {
this.projectTypeStep = new ProjectWizardProjectTypeStep(this.code);
this.projectNameLocationStep = new ProjectWizardProjectNameLocationStep(this.code);
this.rConfigurationStep = new ProjectWizardRConfigurationStep(this.code);
Expand Down Expand Up @@ -115,7 +115,7 @@ class ProjectWizardProjectTypeStep {
}

async selectProjectType(projectType: ProjectType) {
const locator = this.code.driver.page.locator('label').filter({hasText: projectType});
const locator = this.code.driver.page.locator('label').filter({ hasText: projectType });
await locator.click({ force: true });
}
}
Expand Down
7 changes: 4 additions & 3 deletions test/automation/src/positron/positronNotebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

import { Code } from '../code';
import { Notebook } from '../notebook';
import { QuickAccess } from '../quickaccess';
import { QuickInput } from '../quickinput';
import { PositronQuickInput } from './positronQuickInput';
import { PositronQuickAccess } from './positronQuickaccess';
import { basename } from 'path';
import { expect } from '@playwright/test';


const KERNEL_LABEL = '.kernel-label';
const KERNEL_ACTION = '.kernel-action-view-item';
const SELECT_KERNEL_TEXT = 'Select Kernel';
Expand All @@ -34,7 +35,7 @@ export class PositronNotebooks {
notebookProgressBar = this.code.driver.page.locator('[id="workbench\\.parts\\.editor"]').getByRole('progressbar');


constructor(private code: Code, private quickinput: QuickInput, private quickaccess: QuickAccess, private notebook: Notebook) { }
constructor(private code: Code, private quickinput: PositronQuickInput, private quickaccess: PositronQuickAccess, private notebook: Notebook) { }

async selectInterpreter(kernelGroup: string, desiredKernel: string) {
await expect(this.notebookProgressBar).not.toBeVisible({ timeout: 30000 });
Expand Down
4 changes: 2 additions & 2 deletions test/automation/src/positron/positronOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { fail } from 'assert';
import { Code } from '../code';
import { QuickAccess } from '../quickaccess';
import { PositronQuickAccess } from './positronQuickaccess';

const HORIZONTAL_SASH = '.explorer-viewlet .monaco-sash.horizontal';
const FOCUS_OUTLINE_COMMAND = 'outline.focus';
Expand All @@ -17,7 +17,7 @@ const OUTLINE_ELEMENT = '.outline-element';
*/
export class PositronOutline {

constructor(private code: Code, private quickaccess: QuickAccess) { }
constructor(private code: Code, private quickaccess: PositronQuickAccess) { }

async getOutlineData(): Promise<string[]> {

Expand Down
6 changes: 3 additions & 3 deletions test/automation/src/positron/positronOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


import { Code } from '../code';
import { QuickAccess } from '../quickaccess';
import { QuickInput } from '../quickinput';
import { PositronQuickAccess } from './positronQuickaccess';
import { PositronQuickInput } from './positronQuickInput';

const OUTPUT_LINE = '.view-line';

Expand All @@ -15,7 +15,7 @@ const OUTPUT_LINE = '.view-line';
*/
export class PositronOutput {

constructor(private code: Code, private quickaccess: QuickAccess, private quickinput: QuickInput) { }
constructor(private code: Code, private quickaccess: PositronQuickAccess, private quickinput: PositronQuickInput) { }

async openOutputPane(outputPaneNameContains: string) {
await this.quickaccess.runCommand('workbench.action.showOutputChannels', { keepOpen: true });
Expand Down
37 changes: 19 additions & 18 deletions test/automation/src/positron/positronQuickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@ export class PositronQuickInput {

private static QUICK_INPUT = '.quick-input-widget';
private static QUICK_INPUT_INPUT = `${PositronQuickInput.QUICK_INPUT} .quick-input-box input`;
private static QUICK_INPUT_ROW = `${PositronQuickInput.QUICK_INPUT} .quick-input-list .monaco-list-row`;
private static QUICK_INPUT_FOCUSED_ELEMENT = `${PositronQuickInput.QUICK_INPUT_ROW}.focused .monaco-highlighted-label`;
private static QUICK_INPUT_RESULT = `${PositronQuickInput.QUICK_INPUT} .quick-input-list .monaco-list-row`;
// Note: this only grabs the label and not the description or detail
private static QUICK_INPUT_ENTRY_LABEL = `${this.QUICK_INPUT_ROW} .quick-input-list-row > .monaco-icon-label .label-name`;
private static QUICK_INPUT_ENTRY_LABEL_SPAN = `${this.QUICK_INPUT_ROW} .monaco-highlighted-label`;
private static QUICK_INPUT_ENTRY_LABEL = `${this.QUICK_INPUT_RESULT} .quick-input-list-row > .monaco-icon-label .label-name`;
private static QUICKINPUT_OK_BUTTON = '.quick-input-widget .quick-input-action a:has-text("OK")';

constructor(private code: Code) { }

async waitForQuickInputOpened(): Promise<void> {
await expect(this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_INPUT)).toBeVisible();
async waitForQuickInputOpened({ timeout = 10000 }: { timeout?: number } = {}): Promise<void> {
await expect(this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_INPUT)).toBeVisible({ timeout });
}

async type(value: string): Promise<void> {
await this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_INPUT).fill(value);
}

async waitForQuickInputElementFocused(): Promise<void> {
await expect(this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_FOCUSED_ELEMENT)).toBeFocused();
}

async waitForQuickInputElementText(): Promise<string> {
const quickInput = this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_ENTRY_LABEL_SPAN);
await expect(quickInput).not.toHaveText('');
return await quickInput.textContent() || '';
const quickInputResult = this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_RESULT);

// Wait for at least one matching element with non-empty text
await expect(async () => {
const texts = await quickInputResult.allTextContents();
return texts.some(text => text.trim() !== '');
}).toPass();

// Retrieve the text content of the first matching element
const text = await quickInputResult.first().textContent();
return text?.trim() || '';

}

async closeQuickInput(): Promise<void> {
Expand All @@ -57,17 +60,15 @@ export class PositronQuickInput {

async selectQuickInputElement(index: number, keepOpen?: boolean): Promise<void> {
await this.waitForQuickInputOpened();
for (let from = 0; from < index; from++) {
await this.code.driver.page.keyboard.press('Down');
}
await this.code.driver.page.keyboard.press('Enter');
await this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_RESULT).nth(index).click();

if (!keepOpen) {
await this.waitForQuickInputClosed();
}
}

async selectQuickInputElementContaining(text: string): Promise<void> {
await this.code.driver.page.locator(`${PositronQuickInput.QUICK_INPUT_ROW}[aria-label*="${text}"]`).first().click({ timeout: 10000 });
await this.code.driver.page.locator(`${PositronQuickInput.QUICK_INPUT_RESULT}[aria-label*="${text}"]`).first().click({ timeout: 10000 });
}

async clickOkOnQuickInput(): Promise<void> {
Expand Down
Loading
Loading