A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.4 KiB
95 lines
2.4 KiB
5 years ago
|
import express from 'express';
|
||
|
import * as path from 'path';
|
||
|
import * as assert from 'assert';
|
||
|
import * as http from 'http';
|
||
|
|
||
|
import eventually from './eventually';
|
||
|
import { Builder, Lanthan } from 'lanthan';
|
||
|
import { WebDriver, By, Key } from 'selenium-webdriver';
|
||
|
|
||
6 years ago
|
|
||
|
const newApp = () => {
|
||
|
let app = express();
|
||
5 years ago
|
app.get('/', (_req, res) => {
|
||
6 years ago
|
res.send('ok');
|
||
|
});
|
||
|
return app;
|
||
|
};
|
||
|
|
||
|
describe("tab test", () => {
|
||
|
const port = 12321;
|
||
|
const url = `http://127.0.0.1:${port}/`;
|
||
|
|
||
5 years ago
|
let http: http.Server;
|
||
|
let lanthan: Lanthan;
|
||
|
let webdriver: WebDriver;
|
||
|
let browser: any;
|
||
6 years ago
|
|
||
|
before(async() => {
|
||
5 years ago
|
lanthan = await Builder
|
||
|
.forBrowser('firefox')
|
||
|
.spyAddon(path.join(__dirname, '..'))
|
||
|
.build();
|
||
|
webdriver = lanthan.getWebDriver();
|
||
|
browser = lanthan.getWebExtBrowser();
|
||
6 years ago
|
http = newApp().listen(port);
|
||
|
|
||
5 years ago
|
await webdriver.navigate().to(`${url}`);
|
||
6 years ago
|
});
|
||
|
|
||
|
after(async() => {
|
||
5 years ago
|
if (http) {
|
||
|
http.close();
|
||
|
}
|
||
|
if (lanthan) {
|
||
|
await lanthan.quit();
|
||
6 years ago
|
}
|
||
|
});
|
||
|
|
||
|
it('repeats last operation', async () => {
|
||
5 years ago
|
let body = await webdriver.findElement(By.css('body'));
|
||
6 years ago
|
await body.sendKeys(':');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
|
let input = await webdriver.findElement(By.css('input'));
|
||
|
input.sendKeys(`tabopen ${url}newtab`, Key.ENTER);
|
||
6 years ago
|
|
||
|
await eventually(async() => {
|
||
|
let current = await browser.tabs.query({ url: `*://*/newtab` });
|
||
|
assert.equal(current.length, 1);
|
||
|
});
|
||
|
|
||
5 years ago
|
body = await webdriver.findElement(By.css('body'));
|
||
6 years ago
|
await body.sendKeys('.');
|
||
|
|
||
|
await eventually(async() => {
|
||
|
let current = await browser.tabs.query({ url: `*://*/newtab` });
|
||
|
assert.equal(current.length, 2);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('repeats last operation', async () => {
|
||
|
for (let i = 1; i < 5; ++i) {
|
||
|
await browser.tabs.create({ url: `${url}#${i}` });
|
||
|
}
|
||
|
let before = await browser.tabs.query({});
|
||
|
|
||
5 years ago
|
let body = await webdriver.findElement(By.css('body'));
|
||
6 years ago
|
await body.sendKeys('d');
|
||
|
|
||
|
await eventually(async() => {
|
||
|
let current = await browser.tabs.query({});
|
||
|
assert.equal(current.length, before.length - 1);
|
||
|
});
|
||
|
|
||
|
await browser.tabs.update(before[2].id, { active: true });
|
||
5 years ago
|
body = await webdriver.findElement(By.css('body'));
|
||
6 years ago
|
await body.sendKeys('.');
|
||
|
|
||
|
await eventually(async() => {
|
||
|
let current = await browser.tabs.query({});
|
||
|
assert.equal(current.length, before.length - 2);
|
||
|
});
|
||
|
});
|
||
|
});
|