Skip to content

Commit

Permalink
quickInput improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
midleman committed Dec 18, 2024
1 parent 627c84a commit 1f0ee8c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions test/automation/src/positron/positronQuickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -26,21 +25,17 @@ export class PositronQuickInput {
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)).not.toHaveText('');
// }

async waitForQuickInputElementText(): Promise<string> {
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() || '';

}
Expand All @@ -65,19 +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

0 comments on commit 1f0ee8c

Please sign in to comment.