From 1f0ee8ced809a2c3417d3f8f6b532e614b5fa0f3 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Wed, 18 Dec 2024 08:49:43 -0600 Subject: [PATCH] quickInput improvements --- .../src/positron/positronQuickInput.ts | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/test/automation/src/positron/positronQuickInput.ts b/test/automation/src/positron/positronQuickInput.ts index c5046cd1ca2..7407bfdaa78 100644 --- a/test/automation/src/positron/positronQuickInput.ts +++ b/test/automation/src/positron/positronQuickInput.ts @@ -10,10 +10,9 @@ 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 .label-name .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 = `${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) { } @@ -26,21 +25,17 @@ export class PositronQuickInput { await this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_INPUT).fill(value); } - // async waitForQuickInputElementFocused(): Promise { - // await expect(this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_FOCUSED_ELEMENT)).not.toHaveText(''); - // } - async waitForQuickInputElementText(): Promise { - const quickInput = this.code.driver.page.locator(PositronQuickInput.QUICK_INPUT_FOCUSED_ELEMENT); + 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 quickInput.allTextContents(); + const texts = await quickInputResult.allTextContents(); return texts.some(text => text.trim() !== ''); }).toPass(); // Retrieve the text content of the first matching element - const text = await quickInput.first().textContent(); + const text = await quickInputResult.first().textContent(); return text?.trim() || ''; } @@ -65,11 +60,7 @@ export class PositronQuickInput { async selectQuickInputElement(index: number, keepOpen?: boolean): Promise { 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(); @@ -77,7 +68,7 @@ export class PositronQuickInput { } async selectQuickInputElementContaining(text: string): Promise { - 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 {