diff options
Diffstat (limited to 'e2e')
35 files changed, 498 insertions, 442 deletions
diff --git a/e2e/blacklist.test.ts b/e2e/blacklist.test.ts index dec9d99..79cdb47 100644 --- a/e2e/blacklist.test.ts +++ b/e2e/blacklist.test.ts @@ -9,7 +9,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("blacklist test", () => { - let server = new TestServer().receiveContent('/*', + const server = new TestServer().receiveContent('/*', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -25,7 +25,7 @@ describe("blacklist test", () => { browser = lanthan.getWebExtBrowser(); await server.start(); - let url = server.url('/a').replace('http://', ''); + const url = server.url('/a').replace('http://', ''); await new SettingRepository(browser).saveJSON(Settings.fromJSON({ keymaps: { j: { type: "scroll.vertically", count: 1 }, @@ -42,18 +42,18 @@ describe("blacklist test", () => { }); it('should disable add-on if the URL is in the blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a')); + const page = await Page.navigateTo(webdriver, server.url('/a')); await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 0); }); it('should enabled add-on if the URL is not in the blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/ab')); + const page = await Page.navigateTo(webdriver, server.url('/ab')); await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64); }); }); diff --git a/e2e/clipboard.test.ts b/e2e/clipboard.test.ts index 3f2b289..0a09c77 100644 --- a/e2e/clipboard.test.ts +++ b/e2e/clipboard.test.ts @@ -11,7 +11,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("clipboard test", () => { - let server = new TestServer(12321).receiveContent('/happy', 'ok'); + const server = new TestServer(12321).receiveContent('/happy', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -44,18 +44,18 @@ describe("clipboard test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should copy current URL by y', async () => { - let page = await Page.navigateTo(webdriver, server.url('/#should_copy_url')); + const page = await Page.navigateTo(webdriver, server.url('/#should_copy_url')); await page.sendKeys('y'); await eventually(async() => { - let data = await clipboard.read(); + const data = await clipboard.read(); assert.strictEqual(data, server.url('/#should_copy_url')); }); }); @@ -63,11 +63,11 @@ describe("clipboard test", () => { it('should open an URL from clipboard by p', async () => { await clipboard.write(server.url('/#open_from_clipboard')); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('p'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, server.url('/#open_from_clipboard')); }); }); @@ -75,11 +75,11 @@ describe("clipboard test", () => { it('should open an URL from clipboard to new tab by P', async () => { await clipboard.write(server.url('/#open_to_new_tab')); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url(), server.url('/#open_to_new_tab'), @@ -90,11 +90,11 @@ describe("clipboard test", () => { it('should open search result with keywords in clipboard by p', async () => { await clipboard.write(`an apple`); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, server.url('/google?q=an%20apple')); }); }); @@ -102,11 +102,11 @@ describe("clipboard test", () => { it('should open search result with keywords in clipboard to new tabby P', async () => { await clipboard.write(`an apple`); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url(), server.url('/google?q=an%20apple'), diff --git a/e2e/command_addbookmark.test.ts b/e2e/command_addbookmark.test.ts index 5344292..a54c103 100644 --- a/e2e/command_addbookmark.test.ts +++ b/e2e/command_addbookmark.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('addbookmark command test', () => { - let server = new TestServer().receiveContent('/happy', ` + const server = new TestServer().receiveContent('/happy', ` <!DOCTYPE html> <html lang="en"><head><title>how to be happy</title></head></html>`, ); @@ -38,12 +38,12 @@ describe('addbookmark command test', () => { }); it('should add a bookmark from the current page', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('addbookmark how to be happy'); await eventually(async() => { - var bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); + const bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); assert.strictEqual(bookmarks.length, 1); assert.strictEqual(bookmarks[0].url, server.url('/happy')); }); diff --git a/e2e/command_bdelete.test.ts b/e2e/command_bdelete.test.ts index 239074e..c1f27ae 100644 --- a/e2e/command_bdelete.test.ts +++ b/e2e/command_bdelete.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('bdelete/bdeletes command test', () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -31,8 +31,8 @@ describe('bdelete/bdeletes command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1'), pinned: true }); @@ -42,19 +42,19 @@ describe('bdelete/bdeletes command test', () => { await browser.tabs.create({ url: server.url('/site5'), }); await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should delete an unpinned tab by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site5'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -65,45 +65,45 @@ describe('bdelete/bdeletes command test', () => { }); it('should not delete an pinned tab by bdelete command by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site1'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 5); }); }); it('should show an error when no tabs are matched by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete xyz'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'No matching buffer for xyz'); }); }); it('should show an error when more than one tabs are matched by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'More than one match for site'); }); }); it('should delete an unpinned tab by bdelete! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete! site5'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -114,12 +114,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete an pinned tab by bdelete! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete! site1'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site2'), server.url('/site3'), @@ -130,12 +130,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete unpinned tabs by bdeletes command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdeletes site'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -145,12 +145,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete both pinned and unpinned tabs by bdeletes! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdeletes! site'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1); }); }); diff --git a/e2e/command_buffer.test.ts b/e2e/command_buffer.test.ts index 472502b..3fa67ba 100644 --- a/e2e/command_buffer.test.ts +++ b/e2e/command_buffer.test.ts @@ -9,7 +9,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('buffer command test', () => { - let server = new TestServer().handle('/*', (req: Request, res: Response) => { + const server = new TestServer().handle('/*', (req: Request, res: Response) => { res.send(` <!DOCTYPE html> <html lang="en"> @@ -40,8 +40,8 @@ describe('buffer command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1') }); @@ -50,41 +50,41 @@ describe('buffer command test', () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should do nothing by buffer command with no parameters', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); it('should select a tab by buffer command with a number', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer 1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should should an out of range error by buffer commands', async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); let console = await page.showConsole(); await console.execCommand('buffer 0'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'tab 0 does not exist'); }); @@ -94,68 +94,68 @@ describe('buffer command test', () => { await console.execCommand('buffer 9'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'tab 9 does not exist'); }); }); it('should select a tab by buffer command with a title', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer my_site1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should select a tab by buffer command with an URL', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer /site1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should select tabs rotately', async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[4]); - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer site'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should do nothing by ":buffer %"', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer %'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); it('should selects last selected tab by ":buffer #"', async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[1]); - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer #'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); diff --git a/e2e/command_help.test.ts b/e2e/command_help.test.ts index 20035fd..9f8a459 100644 --- a/e2e/command_help.test.ts +++ b/e2e/command_help.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("help command test", () => { - let server = new TestServer(); + const server = new TestServer(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -37,11 +37,11 @@ describe("help command test", () => { }); it('should open help page by help command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('help'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, 'https://ueokande.github.io/vim-vixen/') }); }); diff --git a/e2e/command_open.test.ts b/e2e/command_open.test.ts index ba9c51e..f4d2aa1 100644 --- a/e2e/command_open.test.ts +++ b/e2e/command_open.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("open command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -51,67 +51,67 @@ describe("open command test", () => { }); it('should open default search for keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple')) }); }); it('should open certain search page for keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open yahoo an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open yahoo'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open example.com'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open https://example.com/'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/command_quit.test.ts b/e2e/command_quit.test.ts index 239d880..037ad09 100644 --- a/e2e/command_quit.test.ts +++ b/e2e/command_quit.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('quit/quitall command test', () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -31,8 +31,8 @@ describe('quit/quitall command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1') }); @@ -41,52 +41,52 @@ describe('quit/quitall command test', () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should current tab by q command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('q'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 4) }); }); it('should current tab by quit command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('quit'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 4) }); }); it('should current tab by qa command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('qa'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1) }); }); it('should current tab by quitall command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('quitall'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1) }); }); diff --git a/e2e/command_tabopen.test.ts b/e2e/command_tabopen.test.ts index b5533e6..e96c29e 100644 --- a/e2e/command_tabopen.test.ts +++ b/e2e/command_tabopen.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("tabopen command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -46,8 +46,8 @@ describe("tabopen command test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } @@ -55,73 +55,73 @@ describe("tabopen command test", () => { }); it('should open default search for keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple') ) }); }); it('should open certain search page for keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen yahoo an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen yahoo'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen example.com'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen https://example.com/'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/command_winopen.test.ts b/e2e/command_winopen.test.ts index fb1348d..c9ff8d2 100644 --- a/e2e/command_winopen.test.ts +++ b/e2e/command_winopen.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("winopen command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -46,8 +46,8 @@ describe("winopen command test", () => { }); beforeEach(async() => { - let wins = await browser.windows.getAll(); - for (let win of wins.slice(1)) { + const wins = await browser.windows.getAll(); + for (const win of wins.slice(1)) { await browser.windows.remove(win.id); } @@ -55,85 +55,85 @@ describe("winopen command test", () => { }); it('should open default search for keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen an apple'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple')) }); }); it('should open certain search page for keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen yahoo an apple'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen yahoo'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen example.com'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen https://example.com/'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/completion.test.ts b/e2e/completion.test.ts index e98e1c2..dd4477f 100644 --- a/e2e/completion.test.ts +++ b/e2e/completion.test.ts @@ -30,9 +30,9 @@ describe("general completion test", () => { }); it('should all commands on empty line', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 11); assert.deepStrictEqual(items[0], { type: 'title', text: 'Console Command' }); assert.ok(items[1].text.startsWith('set')); @@ -41,10 +41,10 @@ describe("general completion test", () => { }); it('should only commands filtered by prefix', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('b'); - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.deepStrictEqual(items[0], { type: 'title', text: 'Console Command' }); assert.ok(items[1].text.startsWith('buffer')); @@ -57,23 +57,23 @@ describe("general completion test", () => { // > bdeletes // : b it('selects completion items by <Tab>/<S-Tab> keys', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('b'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); }); await console.sendKeys(Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[1].highlight); assert.strictEqual(await console.currentValue(), 'buffer'); }); await console.sendKeys(Key.TAB, Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[3].highlight); assert.strictEqual(await console.currentValue(), 'bdeletes'); }); @@ -85,7 +85,7 @@ describe("general completion test", () => { await console.sendKeys(Key.SHIFT, Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[3].highlight); assert.strictEqual(await console.currentValue(), 'bdeletes'); }); diff --git a/e2e/completion_buffers.test.ts b/e2e/completion_buffers.test.ts index b6e7de0..ac24753 100644 --- a/e2e/completion_buffers.test.ts +++ b/e2e/completion_buffers.test.ts @@ -9,7 +9,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("completion on buffer/bdelete/bdeletes", () => { - let server = new TestServer().handle('/*', (req: Request, res: Response) => { + const server = new TestServer().handle('/*', (req: Request, res: Response) => { res.send(` <!DOCTYPE html> <html lang="en"> @@ -42,8 +42,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } @@ -54,7 +54,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); @@ -63,11 +63,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should all tabs by "buffer" command with empty params', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer '); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('1:')); @@ -82,11 +82,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should filter items with URLs by keywords on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer title_site2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); assert.ok(items[1].text.includes('title_site2')); @@ -95,22 +95,22 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should filter items with titles by keywords on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer /site2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); }); }); it('should show one item by number on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer 2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 2); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); @@ -118,11 +118,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show unpinned tabs "bdelete" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdelete site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.ok(items[1].text.includes('site3')); assert.ok(items[2].text.includes('site4')); @@ -131,11 +131,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show unpinned tabs "bdeletes" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdeletes site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.ok(items[1].text.includes('site3')); assert.ok(items[2].text.includes('site4')); @@ -144,11 +144,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show both pinned and unpinned tabs "bdelete!" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdelete! site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.ok(items[1].text.includes('site1')); assert.ok(items[2].text.includes('site2')); @@ -159,11 +159,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show both pinned and unpinned tabs "bdeletes!" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdeletes! site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.ok(items[1].text.includes('site1')); assert.ok(items[2].text.includes('site2')); diff --git a/e2e/completion_open.test.ts b/e2e/completion_open.test.ts index 5f8bd11..95d4175 100644 --- a/e2e/completion_open.test.ts +++ b/e2e/completion_open.test.ts @@ -10,7 +10,7 @@ import Page from './lib/Page'; import SettingRepository from "./lib/SettingRepository"; describe("completion on open/tabopen/winopen commands", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -27,7 +27,7 @@ describe("completion on open/tabopen/winopen commands", () => { browser = lanthan.getWebExtBrowser(); // Add item into hitories - await webdriver.navigate().to(('https://i-beam.org/404')); + await webdriver.navigate().to(('https://example.com/')); }); after(async() => { @@ -42,11 +42,11 @@ describe("completion on open/tabopen/winopen commands", () => { }); it('should show completions from search engines, bookmarks, and histories by "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); + const completions = await console.getCompletions(); assert.ok(completions.find(x => x.type === 'title' && x.text === 'Search Engines')); assert.ok(completions.find(x => x.type === 'title' && x.text === 'Bookmarks')); assert.ok(completions.find(x => x.type === 'title' && x.text === 'History')); @@ -54,45 +54,45 @@ describe("completion on open/tabopen/winopen commands", () => { }); it('should filter items with URLs by keywords on "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open https://'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); it('should filter items with titles by keywords on "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open getting'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.toLowerCase().includes('getting'))); }); }); it('should filter items with titles by keywords on "tabopen" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('tabopen getting'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); it('should filter items with titles by keywords on "winopen" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('winopen https://'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); @@ -106,8 +106,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) }); @@ -120,8 +120,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Bookmarks', 'Search Engines', 'Search Engines']) }); }); @@ -135,8 +135,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) }); @@ -151,8 +151,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Bookmarks', 'Search Engines', 'Search Engines']) }); }); diff --git a/e2e/completion_set.test.ts b/e2e/completion_set.test.ts index facf991..7e9714c 100644 --- a/e2e/completion_set.test.ts +++ b/e2e/completion_set.test.ts @@ -30,11 +30,11 @@ describe("completion on set commands", () => { }); it('should show all property names by "set" command with empty params', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('set '); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 5); assert.deepStrictEqual(items[0], { type: 'title', text: 'Properties' }); assert.ok(items[1].text.startsWith('hintchars')); @@ -45,11 +45,11 @@ describe("completion on set commands", () => { }); it('should show filtered property names by "set" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('set no'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 2); assert.ok(items[1].text.includes('nosmoothscroll')) }); diff --git a/e2e/console.test.ts b/e2e/console.test.ts index faaf695..1d441f9 100644 --- a/e2e/console.test.ts +++ b/e2e/console.test.ts @@ -7,7 +7,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("console test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><head><title>Hello, world!</title></head></html>`, ); let lanthan: Lanthan; @@ -36,55 +36,55 @@ describe("console test", () => { it('open console with :', async() => { await page.sendKeys(':'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), ''); }); it('open console with open command by o', async() => { await page.sendKeys('o'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), 'open '); }); it('open console with open command and current URL by O', async() => { await page.sendKeys(Key.SHIFT, 'o'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `open ${server.url()}`); }); it('open console with tabopen command by t', async() => { await page.sendKeys('t'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), 'tabopen '); }); it('open console with tabopen command and current URL by T', async() => { await page.sendKeys(Key.SHIFT, 't'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `tabopen ${server.url()}`); }); it('open console with winopen command by w', async() => { await page.sendKeys('w'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `winopen `); }); it('open console with winopen command and current URL by W', async() => { await page.sendKeys(Key.SHIFT, 'W'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `winopen ${server.url()}`); }); it('open console with buffer command by b', async() => { await page.sendKeys('b'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `buffer `); }); it('open console with addbookmark command with title by a', async() => { await page.sendKeys('a'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `addbookmark Hello, world!`); }); }); diff --git a/e2e/eventually.ts b/e2e/eventually.ts index 12c4552..b0a2dfc 100644 --- a/e2e/eventually.ts +++ b/e2e/eventually.ts @@ -12,8 +12,8 @@ const eventually = async ( timeout = defaultTimeout, interval = defaultInterval, ): Promise<void> => { - let start = Date.now(); - let loop = async() => { + const start = Date.now(); + const loop = async() => { try { await fn(); } catch (err) { diff --git a/e2e/follow.test.ts b/e2e/follow.test.ts index ce3f565..62a109f 100644 --- a/e2e/follow.test.ts +++ b/e2e/follow.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; const newApp = () => { - let server = new TestServer(); + const server = new TestServer(); server.receiveContent('/', ` <!DOCTYPE html> @@ -105,7 +105,7 @@ const newApp = () => { }; describe('follow test', () => { - let server = newApp(); + const server = newApp(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -128,52 +128,52 @@ describe('follow test', () => { }); afterEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should focus an input by f', async () => { - let page = await Page.navigateTo(webdriver, server.url('/follow-input')); + const page = await Page.navigateTo(webdriver, server.url('/follow-input')); await page.sendKeys('f'); await page.waitAndGetHints(); await page.sendKeys('a'); - let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; + const tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; assert.strictEqual(tagName.toLowerCase(), 'input'); }); it('should open a link by f', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('f'); await page.waitAndGetHints(); await page.sendKeys('a'); await eventually(async() => { - let hash = await webdriver.executeScript('return location.pathname'); + const hash = await webdriver.executeScript('return location.pathname'); assert.strictEqual(hash, '/hello'); }); }); it('should focus an input by F', async () => { - let page = await Page.navigateTo(webdriver, server.url('/follow-input')); + const page = await Page.navigateTo(webdriver, server.url('/follow-input')); await page.sendKeys(Key.SHIFT, 'f'); await page.waitAndGetHints(); await page.sendKeys('a'); - let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; + const tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; assert.strictEqual(tagName.toLowerCase(), 'input'); }); it('should open a link to new tab by F', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'f'); await page.waitAndGetHints(); await page.sendKeys('a'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); assert.strictEqual(new URL(tabs[1].url).pathname, '/hello'); assert.strictEqual(tabs[1].openerTabId, tabs[0].id); @@ -181,36 +181,36 @@ describe('follow test', () => { }); it('should show hints of links in area', async () => { - let page = await Page.navigateTo(webdriver, server.url('/area')); + const page = await Page.navigateTo(webdriver, server.url('/area')); await page.sendKeys(Key.SHIFT, 'f'); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 3); }); it('should shows hints only in viewport', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test1')); + const page = await Page.navigateTo(webdriver, server.url('/test1')); await page.sendKeys(Key.SHIFT, 'f'); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); it('should shows hints only in window of the frame', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test2')); + const page = await Page.navigateTo(webdriver, server.url('/test2')); await page.sendKeys(Key.SHIFT, 'f'); await webdriver.switchTo().frame(0); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); it('should shows hints only in the frame', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test3')); + const page = await Page.navigateTo(webdriver, server.url('/test3')); await page.sendKeys(Key.SHIFT, 'f'); await webdriver.switchTo().frame(0); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); }); diff --git a/e2e/follow_properties.test.ts b/e2e/follow_properties.test.ts index eaa38e2..bbd46d4 100644 --- a/e2e/follow_properties.test.ts +++ b/e2e/follow_properties.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe('follow properties test', () => { - let server = new TestServer().receiveContent('/', ` + const server = new TestServer().receiveContent('/', ` <!DOCTYPE html> <html lang="en"><body> <a href="/">link1</a> @@ -65,8 +65,8 @@ describe('follow properties test', () => { }); afterEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); @@ -99,7 +99,7 @@ describe('follow properties test', () => { await page.sendKeys('jj'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs[0].active, false); assert.strictEqual(tabs[1].active, true); }); @@ -111,14 +111,14 @@ describe('follow properties test', () => { await page.sendKeys('jj'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs[0].active, true); assert.strictEqual(tabs[1].active, false); }); }); it('should show hints with hintchars by settings', async () => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('set hintchars=abc'); await (webdriver.switchTo() as any).parentFrame(); diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts index 233bf48..6a82387 100644 --- a/e2e/lib/Console.ts +++ b/e2e/lib/Console.ts @@ -11,13 +11,13 @@ export class Console { } async sendKeys(...keys: string[]) { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); input.sendKeys(...keys); } async currentValue() { return await this.webdriver.executeScript(() => { - let input = document.querySelector('input'); + const input = document.querySelector('input'); if (input === null) { throw new Error('could not find input element'); } @@ -26,33 +26,33 @@ export class Console { } async execCommand(command: string): Promise<void> { - let input = await this.webdriver.findElement(By.css('input.vimvixen-console-command-input')); + const input = await this.webdriver.findElement(By.css('input.vimvixen-console-command-input')); await input.sendKeys(command, Key.ENTER); } async getErrorMessage(): Promise<string> { - let p = await this.webdriver.findElement(By.css('.vimvixen-console-error')); + const p = await this.webdriver.findElement(By.css('.vimvixen-console-error')); return p.getText(); } async inputKeys(...keys: string[]) { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); await input.sendKeys(...keys); } getCompletions(): Promise<CompletionItem[]> { return this.webdriver.executeScript(() => { - let items = document.querySelectorAll('.vimvixen-console-completion > li'); + const items = document.querySelectorAll('.vimvixen-console-completion > li'); if (items.length === 0) { throw new Error('completion items not found'); } - let objs = []; - for (let li of Array.from(items)) { + const objs = []; + for (const li of Array.from(items)) { if (li.classList.contains('vimvixen-console-completion-title')) { objs.push({ type: 'title', text: li.textContent!!.trim() }); } else if ('vimvixen-console-completion-item') { - let highlight = li.classList.contains('vimvixen-completion-selected'); + const highlight = li.classList.contains('vimvixen-completion-selected'); objs.push({ type: 'item', text: li.textContent!!.trim(), highlight }); } else { throw new Error(`unexpected class: ${li.className}`); @@ -63,7 +63,7 @@ export class Console { } async close(): Promise<void> { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); await input.sendKeys(Key.ESCAPE); // TODO remove sleep await new Promise(resolve => setTimeout(resolve, 100)); diff --git a/e2e/lib/FormOptionPage.ts b/e2e/lib/FormOptionPage.ts index 7d981f4..33ce2a7 100644 --- a/e2e/lib/FormOptionPage.ts +++ b/e2e/lib/FormOptionPage.ts @@ -9,8 +9,8 @@ export default class FormOptionPage { } async setBlacklist(nth: number, url: string): Promise<void> { - let selector = '.form-blacklist-form-row > .column-url'; - let inputs = await this.webdriver.findElements(By.css(selector)); + const selector = '.form-blacklist-form-row > .column-url'; + const inputs = await this.webdriver.findElements(By.css(selector)); if (inputs.length <= nth) { throw new RangeError('Index out of range to set a blacklist') } @@ -55,21 +55,21 @@ export default class FormOptionPage { } async addBlacklist(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-blacklist-form-row`)); - let button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-blacklist-form-row`)); + const button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-blacklist-form-row:nth-child(${rows.length + 1})`))); } async addPartialBlacklist(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-partial-blacklist-form-row`)); - let button = await this.webdriver.findElement(By.css('.form-partial-blacklist-form .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-partial-blacklist-form-row`)); + const button = await this.webdriver.findElement(By.css('.form-partial-blacklist-form .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-partial-blacklist-form-row:nth-child(${rows.length + 2})`))); } async removeBlackList(nth: number): Promise<void> { - let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button')); + const buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button')); if (buttons.length <= nth) { throw new RangeError('Index out of range to remove blacklist') } @@ -77,7 +77,7 @@ export default class FormOptionPage { } async removePartialBlackList(nth: number): Promise<void> { - let buttons = await this.webdriver.findElements(By.css('.form-partial-blacklist-form-row .ui-delete-button')); + const buttons = await this.webdriver.findElements(By.css('.form-partial-blacklist-form-row .ui-delete-button')); if (buttons.length <= nth) { throw new RangeError('Index out of range to remove partial blacklist') } @@ -85,14 +85,14 @@ export default class FormOptionPage { } async addSearchEngine(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`)); - let button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`)); + const button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-search-form-row:nth-child(${rows.length + 1})`))); } async setDefaultSearchEngine(nth: number): Promise<void> { - let radios = await this.webdriver.findElements(By.css('.form-search-form-row input[type=radio]')); + const radios = await this.webdriver.findElements(By.css('.form-search-form-row input[type=radio]')); if (radios.length <= nth) { throw new RangeError('Index out of range to set a default search engine'); } diff --git a/e2e/lib/JSONOptionPage.ts b/e2e/lib/JSONOptionPage.ts index ac1ae3d..d6ed7ee 100644 --- a/e2e/lib/JSONOptionPage.ts +++ b/e2e/lib/JSONOptionPage.ts @@ -9,14 +9,14 @@ export default class JSONOptionPage { } async updateSettings(value: string): Promise<void> { - let textarea = await this.webdriver.findElement(By.css('textarea')); + const textarea = await this.webdriver.findElement(By.css('textarea')); await this.webdriver.executeScript(`document.querySelector('textarea').value = '${value}'`) await textarea.sendKeys(' '); await this.webdriver.executeScript(() => document.querySelector('textarea')!!.blur()); } async getErrorMessage(): Promise<string> { - let error = await this.webdriver.findElement(By.css('.settings-ui-input-error')); + const error = await this.webdriver.findElement(By.css('.settings-ui-input-error')); return error.getText(); } } diff --git a/e2e/lib/OptionPage.ts b/e2e/lib/OptionPage.ts index c183b06..9f994a0 100644 --- a/e2e/lib/OptionPage.ts +++ b/e2e/lib/OptionPage.ts @@ -11,13 +11,13 @@ export default class OptionPage { } static async open(lanthan: Lanthan) { - let url = await lanthan.getWebExtBrowser().runtime.getURL("build/settings.html") + const url = await lanthan.getWebExtBrowser().runtime.getURL("build/settings.html") await lanthan.getWebDriver().navigate().to(url); return new OptionPage(lanthan); } async switchToForm(): Promise<FormOptionPage> { - let useFormInput = await this.webdriver.findElement(By.css('#setting-source-form')); + const useFormInput = await this.webdriver.findElement(By.css('#setting-source-form')); await useFormInput.click(); await this.webdriver.switchTo().alert().accept(); return new FormOptionPage(this.lanthan); diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts index 7a5dd7a..ad3f454 100644 --- a/e2e/lib/Page.ts +++ b/e2e/lib/Page.ts @@ -22,7 +22,7 @@ export default class Page { } async sendKeys(...keys: Array<string|number|Promise<string|number>>): Promise<void> { - let body = await this.webdriver.findElement(By.css('body')); + const body = await this.webdriver.findElement(By.css('body')); await body.sendKeys(...keys); } @@ -33,7 +33,7 @@ export default class Page { } async showConsole(): Promise<Console> { - let iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); + const iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); await this.sendKeys(':'); await this.webdriver.wait(until.elementIsVisible(iframe)); @@ -43,7 +43,7 @@ export default class Page { } async getConsole(): Promise<Console> { - let iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); + const iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); await this.webdriver.wait(until.elementIsVisible(iframe)); await this.webdriver.switchTo().frame(0); @@ -69,11 +69,11 @@ export default class Page { async waitAndGetHints(): Promise<Hint[]> { await this.webdriver.wait(until.elementsLocated(By.css('.vimvixen-hint'))); - let elements = await this.webdriver.findElements(By.css(`.vimvixen-hint`)); - let hints = []; - for (let e of elements) { - let display = await e.getCssValue('display'); - let text = await e.getText(); + const elements = await this.webdriver.findElements(By.css(`.vimvixen-hint`)); + const hints = []; + for (const e of elements) { + const display = await e.getCssValue('display'); + const text = await e.getText(); hints.push({ displayed: display !== 'none', text: text, @@ -83,7 +83,7 @@ export default class Page { } private static async waitForConsoleLoaded(webdriver: WebDriver) { - let topFrame = await webdriver.executeScript(() => window.top === window); + const topFrame = await webdriver.executeScript(() => window.top === window); if (!topFrame) { return; } diff --git a/e2e/lib/TestServer.ts b/e2e/lib/TestServer.ts index c010e37..5b9eee3 100644 --- a/e2e/lib/TestServer.ts +++ b/e2e/lib/TestServer.ts @@ -28,12 +28,12 @@ export default class TestServer { return this; } - url(path: string = '/'): string { + url(path = '/'): string { if (!this.http) { throw new Error('http server not started'); } - let addr = this.http.address() as net.AddressInfo; + const addr = this.http.address() as net.AddressInfo; return `http://${addr.address}:${addr.port}${path}` } diff --git a/e2e/lib/clipboard.ts b/e2e/lib/clipboard.ts index c1eddbb..297b71a 100644 --- a/e2e/lib/clipboard.ts +++ b/e2e/lib/clipboard.ts @@ -3,7 +3,7 @@ import { spawn } from 'child_process'; const readLinux = (): Promise<string> => { let stdout = '', stderr = ''; return new Promise((resolve) => { - let xsel = spawn('xsel', ['--clipboard', '--output']); + const xsel = spawn('xsel', ['--clipboard', '--output']); xsel.stdout.on('data', (data) => { stdout += data; }); @@ -22,7 +22,7 @@ const readLinux = (): Promise<string> => { const writeLinux = (data: string): Promise<string> => { let stderr = ''; return new Promise((resolve) => { - let xsel = spawn('xsel', ['--clipboard', '--input']); + const xsel = spawn('xsel', ['--clipboard', '--input']); xsel.stderr.on('data', (data) => { stderr += data; }); @@ -40,7 +40,7 @@ const writeLinux = (data: string): Promise<string> => { const readDarwin = (): Promise<string> => { let stdout = '', stderr = ''; return new Promise((resolve) => { - let pbpaste = spawn('pbpaste'); + const pbpaste = spawn('pbpaste'); pbpaste.stdout.on('data', (data) => { stdout += data; }); @@ -59,7 +59,7 @@ const readDarwin = (): Promise<string> => { const writeDarwin = (data: string): Promise<string> => { let stderr = ''; return new Promise((resolve) => { - let pbcopy = spawn('pbcopy'); + const pbcopy = spawn('pbcopy'); pbcopy.stderr.on('data', (data) => { stderr += data; }); diff --git a/e2e/mark.test.ts b/e2e/mark.test.ts index f9f372b..c73423b 100644 --- a/e2e/mark.test.ts +++ b/e2e/mark.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("mark test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -34,7 +34,7 @@ describe("mark test", () => { }); it('should set a local mark and jump to it', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.scrollTo(200, 200); await page.sendKeys('m', 'a'); await page.scrollTo(500, 500); @@ -63,8 +63,8 @@ describe("mark test", () => { await page.sendKeys('\'', 'A'); await eventually(async() => { - let tab = (await browser.tabs.query({ active: true }))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({ active: true }))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#first'); assert.strictEqual(await page.getScrollX(), 200); @@ -77,7 +77,7 @@ describe("mark test", () => { await page.scrollTo(500, 500); await page.sendKeys('m', 'A'); - let tab = (await browser.tabs.query({ active: true }))[0]; + const tab = (await browser.tabs.query({ active: true }))[0]; await browser.tabs.create({ url: server.url('/#second') }); await browser.tabs.remove(tab.id); @@ -92,8 +92,8 @@ describe("mark test", () => { await page.sendKeys('\'', 'A'); await eventually(async() => { - let tab = (await browser.tabs.query({ active: true }))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({ active: true }))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#first'); }); }); diff --git a/e2e/navigate.test.ts b/e2e/navigate.test.ts index 15c5a31..37f0520 100644 --- a/e2e/navigate.test.ts +++ b/e2e/navigate.test.ts @@ -9,7 +9,7 @@ import { Options as FirefoxOptions } from 'selenium-webdriver/firefox'; import Page from './lib/Page'; const newApp = () => { - let server = new TestServer(); + const server = new TestServer(); server.handle('/pagenation-a/:page', (req, res) => { res.status(200).send(` <!DOCTYPE html> @@ -44,7 +44,7 @@ const newApp = () => { }; describe("navigate test", () => { - let server = newApp(); + const server = newApp(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -52,7 +52,7 @@ describe("navigate test", () => { before(async() => { await server.start(); - let opts = (new FirefoxOptions() as any) + const opts = (new FirefoxOptions() as any) .setPreference('browser.startup.homepage', server.url('/#home')); lanthan = await Builder .forBrowser('firefox') @@ -71,42 +71,42 @@ describe("navigate test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should go to parent path without hash by gu', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c')); await page.sendKeys('g', 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/a/b/`) }); }); it('should remove hash by gu', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); await page.sendKeys('g', 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, ''); assert.strictEqual(url.pathname, `/a/b/c`) }); }); it('should go to root path by gU', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); await page.sendKeys('g', Key.SHIFT, 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/`) }); }); @@ -117,8 +117,8 @@ describe("navigate test", () => { await page.sendKeys(Key.SHIFT, 'h'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/first`) }); @@ -126,73 +126,73 @@ describe("navigate test", () => { page.sendKeys(Key.SHIFT, 'l'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/second`) }); }); it('should go previous and next page in <a> by [[ and ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); await page.sendKeys('[', '['); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-a/9'); }); }); it('should go next page in <a> by ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); await page.sendKeys(']', ']'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-a/11'); }); }); it('should go previous page in <link> by ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); await page.sendKeys('[', '['); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-link/9'); }); }); it('should go next page by in <link> by [[', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); await page.sendKeys(']', ']'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-link/11'); }); }); it('should go to home page into current tab by gh', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('g', 'h'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#home'); }); }); it('should go to home page into current tab by gH', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('g', Key.SHIFT, 'H'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); assert.strictEqual(new URL(tabs[0].url).hash, ''); assert.strictEqual(new URL(tabs[1].url).hash, '#home'); @@ -201,12 +201,12 @@ describe("navigate test", () => { }); it('should reload current tab by r', async () => { - let page = await Page.navigateTo(webdriver, server.url('/reload')); + const page = await Page.navigateTo(webdriver, server.url('/reload')); await page.scrollTo(500, 500); let before: number; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; before = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(before > 0); }); @@ -215,24 +215,24 @@ describe("navigate test", () => { let after; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; after = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(after > before); }); await eventually(async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); assert.strictEqual(await page.getScrollX(), 500); }); }); it('should reload current tab without cache by R', async () => { - let page = await Page.navigateTo(webdriver, server.url('/reload')); + const page = await Page.navigateTo(webdriver, server.url('/reload')); await page.scrollTo(500, 500); let before: number; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; before = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(before > 0); }); @@ -241,13 +241,13 @@ describe("navigate test", () => { let after; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; after = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(after > before); }); await eventually(async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); assert.strictEqual(await page.getScrollY(), 0); }); }); diff --git a/e2e/options.test.ts b/e2e/options.test.ts index f418dc3..91a3dde 100644 --- a/e2e/options.test.ts +++ b/e2e/options.test.ts @@ -9,7 +9,7 @@ import Page from './lib/Page'; import OptionPage from './lib/OptionPage'; describe("options page", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -35,15 +35,15 @@ describe("options page", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('saves current config on blur', async () => { - let page = await OptionPage.open(lanthan); - let jsonPage = await page.asJSONOptionPage(); + const page = await OptionPage.open(lanthan); + const jsonPage = await page.asJSONOptionPage(); await jsonPage.updateSettings(`{ "blacklist": [ "https://example.com" ] }`); let { settings } = await browser.storage.local.get('settings'); @@ -56,25 +56,25 @@ describe("options page", () => { assert.strictEqual(settings.source, 'json'); assert.strictEqual(settings.json, '{ "blacklist": [ "https://example.com" ] } '); - let message = await jsonPage.getErrorMessage(); + const message = await jsonPage.getErrorMessage(); assert.ok(message.startsWith('SyntaxError:')) }); it('updates keymaps without reloading', async () => { - let optionPage = await OptionPage.open(lanthan); - let jsonPage = await optionPage.asJSONOptionPage(); + const optionPage = await OptionPage.open(lanthan); + const jsonPage = await optionPage.asJSONOptionPage(); await jsonPage.updateSettings(`{ "keymaps": { "zz": { "type": "scroll.vertically", "count": 10 } } }`); await browser.tabs.create({ url: server.url(), active: false }); await new Promise((resolve) => setTimeout(resolve, 100)); - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[1]); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('zz'); await eventually(async() => { - let y = await page.getScrollY(); + const y = await page.getScrollY(); assert.strictEqual(y, 640); }); }) diff --git a/e2e/options_form.test.ts b/e2e/options_form.test.ts index c3dc5fb..2121348 100644 --- a/e2e/options_form.test.ts +++ b/e2e/options_form.test.ts @@ -15,8 +15,8 @@ describe("options form page", () => { .build(); browser = lanthan.getWebExtBrowser(); - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); @@ -28,18 +28,16 @@ describe("options form page", () => { }); it('switch to form settings', async () => { - let page = await OptionPage.open(lanthan); + const page = await OptionPage.open(lanthan); await page.switchToForm(); - let { settings } = await browser.storage.local.get('settings'); + const { settings } = await browser.storage.local.get('settings'); assert.strictEqual(settings.source, 'form') }); it('add blacklist item', 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); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; @@ -65,10 +63,8 @@ describe("options form page", () => { }); it('add a partial blacklist item', 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); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; @@ -112,8 +108,8 @@ describe("options form page", () => { }); it('add search engines', async () => { - let page = await OptionPage.open(lanthan); - let forms = await page.switchToForm(); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; diff --git a/e2e/partial_blacklist.test.ts b/e2e/partial_blacklist.test.ts index 950bb39..cb66549 100644 --- a/e2e/partial_blacklist.test.ts +++ b/e2e/partial_blacklist.test.ts @@ -9,7 +9,7 @@ import Settings from '../src/shared/settings/Settings'; import SettingRepository from './lib/SettingRepository'; describe("partial blacklist test", () => { - let server = new TestServer().receiveContent('/*', + const server = new TestServer().receiveContent('/*', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -25,7 +25,7 @@ describe("partial blacklist test", () => { browser = lanthan.getWebExtBrowser(); await server.start(); - let url = server.url().replace('http://', ''); + const url = server.url().replace('http://', ''); await new SettingRepository(browser).saveJSON(Settings.fromJSON({ keymaps: { j: { type: 'scroll.vertically', count: 1 }, @@ -45,7 +45,7 @@ describe("partial blacklist test", () => { }); it('should disable keys in the partial blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/')); + const page = await Page.navigateTo(webdriver, server.url('/')); await page.sendKeys('j'); let scrollY = await page.getScrollY(); diff --git a/e2e/repeat.test.ts b/e2e/repeat.test.ts index b62272f..7c8b5e2 100644 --- a/e2e/repeat.test.ts +++ b/e2e/repeat.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("tab test", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -32,11 +32,11 @@ describe("tab test", () => { it('repeats last command', async () => { let page = await Page.navigateTo(webdriver, server.url()); - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand(`tabopen ${server.url('/newtab')}`); await eventually(async() => { - let current = await browser.tabs.query({ url: `*://*/newtab` }); + const current = await browser.tabs.query({ url: `*://*/newtab` }); assert.strictEqual(current.length, 1); }); @@ -44,7 +44,7 @@ describe("tab test", () => { await page.sendKeys('.'); await eventually(async() => { - let current = await browser.tabs.query({ url: `*://*/newtab` }); + const current = await browser.tabs.query({ url: `*://*/newtab` }); assert.strictEqual(current.length, 2); }); }); @@ -53,13 +53,13 @@ describe("tab test", () => { for (let i = 1; i < 5; ++i) { await browser.tabs.create({ url: server.url('/#' + i) }); } - let before = await browser.tabs.query({}); + const before = await browser.tabs.query({}); let page = await Page.currentContext(webdriver); await page.sendKeys('d'); await eventually(async() => { - let current = await browser.tabs.query({}); + const current = await browser.tabs.query({}); assert.strictEqual(current.length, before.length - 1); }); @@ -68,7 +68,7 @@ describe("tab test", () => { await page.sendKeys('.'); await eventually(async() => { - let current = await browser.tabs.query({}); + const current = await browser.tabs.query({}); assert.strictEqual(current.length, before.length - 2); }); }); diff --git a/e2e/repeat_n_times.test.ts b/e2e/repeat_n_times.test.ts new file mode 100644 index 0000000..a646112 --- /dev/null +++ b/e2e/repeat_n_times.test.ts @@ -0,0 +1,60 @@ +import * as path from 'path'; +import * as assert from 'assert'; + +import TestServer from './lib/TestServer'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver } from 'selenium-webdriver'; +import Page from './lib/Page'; + +describe("tab test", () => { + const server = new TestServer().receiveContent('/', + `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, + ); + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + + before(async() => { + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); + await server.start(); + + browser = browser; + }); + + after(async() => { + await server.stop(); + if (lanthan) { + await lanthan.quit(); + } + }); + + it('repeats scroll 3-times', async () => { + const page = await Page.navigateTo(webdriver, server.url()); + await page.sendKeys('3', 'j'); + + const scrollY = await page.getScrollY(); + assert.strictEqual(scrollY, 64 * 3); + }); + + it('repeats tab deletion 3-times', async () => { + const win = await browser.windows.create({ url: server.url('/#0') }); + for (let i = 1; i < 5; ++i) { + await browser.tabs.create({ url: server.url('/#' + i), windowId: win.id }); + await webdriver.navigate().to(server.url('/#' + i)); + } + + const page = await Page.navigateTo(webdriver, server.url()); + await page.sendKeys('3', 'd'); + + await eventually(async() => { + const current = await browser.tabs.query({ windowId: win.id }); + assert.strictEqual(current.length, 2); + }); + }); +}); diff --git a/e2e/scroll.test.ts b/e2e/scroll.test.ts index 5145265..9b39a2e 100644 --- a/e2e/scroll.test.ts +++ b/e2e/scroll.test.ts @@ -7,7 +7,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("scroll test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -39,7 +39,7 @@ describe("scroll test", () => { it('scrolls up by j', async () => { await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64); }); @@ -47,7 +47,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 200)); await page.sendKeys('k'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 136); }); @@ -55,7 +55,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(100, 100)); await page.sendKeys('h'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.strictEqual(pageXOffset, 36); }); @@ -63,7 +63,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(100, 100)); await page.sendKeys('l'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.strictEqual(pageXOffset, 164); }); @@ -71,7 +71,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys('g', 'g'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 0); }); @@ -79,7 +79,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, 'g'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.ok(scrollY > 5000); }); @@ -87,7 +87,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, '0'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.ok(pageXOffset === 0); }); @@ -95,7 +95,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, '$'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.ok(pageXOffset > 5000); }); @@ -103,8 +103,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'u'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 - Math.floor(pageHeight / 2))) < 5); }); @@ -112,8 +112,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'd'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 + Math.floor(pageHeight / 2))) < 5); }); @@ -121,8 +121,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'b'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 - pageHeight)) < 5); }); @@ -130,8 +130,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'f'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 + pageHeight)) < 5); }); }); diff --git a/e2e/tab.test.ts b/e2e/tab.test.ts index 1a5dd5c..6a8e815 100644 --- a/e2e/tab.test.ts +++ b/e2e/tab.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("tab test", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -48,11 +48,11 @@ describe("tab test", () => { it('deletes tab and selects right by d', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('d'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); assert.strictEqual(current[3].active, true); assert.strictEqual(current[3].id, tabs[4].id); @@ -61,11 +61,11 @@ describe("tab test", () => { it('deletes tab and selects left by D', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'D'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); assert.strictEqual(current[2].active, true); assert.strictEqual(current[2].id, tabs[2].id); @@ -74,20 +74,20 @@ describe("tab test", () => { it('deletes all tabs to the right by x$', async () => { await browser.tabs.update(tabs[1].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('x', '$'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, 2); }); it('duplicates tab by zd', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('z', 'd'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); current.sort((t1: any, t2: any) => t1.index - t2.index); assert.strictEqual(current.length, tabs.length + 1); assert.strictEqual(current[0].url, current[1].url); @@ -96,64 +96,64 @@ describe("tab test", () => { it('makes pinned by zp', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('z', 'p'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].pinned, true); }); it('selects previous tab by K', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'K'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[1].active, true); }); it('selects previous tab by K rotatory', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'K'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[current.length - 1].active, true) }); it('selects next tab by J', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'J'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[3].active, true); }); it('selects previous tab by J rotatory', async () => { await browser.tabs.update(tabs[tabs.length - 1].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'J'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].active, true) }); it('selects first tab by g0', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', '0'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].active, true) }); it('selects last tab by g$', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', '$'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[current.length - 1].active, true) }); @@ -161,10 +161,10 @@ describe("tab test", () => { await browser.tabs.update(tabs[1].id, { active: true }); await browser.tabs.update(tabs[4].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.CONTROL, '6'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[1].active, true) }); @@ -172,38 +172,38 @@ describe("tab test", () => { // This might be a bug in Firefox. it.skip('reopen tab by u', async () => { await browser.tabs.remove(tabs[1].id); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('u'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length); }); it('does not delete pinned tab by d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('d'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length); }); it('deletes pinned tab by !d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('!', 'd'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); }); it('opens view-source by gf', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', 'f'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length + 1); assert.strictEqual(current[current.length - 1].url, `view-source:${server.url('/#0')}`); }); diff --git a/e2e/zoom.test.ts b/e2e/zoom.test.ts index af5cc68..d089097 100644 --- a/e2e/zoom.test.ts +++ b/e2e/zoom.test.ts @@ -33,21 +33,21 @@ describe("zoom test", () => { }); it('should zoom in by zi', async () => { - let before = await browser.tabs.getZoom(tab.id); + const before = await browser.tabs.getZoom(tab.id); await page.sendKeys('zi'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.ok(before < actual); }); }); it('should zoom out by zo', async () => { - let before = await browser.tabs.getZoom(tab.id); + const before = await browser.tabs.getZoom(tab.id); await page.sendKeys('zo'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.ok(before > actual); }); }); @@ -57,7 +57,7 @@ describe("zoom test", () => { await page.sendKeys('zz'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.strictEqual(actual, 1); }); }); |