aboutsummaryrefslogtreecommitdiff
path: root/e2e
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-08-07 22:14:57 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-08-20 21:48:05 +0900
commit6f4812ee062d70246d5ad5b80bb12848f24f58f6 (patch)
tree3cb1a070e89be20897147cf0d6c8805d0b263b2a /e2e
parent1bc96ed1118c38b4b18035f8e05f2709b53b746b (diff)
Add e2e test to verify hot-reload of the settings
Diffstat (limited to 'e2e')
-rw-r--r--e2e/options.test.js49
1 files changed, 41 insertions, 8 deletions
diff --git a/e2e/options.test.js b/e2e/options.test.js
index d386b20..e8045c2 100644
--- a/e2e/options.test.js
+++ b/e2e/options.test.js
@@ -4,12 +4,27 @@ const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
+const newApp = () => {
+ let app = express();
+ app.get('/', (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body style="width:10000px; height:10000px"></body>
+</html">`);
+ });
+ return app;
+};
+
describe("options page", () => {
+ const port = 12321;
+ let http;
let firefox;
let session;
let browser;
before(async() => {
+ http = newApp().listen(port);
+
firefox = await lanthan.firefox({
spy: path.join(__dirname, '..'),
builderf: (builder) => {
@@ -26,6 +41,8 @@ describe("options page", () => {
if (firefox) {
await firefox.close();
}
+
+ http.close();
});
beforeEach(async() => {
@@ -35,17 +52,17 @@ describe("options page", () => {
}
})
+ const updateTextarea = async(value) => {
+ let textarea = await session.findElementByCSS('textarea');
+ await session.executeScript(`document.querySelector('textarea').value = '${value}'`)
+ await textarea.sendKeys(' ');
+ await session.executeScript(() => document.querySelector('textarea').blur());
+ }
+
it('saves current config on blur', async () => {
let url = await browser.runtime.getURL("build/settings.html")
await session.navigateTo(url);
- let textarea = await session.findElementByCSS('textarea');
- const updateTextarea = async(value) => {
- await session.executeScript(`document.querySelector('textarea').value = '${value}'`)
- await textarea.sendKeys(' ');
- await session.executeScript(() => document.querySelector('textarea').blur());
- }
-
await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`);
let { settings } = await browser.storage.local.get('settings');
@@ -62,5 +79,21 @@ describe("options page", () => {
let text = await error.getText();
assert.ok(text.startsWith('SyntaxError:'))
});
-});
+ it('updates keymaps without reloading', async () => {
+ await browser.tabs.create({ url: `http://127.0.0.1:${port}`, active: false });
+ let url = await browser.runtime.getURL("build/settings.html")
+ await session.navigateTo(url);
+
+ let handles = await session.getWindowHandles();
+ await updateTextarea(`{ "keymaps": { "zz": { "type": "scroll.vertically", "count": 10 } } }`);
+
+ await session.switchToWindow(handles[1]);
+
+ let body = await session.findElementByCSS('body');
+ await body.sendKeys('zz')
+
+ let y = await session.executeScript(() => window.pageYOffset);
+ assert.equal(y, 640);
+ })
+});