diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-08-16 17:57:54 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-09-21 12:48:18 +0900 |
commit | d53f010cc92f1fcb9580ca770766790e783e28a5 (patch) | |
tree | 27889a378915e99b55dd917dc00265b282e7fe67 /e2e | |
parent | 264d69c933370b3321dfcd83d823222e730e3fe0 (diff) |
Fix Completion.test
Diffstat (limited to 'e2e')
-rw-r--r-- | e2e/lib/Console.ts | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts index 2c128d1..2d397c6 100644 --- a/e2e/lib/Console.ts +++ b/e2e/lib/Console.ts @@ -1,7 +1,11 @@ import { WebDriver, By, Key } from "selenium-webdriver"; +export type CompletionGroups = { + name: string; + items: Array<CompletionItem>; +}; + export type CompletionItem = { - type: string; text: string; highlight: boolean; }; @@ -25,9 +29,7 @@ export class Console { } async execCommand(command: string): Promise<void> { - const input = await this.webdriver.findElement( - By.css("input.vimvixen-console-command-input") - ); + const input = await this.webdriver.findElement(By.css("input")); await input.sendKeys(command, Key.ENTER); } @@ -52,27 +54,20 @@ export class Console { getCompletions(): Promise<CompletionItem[]> { return this.webdriver.executeScript(() => { - const items = document.querySelectorAll( - ".vimvixen-console-completion > li" - ); - if (items.length === 0) { + const groups = document.querySelectorAll("[role=group]"); + if (groups.length === 0) { throw new Error("completion items not found"); } - const objs = []; - for (const li of Array.from(items)) { - if (li.classList.contains("vimvixen-console-completion-title")) { - objs.push({ type: "title", text: li.textContent!.trim() }); - } else if (li.classList.contains("vimvixen-console-completion-item")) { - const highlight = li.classList.contains( - "vimvixen-completion-selected" - ); - objs.push({ type: "item", text: li.textContent!.trim(), highlight }); - } else { - throw new Error(`unexpected class: ${li.className}`); - } - } - return objs; + return Array.from(groups).map((group) => ({ + name: group.textContent!.trim(), + items: Array.from(group.querySelectorAll("[role=menuitem]")).map( + (item) => ({ + text: item.textContent!.trim(), + highlight: item.getAttribute("aria-selected") === "true", + }) + ), + })); }); } |