aboutsummaryrefslogtreecommitdiff
path: root/e2e/options_form.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-09-29 01:06:01 +0000
committerGitHub <noreply@github.com>2019-09-29 01:06:01 +0000
commit4f4396d0a69d33541844e723cad033b0a927333b (patch)
treef3a75c0b41d8fe2b1e6ca730501e36cee5701705 /e2e/options_form.test.ts
parent0fc2eea7431649f85c6e5d57cca66457f24bb14d (diff)
parent9f0bc5732823505c91ce6b5ba3aa8e4b60ac93f6 (diff)
Merge pull request #648 from ueokande/migrate-to-latest-lanthan
Clean E2E tests
Diffstat (limited to 'e2e/options_form.test.ts')
-rw-r--r--e2e/options_form.test.ts86
1 files changed, 86 insertions, 0 deletions
diff --git a/e2e/options_form.test.ts b/e2e/options_form.test.ts
new file mode 100644
index 0000000..af53791
--- /dev/null
+++ b/e2e/options_form.test.ts
@@ -0,0 +1,86 @@
+import * as path from 'path';
+import * as assert from 'assert';
+
+import { Builder, Lanthan } from 'lanthan';
+import OptionPage from './lib/OptionPage';
+
+describe("options form page", () => {
+ let lanthan: Lanthan;
+ let browser: any;
+
+ beforeEach(async() => {
+ lanthan = await Builder
+ .forBrowser('firefox')
+ .spyAddon(path.join(__dirname, '..'))
+ .build();
+ browser = lanthan.getWebExtBrowser();
+
+ let tabs = await browser.tabs.query({});
+ for (let tab of tabs.slice(1)) {
+ await browser.tabs.remove(tab.id);
+ }
+ })
+
+ afterEach(async() => {
+ if (lanthan) {
+ await lanthan.quit();
+ }
+ })
+
+ it('switch to form settings', async () => {
+ let page = await OptionPage.open(lanthan);
+ await page.switchToForm();
+
+ let { settings } = await browser.storage.local.get('settings');
+ assert.strictEqual(settings.source, 'form')
+ })
+
+ it('add blacklist', async () => {
+ let page = await OptionPage.open(lanthan);
+ let forms = await page.switchToForm();
+ // Scroll is required to click a button on Firefox 60
+ await page.scrollTo(0, 1000);
+
+ // assert default
+ let settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.blacklist, [])
+
+ // add blacklist items
+ await forms.addBlacklist();
+ await forms.setBlacklist(0, 'google.com')
+
+ settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.blacklist, ['google.com'])
+
+ await forms.addBlacklist();
+ await forms.setBlacklist(1, 'yahoo.com')
+
+ settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.blacklist, ['google.com', 'yahoo.com'])
+
+ // delete first item
+ await forms.removeBlackList(0);
+ settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.blacklist, ['yahoo.com'])
+ });
+
+ it('add search engines', async () => {
+ let page = await OptionPage.open(lanthan);
+ let forms = await page.switchToForm();
+
+ // assert default
+ let settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.search.default, 'google');
+
+ // change default
+ await forms.setDefaultSearchEngine(2);
+ settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.search.default, 'bing');
+
+ await forms.addSearchEngine();
+ await forms.setSearchEngine(6, 'yippy', 'https://www.yippy.com/search?query={}');
+
+ settings = (await browser.storage.local.get('settings')).settings;
+ assert.deepStrictEqual(settings.form.search.engines[6], ['yippy', 'https://www.yippy.com/search?query={}']);
+ });
+});