|
|
@ -1,30 +1,30 @@ |
|
|
|
const express = require('express'); |
|
|
|
import express from 'express'; |
|
|
|
const lanthan = require('lanthan'); |
|
|
|
import * as path from 'path'; |
|
|
|
const path = require('path'); |
|
|
|
import * as assert from 'assert'; |
|
|
|
const assert = require('assert'); |
|
|
|
import * as http from 'http'; |
|
|
|
const eventually = require('./eventually'); |
|
|
|
|
|
|
|
const { Builder } = require('lanthan'); |
|
|
|
import eventually from './eventually'; |
|
|
|
const { Key, By } = require('selenium-webdriver'); |
|
|
|
import { Builder, Lanthan } from 'lanthan'; |
|
|
|
|
|
|
|
import { WebDriver, By, Key } from 'selenium-webdriver'; |
|
|
|
|
|
|
|
|
|
|
|
const newApp = () => { |
|
|
|
const newApp = () => { |
|
|
|
let app = express(); |
|
|
|
let app = express(); |
|
|
|
app.get('/', (req, res) => { |
|
|
|
app.get('/', (_req, res) => { |
|
|
|
res.send('ok'); |
|
|
|
res.send('ok'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
return app; |
|
|
|
return app; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
describe("tab test", () => { |
|
|
|
describe("tab test", () => { |
|
|
|
|
|
|
|
|
|
|
|
const port = 12321; |
|
|
|
const port = 12321; |
|
|
|
const url = `http://127.0.0.1:${port}/`; |
|
|
|
const url = `http://127.0.0.1:${port}/`; |
|
|
|
|
|
|
|
|
|
|
|
let http; |
|
|
|
let http: http.Server; |
|
|
|
let lanthan; |
|
|
|
let lanthan: Lanthan; |
|
|
|
let webdriver |
|
|
|
let webdriver: WebDriver; |
|
|
|
let browser; |
|
|
|
let browser: any; |
|
|
|
let win; |
|
|
|
let win: any; |
|
|
|
let tabs; |
|
|
|
let tabs: any[]; |
|
|
|
|
|
|
|
|
|
|
|
before(async() => { |
|
|
|
before(async() => { |
|
|
|
lanthan = await Builder |
|
|
|
lanthan = await Builder |
|
|
@ -52,7 +52,7 @@ describe("tab test", () => { |
|
|
|
await webdriver.navigate().to(`${url}#${i}`); |
|
|
|
await webdriver.navigate().to(`${url}#${i}`); |
|
|
|
} |
|
|
|
} |
|
|
|
tabs = await browser.tabs.query({ windowId: win.id }); |
|
|
|
tabs = await browser.tabs.query({ windowId: win.id }); |
|
|
|
tabs.sort((t1, t2) => t1.index - t2.index); |
|
|
|
tabs.sort((t1: any, t2: any) => t1.index - t2.index); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
afterEach(async() => { |
|
|
|
afterEach(async() => { |
|
|
@ -65,9 +65,9 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('d'); |
|
|
|
await body.sendKeys('d'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length - 1); |
|
|
|
assert.ok(current.length === tabs.length - 1); |
|
|
|
assert(current[3].active); |
|
|
|
assert.ok(current[3].active); |
|
|
|
assert(current[3].url === tabs[4].url); |
|
|
|
assert.ok(current[3].url === tabs[4].url); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('deletes tab and selects left by D', async () => { |
|
|
|
it('deletes tab and selects left by D', async () => { |
|
|
@ -77,9 +77,9 @@ describe("tab test", () => { |
|
|
|
|
|
|
|
|
|
|
|
await eventually(async() => { |
|
|
|
await eventually(async() => { |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length - 1); |
|
|
|
assert.ok(current.length === tabs.length - 1); |
|
|
|
assert(current[2].active); |
|
|
|
assert.ok(current[2].active); |
|
|
|
assert(current[2].url === tabs[2].url); |
|
|
|
assert.ok(current[2].url === tabs[2].url); |
|
|
|
}) |
|
|
|
}) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -89,7 +89,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('x', '$'); |
|
|
|
await body.sendKeys('x', '$'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === 2); |
|
|
|
assert.ok(current.length === 2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('duplicates tab by zd', async () => { |
|
|
|
it('duplicates tab by zd', async () => { |
|
|
@ -99,9 +99,9 @@ describe("tab test", () => { |
|
|
|
|
|
|
|
|
|
|
|
await eventually(async() => { |
|
|
|
await eventually(async() => { |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
current.sort((t1, t2) => t1.index - t2.index); |
|
|
|
current.sort((t1: any, t2: any) => t1.index - t2.index); |
|
|
|
assert(current.length === tabs.length + 1); |
|
|
|
assert.ok(current.length === tabs.length + 1); |
|
|
|
assert(current[0].url === current[1].url); |
|
|
|
assert.ok(current[0].url === current[1].url); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('z', 'p'); |
|
|
|
await body.sendKeys('z', 'p'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[0].pinned); |
|
|
|
assert.ok(current[0].pinned); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects previous tab by K', async () => { |
|
|
|
it('selects previous tab by K', async () => { |
|
|
@ -120,7 +120,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys(Key.SHIFT, 'K'); |
|
|
|
await body.sendKeys(Key.SHIFT, 'K'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[1].active); |
|
|
|
assert.ok(current[1].active); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects previous tab by K rotatory', async () => { |
|
|
|
it('selects previous tab by K rotatory', async () => { |
|
|
@ -129,7 +129,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys(Key.SHIFT, 'K'); |
|
|
|
await body.sendKeys(Key.SHIFT, 'K'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[current.length - 1].active) |
|
|
|
assert.ok(current[current.length - 1].active) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects next tab by J', async () => { |
|
|
|
it('selects next tab by J', async () => { |
|
|
@ -138,7 +138,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys(Key.SHIFT, 'J'); |
|
|
|
await body.sendKeys(Key.SHIFT, 'J'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[3].active); |
|
|
|
assert.ok(current[3].active); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects previous tab by J rotatory', async () => { |
|
|
|
it('selects previous tab by J rotatory', async () => { |
|
|
@ -147,7 +147,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys(Key.SHIFT, 'J'); |
|
|
|
await body.sendKeys(Key.SHIFT, 'J'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[0].active) |
|
|
|
assert.ok(current[0].active) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects first tab by g0', async () => { |
|
|
|
it('selects first tab by g0', async () => { |
|
|
@ -156,7 +156,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('g', '0'); |
|
|
|
await body.sendKeys('g', '0'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[0].active) |
|
|
|
assert.ok(current[0].active) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects last tab by g$', async () => { |
|
|
|
it('selects last tab by g$', async () => { |
|
|
@ -165,7 +165,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('g', '$'); |
|
|
|
await body.sendKeys('g', '$'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[current.length - 1].active) |
|
|
|
assert.ok(current[current.length - 1].active) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('selects last selected tab by <C-6>', async () => { |
|
|
|
it('selects last selected tab by <C-6>', async () => { |
|
|
@ -176,7 +176,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys(Key.CONTROL, '6'); |
|
|
|
await body.sendKeys(Key.CONTROL, '6'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current[1].active) |
|
|
|
assert.ok(current[1].active) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// browser.sessions.getRecentlyClosed() sometime throws "An unexpected error occurred"
|
|
|
|
// browser.sessions.getRecentlyClosed() sometime throws "An unexpected error occurred"
|
|
|
@ -187,7 +187,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('u'); |
|
|
|
await body.sendKeys('u'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length); |
|
|
|
assert.ok(current.length === tabs.length); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('does not delete pinned tab by d', async () => { |
|
|
|
it('does not delete pinned tab by d', async () => { |
|
|
@ -196,7 +196,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('d'); |
|
|
|
await body.sendKeys('d'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length); |
|
|
|
assert.ok(current.length === tabs.length); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('deletes pinned tab by !d', async () => { |
|
|
|
it('deletes pinned tab by !d', async () => { |
|
|
@ -205,7 +205,7 @@ describe("tab test", () => { |
|
|
|
await body.sendKeys('!', 'd'); |
|
|
|
await body.sendKeys('!', 'd'); |
|
|
|
|
|
|
|
|
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length - 1); |
|
|
|
assert.ok(current.length === tabs.length - 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('opens view-source by gf', async () => { |
|
|
|
it('opens view-source by gf', async () => { |
|
|
@ -215,8 +215,8 @@ describe("tab test", () => { |
|
|
|
|
|
|
|
|
|
|
|
await eventually(async() => { |
|
|
|
await eventually(async() => { |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
let current = await browser.tabs.query({ windowId: win.id }); |
|
|
|
assert(current.length === tabs.length + 1); |
|
|
|
assert.ok(current.length === tabs.length + 1); |
|
|
|
assert(current[current.length - 1].url === `view-source:${url}#0`); |
|
|
|
assert.ok(current[current.length - 1].url === `view-source:${url}#0`); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |