diff options
Diffstat (limited to 'e2e/lib')
-rw-r--r-- | e2e/lib/Console.ts | 20 | ||||
-rw-r--r-- | e2e/lib/FormOptionPage.ts | 22 | ||||
-rw-r--r-- | e2e/lib/JSONOptionPage.ts | 4 | ||||
-rw-r--r-- | e2e/lib/OptionPage.ts | 4 | ||||
-rw-r--r-- | e2e/lib/Page.ts | 18 | ||||
-rw-r--r-- | e2e/lib/TestServer.ts | 4 | ||||
-rw-r--r-- | e2e/lib/clipboard.ts | 8 |
7 files changed, 40 insertions, 40 deletions
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; }); |