Migrate e2e tests to TypeScript

jh-changes
Shin'ya Ueoka 5 years ago
parent 91f8383ecc
commit 7e77e31ad6
  1. 24
      e2e/blacklist.test.ts
  2. 32
      e2e/clipboard.test.ts
  3. 24
      e2e/command_addbookmark.test.ts
  4. 30
      e2e/command_bdelete.test.ts
  5. 24
      e2e/command_buffer.test.ts
  6. 30
      e2e/command_open.test.ts
  7. 23
      e2e/command_quit.test.ts
  8. 31
      e2e/command_tabopen.test.ts
  9. 30
      e2e/command_winopen.test.ts
  10. 48
      e2e/completion.test.ts
  11. 86
      e2e/completion_buffers.test.ts
  12. 57
      e2e/completion_open.test.ts
  13. 36
      e2e/completion_set.test.ts
  14. 42
      e2e/console.test.ts
  15. 23
      e2e/eventually.js
  16. 30
      e2e/eventually.ts
  17. 46
      e2e/follow.test.ts
  18. 38
      e2e/follow_properties.test.ts
  19. 30
      e2e/lib/Console.ts
  20. 53
      e2e/lib/clipboard.ts
  21. 30
      e2e/mark.test.ts
  22. 44
      e2e/navigate.test.ts
  23. 27
      e2e/options.test.ts
  24. 20
      e2e/options_form.test.ts
  25. 29
      e2e/repeat.test.ts
  26. 69
      e2e/scroll.test.ts
  27. 4
      e2e/settings.ts
  28. 78
      e2e/tab.test.ts
  29. 29
      e2e/zoom.test.ts

@ -1,13 +1,13 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, By } from 'selenium-webdriver';
import * as http from 'http';
const newApp = () => {
let app = express();
app.get('/*', (req, res) => {
app.get('/*', (_req, res) => {
res.status(200).send(`<!DOCTYPEhtml>
<html lang="en">
<body style="width:10000px; height:10000px"></body>
@ -17,12 +17,11 @@ const newApp = () => {
};
describe("navigate test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -73,4 +72,3 @@ describe("navigate test", () => {
assert.equal(pageYOffset, 64);
});
});

@ -1,15 +1,17 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const clipboard = require('./lib/clipboard');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import eventually from './eventually';
import * as clipboard from './lib/clipboard';
import settings from './settings';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.status(200).send(`<html lang="en"></html">`);
});
return app;
@ -18,10 +20,10 @@ const newApp = () => {
describe("navigate test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -85,7 +87,7 @@ describe("navigate test", () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/`,
`http://127.0.0.1:${port}/#open_to_new_tab`,
]);
@ -114,7 +116,7 @@ describe("navigate test", () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/`,
`http://127.0.0.1:${port}/google?q=an%20apple`,
]);

@ -1,13 +1,15 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
app.get('/happy', (req, res) => {
app.get('/happy', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<head>
@ -20,10 +22,10 @@ const newApp = () => {
describe('addbookmark command test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);

@ -1,9 +1,11 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
@ -21,10 +23,10 @@ const newApp = () => {
describe('bdelete/bdeletes command test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -74,7 +76,7 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/site1`,
`http://127.0.0.1:${port}/site2`,
`http://127.0.0.1:${port}/site3`,
@ -137,7 +139,7 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/site1`,
`http://127.0.0.1:${port}/site2`,
`http://127.0.0.1:${port}/site3`,
@ -156,7 +158,7 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/site2`,
`http://127.0.0.1:${port}/site3`,
`http://127.0.0.1:${port}/site4`,
@ -175,7 +177,7 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map(t => t.url), [
assert.deepEqual(tabs.map((t: any) => t.url), [
`http://127.0.0.1:${port}/site1`,
`http://127.0.0.1:${port}/site2`,
`http://127.0.0.1:${port}/site3`,

@ -1,9 +1,11 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
@ -21,10 +23,10 @@ const newApp = () => {
describe('buffer command test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -105,7 +107,7 @@ describe('buffer command test', () => {
assert.equal(text, 'tab 0 does not exist');
});
await webdriver.switchTo().parentFrame();
await (webdriver.switchTo() as any).parentFrame();
body = await webdriver.findElement(By.css('body'));
await body.sendKeys(':');

@ -1,23 +1,25 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
app.get('/' + name, (req, res) => {
app.get('/' + name, (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
</html">`);
});
}
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>home</h1></body>
@ -28,11 +30,11 @@ const newApp = () => {
describe("open command test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
lanthan = await Builder

@ -1,9 +1,12 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
@ -21,10 +24,10 @@ const newApp = () => {
describe('quit/quitall command test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);

@ -1,23 +1,26 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
app.get('/' + name, (req, res) => {
app.get('/' + name, (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
</html">`);
});
}
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>home</h1></body>
@ -28,11 +31,11 @@ const newApp = () => {
describe("tabopen command test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
http = newApp().listen(port);

@ -1,23 +1,25 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) {
app.get('/' + name, (req, res) => {
app.get('/' + name, (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>${name.charAt(0).toUpperCase() + name.slice(1)}</h1></body>
</html">`);
});
}
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><h1>home</h1></body>
@ -28,11 +30,11 @@ const newApp = () => {
describe("winopen command test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
http = newApp().listen(port);

@ -1,15 +1,17 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
const Console = require('./lib/Console');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
import { Console } from './lib/Console';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>ok</body>
@ -20,11 +22,11 @@ const newApp = () => {
describe("general completion test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
lanthan = await Builder
@ -62,9 +64,9 @@ describe("general completion test", () => {
let items = await c.getCompletions();
assert.equal(items.length, 10);
assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
assert(items[1].text.startsWith('set'))
assert(items[2].text.startsWith('open'))
assert(items[3].text.startsWith('tabopen'))
assert.ok(items[1].text.startsWith('set'))
assert.ok(items[2].text.startsWith('open'))
assert.ok(items[3].text.startsWith('tabopen'))
});
});
@ -79,9 +81,9 @@ describe("general completion test", () => {
let items = await c.getCompletions();
assert.equal(items.length, 4);
assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
assert(items[1].text.startsWith('buffer'))
assert(items[2].text.startsWith('bdelete'))
assert(items[3].text.startsWith('bdeletes'))
assert.ok(items[1].text.startsWith('buffer'))
assert.ok(items[2].text.startsWith('bdelete'))
assert.ok(items[3].text.startsWith('bdeletes'))
});
});
@ -100,7 +102,7 @@ describe("general completion test", () => {
await c.sendKeys(Key.TAB);
await eventually(async() => {
let items = await c.getCompletions();
assert(items[1].highlight)
assert.ok(items[1].highlight)
let v = await c.currentValue();
assert.equal(v, 'buffer');
@ -109,7 +111,7 @@ describe("general completion test", () => {
await c.sendKeys(Key.TAB, Key.TAB);
await eventually(async() => {
let items = await c.getCompletions();
assert(items[3].highlight)
assert.ok(items[3].highlight)
let v = await c.currentValue();
assert.equal(v, 'bdeletes');
@ -124,7 +126,7 @@ describe("general completion test", () => {
await c.sendKeys(Key.SHIFT, Key.TAB);
await eventually(async() => {
let items = await c.getCompletions();
assert(items[3].highlight)
assert.ok(items[3].highlight)
let v = await c.currentValue();
assert.equal(v, 'bdeletes');

@ -1,11 +1,13 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const Console = require('./lib/Console');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By } from 'selenium-webdriver';
import { Console } from './lib/Console';
const newApp = () => {
@ -24,11 +26,11 @@ const newApp = () => {
describe("completion on buffer/bdelete/bdeletes", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
lanthan = await Builder
@ -85,14 +87,14 @@ describe("completion on buffer/bdelete/bdeletes", () => {
let items = await c.getCompletions();
assert.equal(items.length, 6);
assert.deepEqual(items[0], { type: 'title', text: 'Buffers' });
assert(items[1].text.startsWith('1:'));
assert(items[2].text.startsWith('2:'));
assert(items[3].text.startsWith('3:'));
assert(items[4].text.startsWith('4:'));
assert(items[5].text.startsWith('5:'));
assert(items[3].text.includes('%'));
assert(items[5].text.includes('#'));
assert.ok(items[1].text.startsWith('1:'));
assert.ok(items[2].text.startsWith('2:'));
assert.ok(items[3].text.startsWith('3:'));
assert.ok(items[4].text.startsWith('4:'));
assert.ok(items[5].text.startsWith('5:'));
assert.ok(items[3].text.includes('%'));
assert.ok(items[5].text.includes('#'));
});
})
@ -106,9 +108,9 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.deepEqual(items[0], { type: 'title', text: 'Buffers' });
assert(items[1].text.startsWith('2:'));
assert(items[1].text.includes('title_site2'));
assert(items[1].text.includes(`http://127.0.0.1:${port}/site2`));
assert.ok(items[1].text.startsWith('2:'));
assert.ok(items[1].text.includes('title_site2'));
assert.ok(items[1].text.includes(`http://127.0.0.1:${port}/site2`));
});
})
@ -122,7 +124,7 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.deepEqual(items[0], { type: 'title', text: 'Buffers' });
assert(items[1].text.startsWith('2:'));
assert.ok(items[1].text.startsWith('2:'));
});
})
@ -137,7 +139,7 @@ describe("completion on buffer/bdelete/bdeletes", () => {
let items = await c.getCompletions();
assert.equal(items.length, 2);
assert.deepEqual(items[0], { type: 'title', text: 'Buffers' });
assert(items[1].text.startsWith('2:'));
assert.ok(items[1].text.startsWith('2:'));
});
})
@ -151,9 +153,9 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.equal(items.length, 4);
assert(items[1].text.includes('site3'));
assert(items[2].text.includes('site4'));
assert(items[3].text.includes('site5'));
assert.ok(items[1].text.includes('site3'));
assert.ok(items[2].text.includes('site4'));
assert.ok(items[3].text.includes('site5'));
});
})
@ -167,9 +169,9 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.equal(items.length, 4);
assert(items[1].text.includes('site3'));
assert(items[2].text.includes('site4'));
assert(items[3].text.includes('site5'));
assert.ok(items[1].text.includes('site3'));
assert.ok(items[2].text.includes('site4'));
assert.ok(items[3].text.includes('site5'));
});
})
@ -183,11 +185,11 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.equal(items.length, 6);
assert(items[1].text.includes('site1'));
assert(items[2].text.includes('site2'));
assert(items[3].text.includes('site3'));
assert(items[4].text.includes('site4'));
assert(items[5].text.includes('site5'));
assert.ok(items[1].text.includes('site1'));
assert.ok(items[2].text.includes('site2'));
assert.ok(items[3].text.includes('site3'));
assert.ok(items[4].text.includes('site4'));
assert.ok(items[5].text.includes('site5'));
});
})
@ -201,11 +203,11 @@ describe("completion on buffer/bdelete/bdeletes", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.equal(items.length, 6);
assert(items[1].text.includes('site1'));
assert(items[2].text.includes('site2'));
assert(items[3].text.includes('site3'));
assert(items[4].text.includes('site4'));
assert(items[5].text.includes('site5'));
assert.ok(items[1].text.includes('site1'));
assert.ok(items[2].text.includes('site2'));
assert.ok(items[3].text.includes('site3'));
assert.ok(items[4].text.includes('site4'));
assert.ok(items[5].text.includes('site5'));
});
})
});

@ -1,17 +1,18 @@
const express = require('express');
const lanthan = require('lanthan');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const { Builder } = require('lanthan');
const { By, Key } = require('selenium-webdriver');
const Console = require('./lib/Console');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
import { Console } from './lib/Console';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>ok</body>
@ -22,11 +23,11 @@ const newApp = () => {
describe("completion on open/tabopen/winopen commands", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
lanthan = await Builder
@ -66,9 +67,9 @@ describe("completion on open/tabopen/winopen commands", () => {
await eventually(async() => {
let completions = await c.getCompletions();
assert(completions.find(x => x.type === 'title' && x.text === 'Search Engines'));
assert(completions.find(x => x.type === 'title' && x.text === 'Bookmarks'));
assert(completions.find(x => x.type === 'title' && x.text === 'History'));
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'));
});
});
@ -82,7 +83,7 @@ describe("completion on open/tabopen/winopen commands", () => {
await eventually(async() => {
let completions = await c.getCompletions();
let items = completions.filter(x => x.type === 'item').map(x => x.text);
assert(items.every(x => x.includes('https://')));
assert.ok(items.every(x => x.includes('https://')));
});
})
@ -96,7 +97,7 @@ describe("completion on open/tabopen/winopen commands", () => {
await eventually(async() => {
let completions = await c.getCompletions();
let items = completions.filter(x => x.type === 'item').map(x => x.text);
assert(items.every(x => x.toLowerCase().includes('getting')));
assert.ok(items.every(x => x.toLowerCase().includes('getting')));
});
})
@ -110,7 +111,7 @@ describe("completion on open/tabopen/winopen commands", () => {
await eventually(async() => {
let completions = await c.getCompletions();
let items = completions.filter(x => x.type === 'item').map(x => x.text);
assert(items.every(x => x.includes('https://')));
assert.ok(items.every(x => x.includes('https://')));
});
})
@ -124,22 +125,22 @@ describe("completion on open/tabopen/winopen commands", () => {
await eventually(async() => {
let completions = await c.getCompletions();
let items = completions.filter(x => x.type === 'item').map(x => x.text);
assert(items.every(x => x.includes('https://')));
assert.ok(items.every(x => x.includes('https://')));
});
})
it('should display only specified items in "complete" property by set command', async() => {
let c = new Console(webdriver);
const execCommand = async(line) => {
const execCommand = async(line: string) => {
await body.sendKeys(':');
await webdriver.switchTo().frame(0);
await c.sendKeys(line, Key.ENTER);
await new Promise(resolve => setTimeout(resolve, 100));
await webdriver.switchTo().parentFrame();
await (webdriver.switchTo() as any).parentFrame();
}
const typeCommand = async(...keys) => {
const typeCommand = async(...keys: string[]) => {
await body.sendKeys(':');
await webdriver.switchTo().frame(0);
await c.sendKeys(...keys);
@ -148,7 +149,7 @@ describe("completion on open/tabopen/winopen commands", () => {
const cancel = async() => {
await c.sendKeys(Key.ESCAPE);
await new Promise(resolve => setTimeout(resolve, 100));
await webdriver.switchTo().parentFrame();
await (webdriver.switchTo() as any).parentFrame();
}
await execCommand('set complete=sbh');
@ -191,7 +192,7 @@ describe("completion on open/tabopen/winopen commands", () => {
let c = new Console(webdriver);
const typeCommand = async(...keys) => {
const typeCommand = async(...keys: string[]) => {
await body.sendKeys(':');
await webdriver.switchTo().frame(0);
await c.sendKeys(...keys);
@ -200,7 +201,7 @@ describe("completion on open/tabopen/winopen commands", () => {
const cancel = async() => {
await c.sendKeys(Key.ESCAPE);
await new Promise(resolve => setTimeout(resolve, 100));
await webdriver.switchTo().parentFrame();
await (webdriver.switchTo() as any).parentFrame();
}
await browser.storage.local.set({ settings: {

@ -1,19 +1,17 @@
const express = require('express');
const lanthan = require('lanthan');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
const Console = require('./lib/Console');
const { Builder } = require('lanthan');
const { By } = require('selenium-webdriver');
import * as path from 'path';
import * as assert from 'assert';
import settings from './settings';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By } from 'selenium-webdriver';
import { Console } from './lib/Console';
describe("completion on set commands", () => {
const port = 12321;
let lanthan;
let session;
let browser;
let body;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
lanthan = await Builder
@ -50,10 +48,10 @@ describe("completion on set commands", () => {
let items = await c.getCompletions();
assert.equal(items.length, 5);
assert.deepEqual(items[0], { type: 'title', text: 'Properties' });
assert(items[1].text.startsWith('hintchars'))
assert(items[2].text.startsWith('smoothscroll'))
assert(items[3].text.startsWith('nosmoothscroll'))
assert(items[4].text.startsWith('complete'))
assert.ok(items[1].text.startsWith('hintchars'))
assert.ok(items[2].text.startsWith('smoothscroll'))
assert.ok(items[3].text.startsWith('nosmoothscroll'))
assert.ok(items[4].text.startsWith('complete'))
});
});
@ -67,7 +65,7 @@ describe("completion on set commands", () => {
await eventually(async() => {
let items = await c.getCompletions();
assert.equal(items.length, 2);
assert(items[1].text.includes('nosmoothscroll'))
assert.ok(items[1].text.includes('nosmoothscroll'))
});
});
});

@ -1,13 +1,14 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { Key, By } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<head>
@ -21,12 +22,10 @@ const newApp = () => {
describe("console test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let tab;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let body: WebElement;
before(async() => {
http = newApp().listen(port);
@ -35,7 +34,6 @@ describe("console test", () => {
.spyAddon(path.join(__dirname, '..'))
.build();
webdriver = lanthan.getWebDriver();
browser = lanthan.getWebExtBrowser();
});
after(async() => {
@ -65,7 +63,7 @@ describe("console test", () => {
await body.sendKeys('o');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, 'open ');
});
@ -73,7 +71,7 @@ describe("console test", () => {
await body.sendKeys(Key.SHIFT, 'o');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, `open http://127.0.0.1:${port}/`);
});
@ -81,7 +79,7 @@ describe("console test", () => {
await body.sendKeys('t');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, 'tabopen ');
});
@ -89,7 +87,7 @@ describe("console test", () => {
await body.sendKeys(Key.SHIFT, 't');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, `tabopen http://127.0.0.1:${port}/`);
});
@ -97,7 +95,7 @@ describe("console test", () => {
await body.sendKeys('w');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, 'winopen ');
});
@ -105,7 +103,7 @@ describe("console test", () => {
await body.sendKeys(Key.SHIFT, 'W');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, `winopen http://127.0.0.1:${port}/`);
});
@ -113,7 +111,7 @@ describe("console test", () => {
await body.sendKeys('b');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, `buffer `);
});
@ -121,7 +119,7 @@ describe("console test", () => {
await body.sendKeys('a');
await webdriver.switchTo().frame(0);
let value = await webdriver.executeScript(() => document.querySelector('input').value);
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
assert.equal(value, `addbookmark Hello, world!`);
});
});

@ -1,23 +0,0 @@
let defaultInterval = 100;
let defaultTimeout = 2000;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const eventually = async (fn, timeout = defaultTimeout, interval = defaultInterval) => {
let start = Date.now();
let loop = async() => {
try {
await fn();
} catch (err) {
if (Date.now() - start > timeout) {
throw err;
}
await new Promise((resolve) => setTimeout(resolve, interval))
await loop();
}
};
await loop();
};
module.exports = eventually;

@ -0,0 +1,30 @@
const defaultInterval = 100;
const defaultTimeout = 2000;
type Handler = () => void
const sleep = (ms: number): Promise<void> => {
return new Promise(resolve => setTimeout(resolve, ms));
}
const eventually = async (
fn: Handler,
timeout = defaultTimeout,
interval = defaultInterval,
): Promise<void> => {
let start = Date.now();
let loop = async() => {
try {
await fn();
} catch (err) {
if (Date.now() - start > timeout) {
throw err;
}
await sleep(interval);
await loop();
}
};
await loop();
};
export default eventually;

@ -1,28 +1,30 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { Key, By } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><a href="hello">hello</a></body>
</html">`);
});
app.get('/follow-input', (req, res) => {
app.get('/follow-input', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><input></body>
</html">`);
});
app.get('/area', (req, res) => {
app.get('/area', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>
@ -49,7 +51,7 @@ const newApp = () => {
* | |
* +-----------------+
*/
app.get('/test1', (req, res) => {
app.get('/test1', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>
@ -71,13 +73,13 @@ const newApp = () => {
* | |
* +-----------------+
*/
app.get('/test2', (req, res) => {
app.get('/test2', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><iframe height="5000" src='/test2-frame'></body>
</html">`);
});
app.get('/test2-frame', (req, res) => {
app.get('/test2-frame', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>
@ -98,13 +100,13 @@ const newApp = () => {
* | |
* +-----------------+
*/
app.get('/test3', (req, res) => {
app.get('/test3', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body><iframe src='/test3-frame'></body>
</html">`);
});
app.get('/test3-frame', (req, res) => {
app.get('/test3-frame', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>
@ -118,20 +120,20 @@ const newApp = () => {
return app;
};
const waitForHints = async(webdriver) => {
const waitForHints = async(webdriver: WebDriver): Promise<void> => {
await eventually(async() => {
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
assert(hints.length > 0);
assert.ok(hints.length > 0);
});
};
describe('follow test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -167,7 +169,7 @@ describe('follow test', () => {
await waitForHints(webdriver);
await body.sendKeys('a');
let tagName = await webdriver.executeScript(() => document.activeElement.tagName);
let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string;
assert.equal(tagName.toLowerCase(), 'input');
});
@ -193,7 +195,7 @@ describe('follow test', () => {
await waitForHints(webdriver);
await body.sendKeys('a');
let tagName = await webdriver.executeScript(() => document.activeElement.tagName);
let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string;
assert.equal(tagName.toLowerCase(), 'input');
});

@ -1,15 +1,17 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const Console = require('./lib/Console');
const { Builder } = require('lanthan');
const { Key, By } = require('selenium-webdriver');
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, WebElement, By, Key } from 'selenium-webdriver';
import { Console } from './lib/Console';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body>
@ -24,21 +26,13 @@ const newApp = () => {
return app;
};
const waitForHints = async(webdriver) => {
await eventually(async() => {
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
assert(hints.length > 0);
});
};
describe('follow properties test', () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let body: WebElement;
before(async() => {
http = newApp().listen(port);
@ -152,7 +146,7 @@ describe('follow properties test', () => {
await webdriver.switchTo().frame(0);
await c.sendKeys('set hintchars=abc', Key.ENTER);
await new Promise(resolve => setTimeout(resolve, 100));
await webdriver.switchTo().parentFrame();
await (webdriver.switchTo() as any).parentFrame();
await body.sendKeys('f');
await eventually(async() => {

@ -1,11 +1,16 @@
const { By } = require('selenium-webdriver');
import { WebDriver, By } from 'selenium-webdriver';
class Console {
constructor(webdriver) {
this.webdriver = webdriver;
export type CompletionItem = {
type: string;
text: string;
highlight: boolean;
}
export class Console {
constructor(private webdriver: WebDriver) {
}
async sendKeys(...keys) {
async sendKeys(...keys: string[]) {
let input = await this.webdriver.findElement(By.css('input'));
input.sendKeys(...keys);
}
@ -13,24 +18,27 @@ class Console {
async currentValue() {
return await this.webdriver.executeScript(() => {
let input = document.querySelector('input');
if (input === null) {
throw new Error('could not find input element');
}
return input.value;
});
}
async getCompletions() {
return await this.webdriver.executeScript(() => {
getCompletions(): Promise<CompletionItem[]> {
return this.webdriver.executeScript(() => {
let items = document.querySelectorAll('.vimvixen-console-completion > li');
if (items.length === 0) {
throw new Error('completion items not found');
}
let objs = [];
for (let li of items) {
for (let li of Array.from(items)) {
if (li.classList.contains('vimvixen-console-completion-title')) {
objs.push({ type: 'title', text: li.textContent.trim() });
objs.push({ type: 'title', text: li.textContent!!.trim() });
} else if ('vimvixen-console-completion-item') {
let highlight = li.classList.contains('vimvixen-completion-selected');
objs.push({ type: 'item', text: li.textContent.trim(), highlight });
objs.push({ type: 'item', text: li.textContent!!.trim(), highlight });
} else {
throw new Error(`unexpected class: ${li.className}`);
}
@ -39,5 +47,3 @@ class Console {
});
}
}
module.exports = Console;

@ -1,10 +1,8 @@
'use strict';
import { spawn } from 'child_process';
const { spawn } = require('child_process');
const readLinux = () => {
const readLinux = (): Promise<string> => {
let stdout = '', stderr = '';
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
let xsel = spawn('xsel', ['--clipboard', '--output']);
xsel.stdout.on('data', (data) => {
stdout += data;
@ -21,9 +19,9 @@ const readLinux = () => {
});
};
const writeLinux = (data) => {
let stdout = '', stderr = '';
return new Promise((resolve, reject) => {
const writeLinux = (data: string): Promise<string> => {
let stderr = '';
return new Promise((resolve) => {
let xsel = spawn('xsel', ['--clipboard', '--input']);
xsel.stderr.on('data', (data) => {
stderr += data;
@ -39,25 +37,30 @@ const writeLinux = (data) => {
});
};
const unsupported = (os) => {
return () => {
throw new Error(`Unsupported os: ${os}`);
};
};
class UnsupportedError extends Error {
constructor(platform: string) {
super();
this.message = `Unsupported platform: ${platform}`;
}
}
const detect = () => {
const read = () => {
switch (process.platform) {
case 'linux':
return {
read: readLinux,
write: writeLinux,
};
default:
return {
read: unsupported(process.platform),
write: unsupported(process.platform),
};
case 'linux':
return readLinux();
}
throw new UnsupportedError(process.platform);
}
module.exports = detect();
const write = (data: string) => {
switch (process.platform) {
case 'linux':
return writeLinux(data);
}
throw new UnsupportedError(process.platform);
}
export {
read,
write,
};

@ -1,13 +1,15 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By } = require('selenium-webdriver');
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 } from 'selenium-webdriver';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body style="width:10000px; height:10000px"></body>
@ -17,12 +19,11 @@ const newApp = () => {
};
describe("mark test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -103,12 +104,13 @@ describe("mark test", () => {
await browser.tabs.create({ url: `http://127.0.0.1:${port}#second` });
await browser.tabs.remove(tab.id);
let handles;
let handles: string[];
await eventually(async() => {
handles = await webdriver.getAllWindowHandles();
await webdriver.getAllWindowHandles
assert.equal(handles.length, 2);
});
await webdriver.switchTo().window(handles[0]);
await webdriver.switchTo().window(handles!![0]);
await webdriver.navigate().to(`http://127.0.0.1:${port}#second`);
body = await webdriver.findElement(By.css('body'));
await body.sendKeys('\'', 'A');

@ -1,10 +1,12 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { Options: FirefoxOptions } = require('selenium-webdriver/firefox');
const { Key, By } = require('selenium-webdriver');
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';
import { Options as FirefoxOptions } from 'selenium-webdriver/firefox';
const newApp = () => {
let app = express();
@ -24,7 +26,7 @@ const newApp = () => {
</head>
</html">`);
});
app.get('/reload', (req, res) => {
app.get('/reload', (_req, res) => {
res.status(200).send(`
<html lang="en">
<head>
@ -46,13 +48,13 @@ const newApp = () => {
describe("navigate test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
let opts = new FirefoxOptions()
let opts = (new FirefoxOptions() as any)
.setPreference('browser.startup.homepage', `http://127.0.0.1:${port}#home`);
http = newApp().listen(port);
lanthan = await Builder
@ -135,8 +137,8 @@ describe("navigate test", () => {
await body.sendKeys(Key.SHIFT, 'l');
await eventually(async() => {
tab = (await browser.tabs.query({}))[0];
url = new URL(tab.url);
let tab = (await browser.tabs.query({}))[0];
let url = new URL(tab.url);
assert.equal(url.pathname, `/second`)
});
});
@ -220,11 +222,11 @@ describe("navigate test", () => {
it('should reload current tab by r', async () => {
await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`);
await webdriver.executeScript(() => window.scrollTo(500, 500));
let before
let before: number;
await eventually(async() => {
let tab = (await browser.tabs.query({}))[0];
before = Number(new URL(tab.url).hash.split('#')[1]);
assert(before > 0);
assert.ok(before > 0);
});
let body = await webdriver.findElement(By.css('body'));
@ -234,7 +236,7 @@ describe("navigate test", () => {
await eventually(async() => {
let tab = (await browser.tabs.query({}))[0];
after = Number(new URL(tab.url).hash.split('#')[1]);
assert(after > before);
assert.ok(after > before);
});
await eventually(async() => {
@ -246,11 +248,11 @@ describe("navigate test", () => {
it('should reload current tab without cache by R', async () => {
await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`);
await webdriver.executeScript(() => window.scrollTo(500, 500));
let before
let before: number;
await eventually(async() => {
let tab = (await browser.tabs.query({}))[0];
before = Number(new URL(tab.url).hash.split('#')[1]);
assert(before > 0);
assert.ok(before > 0);
});
let body = await webdriver.findElement(By.css('body'));
@ -260,7 +262,7 @@ describe("navigate test", () => {
await eventually(async() => {
let tab = (await browser.tabs.query({}))[0];
after = Number(new URL(tab.url).hash.split('#')[1]);
assert(after > before);
assert.ok(after > before);
});
// assert that the page offset is reset to 0, and 'eventually' is timed-out.

@ -1,13 +1,14 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { By } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, By } from 'selenium-webdriver';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body style="width:10000px; height:10000px"></body>
@ -18,10 +19,10 @@ const newApp = () => {
describe("options page", () => {
const port = 12321;
let http;
let lanthan;
let session;
let browser;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
http = newApp().listen(port);
@ -50,11 +51,11 @@ describe("options page", () => {
}
})
const updateTextarea = async(value) => {
const updateTextarea = async(value: string) => {
let textarea = await webdriver.findElement(By.css('textarea'));
await webdriver.executeScript(`document.querySelector('textarea').value = '${value}'`)
await textarea.sendKeys(' ');
await webdriver.executeScript(() => document.querySelector('textarea').blur());
await webdriver.executeScript(() => document.querySelector('textarea')!!.blur());
}
it('saves current config on blur', async () => {

@ -1,12 +1,14 @@
const path = require('path');
const assert = require('assert');
const { Builder } = require('lanthan');
const { By } = require('selenium-webdriver');
import * as path from 'path';
import * as assert from 'assert';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, By } from 'selenium-webdriver';
describe("options form page", () => {
let lanthan;
let webdriver;
let browser;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
beforeEach(async() => {
lanthan = await Builder
@ -28,14 +30,14 @@ describe("options form page", () => {
}
})
const setBlacklistValue = async(nth, value) => {
const setBlacklistValue = async(nth: number, value: string) => {
let selector = '.form-blacklist-form .column-url';
let input = (await webdriver.findElements(By.css(selector)))[nth];
await input.sendKeys(value);
await webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
}
const setSearchEngineValue = async(nth, name, url) => {
const setSearchEngineValue = async(nth: number, name: string, url: string) => {
let selector = '.form-search-form input.column-name';
let input = (await webdriver.findElements(By.css(selector)))[nth];
await input.sendKeys(name);

@ -1,28 +1,29 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Builder } = require('lanthan');
const { Key, By } = require('selenium-webdriver');
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';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send('ok');
});
return app;
};
describe("tab test", () => {
const port = 12321;
const url = `http://127.0.0.1:${port}/`;
let http;
let lanthan;
let webdriver
let browser;
let tabs;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
lanthan = await Builder
@ -46,8 +47,6 @@ describe("tab test", () => {
});
it('repeats last operation', async () => {
let before = await browser.tabs.query({});
let body = await webdriver.findElement(By.css('body'));
await body.sendKeys(':');

@ -1,12 +1,14 @@
const express = require('express');
const path = require('path');
const assert = require('assert');
const { Builder } = require('lanthan');
const { Key, By } = require('selenium-webdriver');
import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
const newApp = () => {
let app = express();
app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.send(`<!DOCTYPEhtml>
<html lang="en">
<body style="width:10000px; height:10000px"></body>
@ -16,12 +18,11 @@ const newApp = () => {
};
describe("scroll test", () => {
const port = 12321;
let http;
let lanthan;
let webdriver;
let body;
let http: http.Server;
let lanthan: Lanthan;
let webdriver: WebDriver;
let body: WebElement;
before(async() => {
http = newApp().listen(port);
@ -51,7 +52,7 @@ describe("scroll test", () => {
it('scrolls up by k', async () => {
await body.sendKeys('j');
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.equal(pageYOffset, 64);
});
@ -59,7 +60,7 @@ describe("scroll test", () => {
await webdriver.executeScript(() => window.scrollTo(0, 200));
await body.sendKeys('k');
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.equal(pageYOffset, 136);
});
@ -67,7 +68,7 @@ describe("scroll test", () => {
await webdriver.executeScript(() => window.scrollTo(100, 100));
await body.sendKeys('h');
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number;
assert.equal(pageXOffset, 36);
});
@ -75,7 +76,7 @@ describe("scroll test", () => {
await webdriver.executeScript(() => window.scrollTo(100, 100));
await body.sendKeys('l');
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number;
assert.equal(pageXOffset, 164);
});
@ -83,7 +84,7 @@ describe("scroll test", () => {
await webdriver.executeScript(() => window.scrollTo(0, 100));
await body.sendKeys('g', 'g');
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.equal(pageYOffset, 0);
});
@ -91,24 +92,24 @@ describe("scroll test", () => {
await webdriver.executeScript(() => window.scrollTo(0, 100));
await body.sendKeys(Key.SHIFT, 'g');
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
assert(pageYOffset > 5000);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.ok(pageYOffset > 5000);
});
it('scrolls bottom by 0', async () => {
await webdriver.executeScript(() => window.scrollTo(0, 100));
await body.sendKeys(Key.SHIFT, '0');
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
assert(pageXOffset === 0);
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number;
assert.ok(pageXOffset === 0);
});
it('scrolls bottom by $', async () => {
await webdriver.executeScript(() => window.scrollTo(0, 100));
await body.sendKeys(Key.SHIFT, '$');
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
assert(pageXOffset > 5000);
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number;
assert.ok(pageXOffset > 5000);
});
it('scrolls bottom by <C-U>', async () => {
@ -116,9 +117,9 @@ describe("scroll test", () => {
await body.sendKeys(Key.CONTROL, 'u');
let pageHeight =
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
assert(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5);
await webdriver.executeScript(() => window.document.documentElement.clientHeight) as number;
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.ok(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5);
});
it('scrolls bottom by <C-D>', async () => {
@ -126,9 +127,9 @@ describe("scroll test", () => {
await body.sendKeys(Key.CONTROL, 'd');
let pageHeight =
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
assert(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5);
await webdriver.executeScript(() => window.document.documentElement.clientHeight) as number;
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.ok(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5);
});
it('scrolls bottom by <C-B>', async () => {
@ -136,9 +137,9 @@ describe("scroll test", () => {
await body.sendKeys(Key.CONTROL, 'b');
let pageHeight =
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
assert(Math.abs(pageYOffset - (1000 - pageHeight)) < 5);
await webdriver.executeScript(() => window.document.documentElement.clientHeight) as number;
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.ok(Math.abs(pageYOffset - (1000 - pageHeight)) < 5);
});
it('scrolls bottom by <C-F>', async () => {
@ -146,8 +147,8 @@ describe("scroll test", () => {
await body.sendKeys(Key.CONTROL, 'f');
let pageHeight =
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
assert(Math.abs(pageYOffset - (1000 + pageHeight)) < 5);
await webdriver.executeScript(() => window.document.documentElement.clientHeight) as number;
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset) as number;
assert.ok(Math.abs(pageYOffset - (1000 + pageHeight)) < 5);
});
});

@ -1,4 +1,4 @@
module.exports = {
export default {
source: 'json',
json: `{
"keymaps": {
@ -83,4 +83,4 @@ module.exports = {
"blacklist": [
]
}`,
}
};

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

@ -1,16 +1,17 @@
const express = require('express');
const { Builder } = require('lanthan');
const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const { Key, By } = require('selenium-webdriver');
import * as path from 'path';
import * as assert from 'assert';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver, WebElement, By } from 'selenium-webdriver';
describe("zoom test", () => {
let lanthan;
let webdriver;
let browser;
let tab;
let body;
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
let tab: any;
let body: WebElement;
before(async() => {
lanthan = await Builder
@ -37,7 +38,7 @@ describe("zoom test", () => {
await eventually(async() => {
let actual = await browser.tabs.getZoom(tab.id);
assert(before < actual);
assert.ok(before < actual);
});
});
@ -47,7 +48,7 @@ describe("zoom test", () => {
await eventually(async() => {
let actual = await browser.tabs.getZoom(tab.id);
assert(before > actual);
assert.ok(before > actual);
});
});
@ -57,7 +58,7 @@ describe("zoom test", () => {
await eventually(async() => {
let actual = await browser.tabs.getZoom(tab.id);
assert(actual === 1);
assert.ok(actual === 1);
});
});
});