aboutsummaryrefslogtreecommitdiff
path: root/e2e
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-08-20 22:11:45 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-08-20 22:11:45 +0900
commitcd549234b457e868f11624de9fd2cdd533a63e06 (patch)
tree160bee1512658c55dc35d720d71ef1f635e860c6 /e2e
parentf479f33bd2af7b07980d6639f1fc2ad5bac453f2 (diff)
Add search engine e2e test
Diffstat (limited to 'e2e')
-rw-r--r--e2e/options_form.test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/e2e/options_form.test.js b/e2e/options_form.test.js
index d665f1c..67ab0ba 100644
--- a/e2e/options_form.test.js
+++ b/e2e/options_form.test.js
@@ -38,6 +38,18 @@ describe("options form page", () => {
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);
@@ -58,9 +70,11 @@ describe("options form page", () => {
await useFormInput.click();
await session.acceptAlert();
+ // 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')
@@ -74,10 +88,37 @@ describe("options form page", () => {
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.only('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={}']);
+ });
});