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: new project wizard updates #5908

Merged
merged 21 commits into from
Jan 9, 2025
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"update-grammars": "node build/npm/update-all-grammars.mjs",
"update-localization-extension": "node build/npm/update-localization-extension.js",
"e2e": "npm run e2e-electron",
"e2e-watch": "npm run --prefix test/e2e watch",
"e2e-electron": "npx playwright test --project e2e-electron",
"e2e-browser": "npx playwright test --project e2e-browser",
"e2e-pr": "npx playwright test --project e2e-electron --grep @critical",
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ export * from './fixtures/python';
export * from './fixtures/r';
export * from './fixtures/userSettings';

// test-runner
export * from './test-runner';

export { getDevElectronPath, getBuildElectronPath, getBuildVersion } from './electron';
8 changes: 6 additions & 2 deletions test/e2e/pages/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ export class Console {
contents.forEach(line => this.code.logger.log(line));
}

async typeToConsole(text: string, delay = 30) {
async typeToConsole(text: string, delay = 30, pressEnter = false) {
await this.code.driver.page.waitForTimeout(500);
await this.activeConsole.click();
await this.code.driver.page.keyboard.type(text, { delay });

if (pressEnter) {
await this.code.driver.page.keyboard.press('Enter');
}
}

async sendEnterKey() {
Expand All @@ -134,7 +138,7 @@ export class Console {
const page = this.code.driver.page;

// ensure interpreter(s) containing starting/discovering do not exist in DOM
await expect(page.locator('text=/^Starting up|^Starting|^Discovering( \\w+)? interpreters|starting\\.$/i')).toHaveCount(0, { timeout: 30000 });
await expect(page.locator('text=/^Starting up|^Starting|^Discovering( \\w+)? interpreters|starting\\.$/i')).toHaveCount(0, { timeout: 50000 });

// ensure we are on Console tab
await page.getByRole('tab', { name: 'Console', exact: true }).locator('a').click();
Expand Down
24 changes: 6 additions & 18 deletions test/e2e/pages/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { expect, Locator } from '@playwright/test';
import { Code } from '../infra/code';

const POSITRON_EXPLORER_PROJECT_TITLE = 'div[id="workbench.view.explorer"] h3.title';
const POSITRON_EXPLORER_PROJECT_FILES = 'div[id="workbench.view.explorer"] span[class="monaco-highlighted-label"]';


/*
Expand All @@ -20,23 +19,12 @@ export class Explorer {

constructor(protected code: Code) { }

/**
* Constructs a string array of the top-level project files/directories in the explorer.
* @param locator - The locator for the project files/directories in the explorer.
* @returns Promise<string[]> Array of strings representing the top-level project files/directories in the explorer.
*/
async getExplorerProjectFiles(locator: string = POSITRON_EXPLORER_PROJECT_FILES): Promise<string[]> {
const explorerProjectFiles = this.code.driver.page.locator(locator);
const filesList = await explorerProjectFiles.all();
const fileNames = filesList.map(async file => {
const fileText = await file.textContent();
return fileText || '';
});
return await Promise.all(fileNames);
}
async verifyProjectFilesExist(files: string[]) {
const projectFiles = this.code.driver.page.locator('.monaco-list > .monaco-scrollable-element');

async waitForProjectFileToAppear(filename: string) {
const escapedFilename = filename.replace(/\./g, '\\.').toLowerCase();
await expect(this.code.driver.page.locator(`.${escapedFilename}-name-file-icon`)).toBeVisible({ timeout: 30000 });
for (let i = 0; i < files.length; i++) {
const timeout = i === 0 ? 50000 : undefined; // 50s for the first check, default for the rest as sometimes waiting for project to load
await expect(projectFiles.getByLabel(files[i], { exact: true }).locator('a')).toBeVisible({ timeout });
}
}
}
Loading
Loading