aboutsummaryrefslogtreecommitdiff
path: root/e2e/options_form.test.js
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.js
parent0fc2eea7431649f85c6e5d57cca66457f24bb14d (diff)
parent9f0bc5732823505c91ce6b5ba3aa8e4b60ac93f6 (diff)
Merge pull request #648 from ueokande/migrate-to-latest-lanthan
Clean E2E tests
Diffstat (limited to 'e2e/options_form.test.js')
-rw-r--r--e2e/options_form.test.js125
1 files changed, 0 insertions, 125 deletions
diff --git a/e2e/options_form.test.js b/e2e/options_form.test.js
deleted file mode 100644
index f86d995..0000000
--- a/e2e/options_form.test.js
+++ /dev/null
@@ -1,125 +0,0 @@
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('assert');
-
-describe("options form page", () => {
- let firefox;
- let session;
- let browser;
-
- beforeEach(async() => {
- firefox = await lanthan.firefox({
- spy: path.join(__dirname, '..'),
- builderf: (builder) => {
- builder.addFile('build/settings.js');
- builder.addFile('build/settings.html');
- },
- });
- await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
- session = firefox.session;
- browser = firefox.browser;
-
- let tabs = await browser.tabs.query({});
- for (let tab of tabs.slice(1)) {
- await browser.tabs.remove(tab.id);
- }
- })
-
- afterEach(async() => {
- if (firefox) {
- await firefox.close();
- }
- })
-
- const setBlacklistValue = async(nth, value) => {
- let selector = '.form-blacklist-form .column-url';
- let input = (await session.findElementsByCSS(selector))[nth];
- await input.sendKeys(value);
- await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
- }
-
- const setSearchEngineValue = async(nth, name, url) => {
- let selector = '.form-search-form input.column-name';
- let input = (await session.findElementsByCSS(selector))[nth];
- await input.sendKeys(name);
- await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
-
- selector = '.form-search-form input.column-url';
- input = (await session.findElementsByCSS(selector))[nth];
- await input.sendKeys(url);
- await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
- }
-
- it('switch to form settings', async () => {
- let url = await browser.runtime.getURL("build/settings.html")
- await session.navigateTo(url);
-
- let useFormInput = await session.findElementByCSS('#setting-source-form');
- await useFormInput.click();
- await session.acceptAlert();
-
- let { settings } = await browser.storage.local.get('settings');
- assert.equal(settings.source, 'form')
- })
-
- it('add blacklist', async () => {
- let url = await browser.runtime.getURL("build/settings.html")
- await session.navigateTo(url);
-
- let useFormInput = await session.findElementByCSS('#setting-source-form');
- await useFormInput.click();
- await session.acceptAlert();
- await session.executeScript(() => window.scrollBy(0, 1000));
-
- // assert default
- let settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.blacklist, [])
-
- // add blacklist items
- let addButton = await session.findElementByCSS('.form-blacklist-form .ui-add-button');
- await addButton.click();
- await setBlacklistValue(0, 'google.com')
-
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.blacklist, ['google.com'])
-
- await addButton.click();
- await setBlacklistValue(1, 'yahoo.com')
-
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.blacklist, ['google.com', 'yahoo.com'])
-
- // delete first item
- let deleteButton = (await session.findElementsByCSS('.form-blacklist-form .ui-delete-button'))[0];
- await deleteButton.click()
-
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.blacklist, ['yahoo.com'])
- });
-
- it('add search engines', async () => {
- let url = await browser.runtime.getURL("build/settings.html")
- await session.navigateTo(url);
-
- let useFormInput = await session.findElementByCSS('#setting-source-form');
- await useFormInput.click();
- await session.acceptAlert();
-
- // assert default
- let settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.search.default, 'google');
-
- // change default
- let radio = (await session.findElementsByCSS('.form-search-form input[type=radio]'))[2];
- await radio.click();
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.search.default, 'bing');
-
- let addButton = await session.findElementByCSS('.form-search-form .ui-add-button');
- await addButton.click();
- await setSearchEngineValue(6, 'yippy', 'https://www.yippy.com/search?query={}');
-
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepEqual(settings.form.search.engines[6], ['yippy', 'https://www.yippy.com/search?query={}']);
- });
-});