aboutsummaryrefslogtreecommitdiff
path: root/e2e
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-04 17:50:42 +0900
committerGitHub <noreply@github.com>2020-05-04 17:50:42 +0900
commit69b6894b1997a773678709a7cd591afddc15c8ce (patch)
tree07e4c665829236e733316ae6f2684fe03b0a6781 /e2e
parent49addd75b76f185c9dad5d74e44e39cbea360510 (diff)
parent44ff8e449dba0de32500da3c3f17fc1361449717 (diff)
Merge pull request #751 from ueokande/dark-mode
Supports dark mode
Diffstat (limited to 'e2e')
-rw-r--r--e2e/colorscheme.test.ts60
-rw-r--r--e2e/completion_set.test.ts3
-rw-r--r--e2e/lib/Console.ts6
3 files changed, 68 insertions, 1 deletions
diff --git a/e2e/colorscheme.test.ts b/e2e/colorscheme.test.ts
new file mode 100644
index 0000000..3927a72
--- /dev/null
+++ b/e2e/colorscheme.test.ts
@@ -0,0 +1,60 @@
+import * as path from "path";
+import * as assert from "assert";
+
+import TestServer from "./lib/TestServer";
+import { Builder, Lanthan } from "lanthan";
+import { WebDriver } from "selenium-webdriver";
+import { Options as FirefoxOptions } from "selenium-webdriver/firefox";
+import Page from "./lib/Page";
+
+describe("colorscheme test", () => {
+ const server = new TestServer();
+ let lanthan: Lanthan;
+ let webdriver: WebDriver;
+ let page: Page;
+
+ before(async () => {
+ const opts = (new FirefoxOptions() as any).setPreference(
+ "ui.systemUsesDarkTheme",
+ 1
+ );
+
+ lanthan = await Builder.forBrowser("firefox")
+ .setOptions(opts)
+ .spyAddon(path.join(__dirname, ".."))
+ .build();
+ webdriver = lanthan.getWebDriver();
+
+ await server.start();
+ });
+
+ after(async () => {
+ await server.stop();
+ if (lanthan) {
+ await lanthan.quit();
+ }
+ });
+
+ beforeEach(async () => {
+ page = await Page.navigateTo(webdriver, server.url());
+ });
+
+ it("changes color scheme by set command", async () => {
+ let console = await page.showConsole();
+
+ await console.execCommand("set colorscheme=dark");
+ await (webdriver.switchTo() as any).parentFrame();
+ console = await page.showConsole();
+ assert.strictEqual(await console.getTheme(), "dark");
+
+ await console.execCommand("set colorscheme=light");
+ await (webdriver.switchTo() as any).parentFrame();
+ console = await page.showConsole();
+ assert.strictEqual(await console.getTheme(), "light");
+
+ await console.execCommand("set colorscheme=system");
+ await (webdriver.switchTo() as any).parentFrame();
+ console = await page.showConsole();
+ assert.strictEqual(await console.getTheme(), "dark");
+ });
+});
diff --git a/e2e/completion_set.test.ts b/e2e/completion_set.test.ts
index 3a139fe..0a45ed3 100644
--- a/e2e/completion_set.test.ts
+++ b/e2e/completion_set.test.ts
@@ -34,12 +34,13 @@ describe("completion on set commands", () => {
await eventually(async () => {
const items = await console.getCompletions();
- assert.strictEqual(items.length, 5);
+ assert.strictEqual(items.length, 6);
assert.deepStrictEqual(items[0], { type: "title", text: "Properties" });
assert.ok(items[1].text.startsWith("hintchars"));
assert.ok(items[2].text.startsWith("smoothscroll"));
assert.ok(items[3].text.startsWith("nosmoothscroll"));
assert.ok(items[4].text.startsWith("complete"));
+ assert.ok(items[5].text.startsWith("colorscheme"));
});
});
diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts
index 68c0e10..0bae2f7 100644
--- a/e2e/lib/Console.ts
+++ b/e2e/lib/Console.ts
@@ -76,6 +76,12 @@ export class Console {
});
}
+ async getTheme(): Promise<string> {
+ const wrapper = await this.webdriver.findElement(By.css("div[data-theme]"));
+ const theme = await wrapper.getAttribute("data-theme");
+ return theme;
+ }
+
async close(): Promise<void> {
const input = await this.webdriver.findElement(By.css("input"));
await input.sendKeys(Key.ESCAPE);