Add e2e test to verify hot-reload of the settings
This commit is contained in:
parent
1bc96ed111
commit
6f4812ee06
2 changed files with 41 additions and 34 deletions
26
QA.md
26
QA.md
|
@ -25,32 +25,6 @@ The behaviors of the console are tested in [Console section](#consoles).
|
||||||
|
|
||||||
### Settings
|
### Settings
|
||||||
|
|
||||||
#### JSON Settings
|
|
||||||
|
|
||||||
##### Validations
|
|
||||||
|
|
||||||
- [ ] show error on invalid json
|
|
||||||
- [ ] show error when top-level keys has keys other than `keymaps`, `search`, `blacklist`, and `properties`
|
|
||||||
|
|
||||||
###### `"keymaps"` section
|
|
||||||
|
|
||||||
- [ ] show error on unknown operation name in `"keymaps"`
|
|
||||||
|
|
||||||
###### `"search"` section
|
|
||||||
|
|
||||||
- validations in `"search"` section are not tested in this release
|
|
||||||
|
|
||||||
##### Updating
|
|
||||||
|
|
||||||
- [ ] changes are updated on textarea blure when no errors
|
|
||||||
- [ ] keymap settings are applied to open tabs without reload
|
|
||||||
- [ ] search settings are applied to open tabs without reload
|
|
||||||
|
|
||||||
##### Properties
|
|
||||||
|
|
||||||
- [ ] show errors when invalid property name
|
|
||||||
- [ ] show errors when invalid property type
|
|
||||||
|
|
||||||
#### Form Settings
|
#### Form Settings
|
||||||
|
|
||||||
<!-- validation on form settings does not implement in 0.7 -->
|
<!-- validation on form settings does not implement in 0.7 -->
|
||||||
|
|
|
@ -4,12 +4,27 @@ const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
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", () => {
|
describe("options page", () => {
|
||||||
|
const port = 12321;
|
||||||
|
let http;
|
||||||
let firefox;
|
let firefox;
|
||||||
let session;
|
let session;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
firefox = await lanthan.firefox({
|
||||||
spy: path.join(__dirname, '..'),
|
spy: path.join(__dirname, '..'),
|
||||||
builderf: (builder) => {
|
builderf: (builder) => {
|
||||||
|
@ -26,6 +41,8 @@ describe("options page", () => {
|
||||||
if (firefox) {
|
if (firefox) {
|
||||||
await firefox.close();
|
await firefox.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
http.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
|
@ -35,17 +52,17 @@ describe("options page", () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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) => {
|
const updateTextarea = async(value) => {
|
||||||
|
let textarea = await session.findElementByCSS('textarea');
|
||||||
await session.executeScript(`document.querySelector('textarea').value = '${value}'`)
|
await session.executeScript(`document.querySelector('textarea').value = '${value}'`)
|
||||||
await textarea.sendKeys(' ');
|
await textarea.sendKeys(' ');
|
||||||
await session.executeScript(() => document.querySelector('textarea').blur());
|
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);
|
||||||
|
|
||||||
await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`);
|
await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`);
|
||||||
|
|
||||||
let { settings } = await browser.storage.local.get('settings');
|
let { settings } = await browser.storage.local.get('settings');
|
||||||
|
@ -62,5 +79,21 @@ describe("options page", () => {
|
||||||
let text = await error.getText();
|
let text = await error.getText();
|
||||||
assert.ok(text.startsWith('SyntaxError:'))
|
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);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
Reference in a new issue