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: improve handling of open folder options #6331

Merged
merged 2 commits into from
Feb 13, 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
24 changes: 3 additions & 21 deletions test/e2e/pages/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/

import test, { expect, Locator } from '@playwright/test';
import { expect, Locator } from '@playwright/test';
import { Code } from '../infra/code';

const QUICK_INPUT_LIST = '.quick-input-widget .quick-input-list';
Expand All @@ -17,9 +17,11 @@ export class QuickInput {
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")';
quickInputList: Locator;
quickInput: Locator;

constructor(private code: Code) {
this.quickInputList = this.code.driver.page.locator(QUICK_INPUT_LIST);
this.quickInput = this.code.driver.page.locator(QuickInput.QUICK_INPUT_INPUT);
}

async waitForQuickInputOpened({ timeout = 10000 }: { timeout?: number } = {}): Promise<void> {
Expand Down Expand Up @@ -81,24 +83,4 @@ export class QuickInput {
async clickOkButton(): Promise<void> {
await this.code.driver.page.locator(QuickInput.QUICKINPUT_OK_BUTTON).click();
}

async arrowDownToSelectOption(option: string): Promise<void> {
await test.step(`Arrow down to select "${option}"`, async () => {
const page = this.code.driver.page;
for (let i = 0; i < 50; i++) {
const quickInputOption = page.getByRole('option', { name: option }).locator('a');

if (await quickInputOption.isVisible()) {
await quickInputOption.click();
// this is important as it guarantees the dropdown has refreshed
await expect(quickInputOption).not.toBeVisible();
return;
}

await page.keyboard.press('ArrowDown');
}

throw new Error(`Element with text "${option}" not found`);
});
}
}
5 changes: 4 additions & 1 deletion test/e2e/tests/_test.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
await playwright.expect(app.workbench.quickInput.quickInputList.getByLabel('..', { exact: true }).locator('a')).toBeVisible();

const folderNames = folderPath.split('/');

for (const folderName of folderNames) {
await app.workbench.quickInput.arrowDownToSelectOption(folderName);
await app.workbench.quickInput.quickInput.pressSequentially(folderName + '/');
const quickInputOption = app.code.driver.page.getByRole('option', { name: folderName }).locator('a');
await playwright.expect(quickInputOption).not.toBeVisible();
}

await app.workbench.quickInput.clickOkButton();
Expand Down