From 8bfa19885bc84e5b75009b24050be8304d52d3b2 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 21 Sep 2020 11:15:53 +0900 Subject: Fix e2e tests --- e2e/lib/Console.ts | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'e2e/lib') diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts index 2d397c6..4d017cc 100644 --- a/e2e/lib/Console.ts +++ b/e2e/lib/Console.ts @@ -1,7 +1,7 @@ import { WebDriver, By, Key } from "selenium-webdriver"; export type CompletionGroups = { - name: string; + title: string; items: Array; }; @@ -34,16 +34,12 @@ export class Console { } async getErrorMessage(): Promise { - const p = await this.webdriver.findElement( - By.css(".vimvixen-console-error") - ); + const p = await this.webdriver.findElement(By.css("[role=alert]")); return p.getText(); } async getInformationMessage(): Promise { - const p = await this.webdriver.findElement( - By.css(".vimvixen-console-info") - ); + const p = await this.webdriver.findElement(By.css("[role=status]")); return p.getText(); } @@ -52,29 +48,42 @@ export class Console { await input.sendKeys(...keys); } - getCompletions(): Promise { + getCompletions(): Promise { return this.webdriver.executeScript(() => { const groups = document.querySelectorAll("[role=group]"); if (groups.length === 0) { throw new Error("completion items not found"); } - return Array.from(groups).map((group) => ({ - name: group.textContent!.trim(), - items: Array.from(group.querySelectorAll("[role=menuitem]")).map( - (item) => ({ - text: item.textContent!.trim(), + return Array.from(groups).map((group) => { + const describedby = group.getAttribute("aria-describedby") as string; + const title = document.getElementById(describedby)!; + const items = group.querySelectorAll("[role=menuitem]"); + + return { + title: title.textContent!.trim(), + items: Array.from(items).map((item) => ({ + text: document.getElementById( + item.getAttribute("aria-labelledby")! + )!.textContent, highlight: item.getAttribute("aria-selected") === "true", - }) - ), - })); + })), + }; + }); }); } async getTheme(): Promise { - const wrapper = await this.webdriver.findElement(By.css("div[data-theme]")); - const theme = await wrapper.getAttribute("data-theme"); - return theme; + const color = (await this.webdriver.executeScript(() => { + const input = document.querySelector("input")!; + return window.getComputedStyle(input).backgroundColor; + })) as string; + if (color === "rgb(5, 32, 39)") { + return "dark"; + } else if (color === "rgb(255, 255, 255)") { + return "light"; + } + throw new Error(`unknown input color: ${color}`); } async close(): Promise { -- cgit v1.2.3