aboutsummaryrefslogtreecommitdiff
path: root/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'e2e')
-rw-r--r--e2e/command_open.test.js150
-rw-r--r--e2e/command_tabopen.test.js161
-rw-r--r--e2e/command_winopen.test.js173
-rw-r--r--e2e/settings.js85
4 files changed, 569 insertions, 0 deletions
diff --git a/e2e/command_open.test.js b/e2e/command_open.test.js
new file mode 100644
index 0000000..2ee3568
--- /dev/null
+++ b/e2e/command_open.test.js
@@ -0,0 +1,150 @@
+const express = require('express');
+const lanthan = require('lanthan');
+const path = require('path');
+const assert = require('assert');
+const eventually = require('./eventually');
+const settings = require('./settings');
+
+const Key = lanthan.Key;
+
+const newApp = () => {
+
+ let app = express();
+ for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
+ app.get('/' + name, (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
+</html">`);
+ });
+ }
+ app.get('/', (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>home</h1></body>
+</html">`);
+ });
+ return app;
+};
+
+describe("open command test", () => {
+ const port = 12321;
+ let http;
+ let firefox;
+ let session;
+ let browser;
+ let tab;
+ let body;
+
+ before(async() => {
+ firefox = await lanthan.firefox({
+ spy: path.join(__dirname, '..'),
+ builderf: (builder) => {
+ builder.addFile('build/settings.js');
+ },
+ });
+ session = firefox.session;
+ browser = firefox.browser;
+ http = newApp().listen(port);
+
+ await browser.storage.local.set({
+ settings,
+ });
+ });
+
+ after(async() => {
+ http.close();
+ if (firefox) {
+ await firefox.close();
+ }
+ });
+
+ beforeEach(async() => {
+ await session.navigateTo(`http://127.0.0.1:${port}`);
+ body = await session.findElementByCSS('body');
+ })
+
+ it('should open default search for keywords by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open an apple', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=an%20apple`)
+ });
+ });
+
+ it('should open certain search page for keywords by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open yahoo an apple', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true })
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=an%20apple`)
+ });
+ });
+
+ it('should open default engine with empty keywords by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true })
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=`)
+ });
+ });
+
+ it('should open certain search page for empty keywords by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open yahoo', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true })
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=`)
+ });
+ });
+
+ it('should open a site with domain by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true })
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+
+ it('should open a site with URL by open command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('open https://i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({ active: true })
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+});
diff --git a/e2e/command_tabopen.test.js b/e2e/command_tabopen.test.js
new file mode 100644
index 0000000..4decb5c
--- /dev/null
+++ b/e2e/command_tabopen.test.js
@@ -0,0 +1,161 @@
+const express = require('express');
+const lanthan = require('lanthan');
+const path = require('path');
+const assert = require('assert');
+const eventually = require('./eventually');
+const settings = require('./settings');
+
+const Key = lanthan.Key;
+
+const newApp = () => {
+
+ let app = express();
+ for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
+ app.get('/' + name, (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
+</html">`);
+ });
+ }
+ app.get('/', (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>home</h1></body>
+</html">`);
+ });
+ return app;
+};
+
+describe("tabopen command test", () => {
+ const port = 12321;
+ let http;
+ let firefox;
+ let session;
+ let browser;
+ let tab;
+ let body;
+
+ before(async() => {
+ http = newApp().listen(port);
+
+ firefox = await lanthan.firefox({
+ spy: path.join(__dirname, '..'),
+ builderf: (builder) => {
+ builder.addFile('build/settings.js');
+ },
+ });
+ session = firefox.session;
+ browser = firefox.browser;
+ await browser.storage.local.set({
+ settings,
+ });
+ });
+
+ after(async() => {
+ http.close();
+ if (firefox) {
+ await firefox.close();
+ }
+ });
+
+ beforeEach(async() => {
+ let tabs = await browser.tabs.query({});
+ for (let tab of tabs.slice(1)) {
+ await browser.tabs.remove(tab.id);
+ }
+
+ await session.navigateTo(`http://127.0.0.1:${port}`);
+ body = await session.findElementByCSS('body');
+ })
+
+ it('should open default search for keywords by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen an apple', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=an%20apple`)
+ });
+ });
+
+ it('should open certain search page for keywords by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen yahoo an apple', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=an%20apple`)
+ });
+ });
+
+ it('should open default engine with empty keywords by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=`)
+ });
+ });
+
+ it('should open certain search page for empty keywords by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen yahoo', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=`)
+ });
+ });
+
+ it('should open a site with domain by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+
+ it('should open a site with URL by tabopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('tabopen https://i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let tabs = await browser.tabs.query({});
+ assert.equal(tabs.length, 2);
+ let url = new URL(tabs[1].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+});
diff --git a/e2e/command_winopen.test.js b/e2e/command_winopen.test.js
new file mode 100644
index 0000000..09135fe
--- /dev/null
+++ b/e2e/command_winopen.test.js
@@ -0,0 +1,173 @@
+const express = require('express');
+const lanthan = require('lanthan');
+const path = require('path');
+const assert = require('assert');
+const eventually = require('./eventually');
+const settings = require('./settings');
+
+const Key = lanthan.Key;
+
+const newApp = () => {
+
+ let app = express();
+ for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
+ app.get('/' + name, (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
+</html">`);
+ });
+ }
+ app.get('/', (req, res) => {
+ res.send(`<!DOCTYPEhtml>
+<html lang="en">
+ <body><h1>home</h1></body>
+</html">`);
+ });
+ return app;
+};
+
+describe("winopen command test", () => {
+ const port = 12321;
+ let http;
+ let firefox;
+ let session;
+ let browser;
+ let tab;
+ let body;
+
+ before(async() => {
+ http = newApp().listen(port);
+
+ firefox = await lanthan.firefox({
+ spy: path.join(__dirname, '..'),
+ builderf: (builder) => {
+ builder.addFile('build/settings.js');
+ },
+ });
+ session = firefox.session;
+ browser = firefox.browser;
+ await browser.storage.local.set({
+ settings,
+ });
+ });
+
+ after(async() => {
+ http.close();
+ if (firefox) {
+ await firefox.close();
+ }
+ });
+
+ beforeEach(async() => {
+ let wins = await browser.windows.getAll();
+ for (let win of wins.slice(1)) {
+ await browser.windows.remove(win.id);
+ }
+
+ await session.navigateTo(`http://127.0.0.1:${port}`);
+ body = await session.findElementByCSS('body');
+ })
+
+ it('should open default search for keywords by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen an apple', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=an%20apple`)
+ });
+ });
+
+ it('should open certain search page for keywords by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen yahoo an apple', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=an%20apple`)
+ });
+ });
+
+ it('should open default engine with empty keywords by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/google?q=`)
+ });
+ });
+
+ it('should open certain search page for empty keywords by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen yahoo', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, `http://127.0.0.1:${port}/yahoo?q=`)
+ });
+ });
+
+ it('should open a site with domain by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+
+ it('should open a site with URL by winopen command ', async() => {
+ await body.sendKeys(':');
+
+ await session.switchToFrame(0);
+ let input = await session.findElementByCSS('input');
+ input.sendKeys('winopen https://i-beam.org', Key.Enter);
+
+ await eventually(async() => {
+ let wins = await browser.windows.getAll();
+ assert.equal(wins.length, 2);
+
+ let tabs = await browser.tabs.query({ windowId: wins[1].id });
+ let url = new URL(tabs[0].url);
+ assert.equal(url.href, 'https://i-beam.org/')
+ });
+ });
+});
diff --git a/e2e/settings.js b/e2e/settings.js
new file mode 100644
index 0000000..e09747f
--- /dev/null
+++ b/e2e/settings.js
@@ -0,0 +1,85 @@
+module.exports = {
+ source: 'json',
+ json: `{
+ "keymaps": {
+ "0": { "type": "scroll.home" },
+ ":": { "type": "command.show" },
+ "o": { "type": "command.show.open", "alter": false },
+ "O": { "type": "command.show.open", "alter": true },
+ "t": { "type": "command.show.tabopen", "alter": false },
+ "T": { "type": "command.show.tabopen", "alter": true },
+ "w": { "type": "command.show.winopen", "alter": false },
+ "W": { "type": "command.show.winopen", "alter": true },
+ "b": { "type": "command.show.buffer" },
+ "a": { "type": "command.show.addbookmark", "alter": true },
+ "k": { "type": "scroll.vertically", "count": -1 },
+ "j": { "type": "scroll.vertically", "count": 1 },
+ "h": { "type": "scroll.horizonally", "count": -1 },
+ "l": { "type": "scroll.horizonally", "count": 1 },
+ "<C-U>": { "type": "scroll.pages", "count": -0.5 },
+ "<C-D>": { "type": "scroll.pages", "count": 0.5 },
+ "<C-B>": { "type": "scroll.pages", "count": -1 },
+ "<C-F>": { "type": "scroll.pages", "count": 1 },
+ "gg": { "type": "scroll.top" },
+ "G": { "type": "scroll.bottom" },
+ "$": { "type": "scroll.end" },
+ "d": { "type": "tabs.close" },
+ "D": { "type": "tabs.close.right" },
+ "!d": { "type": "tabs.close.force" },
+ "u": { "type": "tabs.reopen" },
+ "K": { "type": "tabs.prev", "count": 1 },
+ "J": { "type": "tabs.next", "count": 1 },
+ "gT": { "type": "tabs.prev", "count": 1 },
+ "gt": { "type": "tabs.next", "count": 1 },
+ "g0": { "type": "tabs.first" },
+ "g$": { "type": "tabs.last" },
+ "<C-6>": { "type": "tabs.prevsel" },
+ "r": { "type": "tabs.reload", "cache": false },
+ "R": { "type": "tabs.reload", "cache": true },
+ "zp": { "type": "tabs.pin.toggle" },
+ "zd": { "type": "tabs.duplicate" },
+ "zi": { "type": "zoom.in" },
+ "zo": { "type": "zoom.out" },
+ "zz": { "type": "zoom.neutral" },
+ "f": { "type": "follow.start", "newTab": false },
+ "F": { "type": "follow.start", "newTab": true, "background": false },
+ "m": { "type": "mark.set.prefix" },
+ "'": { "type": "mark.jump.prefix" },
+ "H": { "type": "navigate.history.prev" },
+ "L": { "type": "navigate.history.next" },
+ "[[": { "type": "navigate.link.prev" },
+ "]]": { "type": "navigate.link.next" },
+ "gu": { "type": "navigate.parent" },
+ "gU": { "type": "navigate.root" },
+ "gi": { "type": "focus.input" },
+ "gf": { "type": "page.source" },
+ "gh": { "type": "page.home" },
+ "gH": { "type": "page.home", "newTab": true },
+ "y": { "type": "urls.yank" },
+ "p": { "type": "urls.paste", "newTab": false },
+ "P": { "type": "urls.paste", "newTab": true },
+ "/": { "type": "find.start" },
+ "n": { "type": "find.next" },
+ "N": { "type": "find.prev" },
+ "<S-Esc>": { "type": "addon.toggle.enabled" }
+ },
+ "search": {
+ "default": "google",
+ "engines": {
+ "google": "http://127.0.0.1:12321/google?q={}",
+ "yahoo": "http://127.0.0.1:12321/yahoo?q={}",
+ "bing": "http://127.0.0.1:12321/bind?q={}",
+ "duckduckgo": "http://127.0.0.1:12321/duplicate?q={}",
+ "twitter": "http://127.0.0.1:12321/twitter?q={}",
+ "wikipedia": "http://127.0.0.1:12321/wikipedia?q={}"
+ }
+ },
+ "properties": {
+ "hintchars": "abcdefghijklmnopqrstuvwxyz",
+ "smoothscroll": false,
+ "complete": "sbh"
+ },
+ "blacklist": [
+ ]
+}`,
+}