aboutsummaryrefslogtreecommitdiff
path: root/e2e/completion.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-09-23 16:16:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-09-23 16:16:51 +0900
commitd37896887e848818a8d6e426ad6216fa8b331d80 (patch)
treeb3f13487449d029db97f61e62ea353e0f5c5abd1 /e2e/completion.test.ts
parentb5540dea9a08a258dc0dd19fccfcb2be47b0fc3c (diff)
Make pages as a page object
Diffstat (limited to 'e2e/completion.test.ts')
-rw-r--r--e2e/completion.test.ts98
1 files changed, 40 insertions, 58 deletions
diff --git a/e2e/completion.test.ts b/e2e/completion.test.ts
index fd58f74..4884d21 100644
--- a/e2e/completion.test.ts
+++ b/e2e/completion.test.ts
@@ -3,11 +3,11 @@ import * as path from 'path';
import * as assert from 'assert';
import * as http from 'http';
-import settings from './settings';
import eventually from './eventually';
+import settings from './settings';
import { Builder, Lanthan } from 'lanthan';
-import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
-import { Console } from './lib/Console';
+import { WebDriver, Key } from 'selenium-webdriver';
+import Page from './lib/Page';
const newApp = () => {
let app = express();
@@ -26,7 +26,7 @@ describe("general completion test", () => {
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
- let body: WebElement;
+ let page: Page;
before(async() => {
lanthan = await Builder
@@ -50,86 +50,68 @@ describe("general completion test", () => {
});
beforeEach(async() => {
- await webdriver.navigate().to(`http://127.0.0.1:${port}`);
- body = await webdriver.findElement(By.css('body'));
+ page = await Page.navigateTo(webdriver, `http://127.0.0.1:${port}`);
});
it('should all commands on empty line', async() => {
- await body.sendKeys(':');
-
- await webdriver.switchTo().frame(0);
- let c = new Console(webdriver);
-
- await eventually(async() => {
- let items = await c.getCompletions();
- assert.equal(items.length, 10);
- assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
- assert.ok(items[1].text.startsWith('set'))
- assert.ok(items[2].text.startsWith('open'))
- assert.ok(items[3].text.startsWith('tabopen'))
- });
+ let console = await page.showConsole();
+
+ let items = await console.getCompletions();
+ assert.equal(items.length, 10);
+ assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
+ assert.ok(items[1].text.startsWith('set'))
+ assert.ok(items[2].text.startsWith('open'))
+ assert.ok(items[3].text.startsWith('tabopen'))
});
it('should only commands filtered by prefix', async() => {
- await body.sendKeys(':');
-
- await webdriver.switchTo().frame(0);
- let c = new Console(webdriver);
- await c.sendKeys('b');
-
- await eventually(async() => {
- let items = await c.getCompletions();
- assert.equal(items.length, 4);
- assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
- assert.ok(items[1].text.startsWith('buffer'))
- assert.ok(items[2].text.startsWith('bdelete'))
- assert.ok(items[3].text.startsWith('bdeletes'))
- });
+ let console = await page.showConsole();
+ await console.inputKeys('b');
+
+ let items = await console.getCompletions();
+ assert.equal(items.length, 4);
+ assert.deepEqual(items[0], { type: 'title', text: 'Console Command' });
+ assert.ok(items[1].text.startsWith('buffer'))
+ assert.ok(items[2].text.startsWith('bdelete'))
+ assert.ok(items[3].text.startsWith('bdeletes'))
});
+ // > byffer
+ // > bdelete
+ // > bdeletes
+ // : b
it('selects completion items by <Tab>/<S-Tab> keys', async() => {
- await body.sendKeys(':');
-
- await webdriver.switchTo().frame(0);
- let c = new Console(webdriver);
- await c.sendKeys('b');
-
+ let console = await page.showConsole();
+ await console.inputKeys('b');
await eventually(async() => {
- let items = await c.getCompletions();
+ let items = await console.getCompletions();
assert.equal(items.length, 4);
});
- await c.sendKeys(Key.TAB);
+ await console.sendKeys(Key.TAB);
await eventually(async() => {
- let items = await c.getCompletions();
+ let items = await console.getCompletions();
assert.ok(items[1].highlight)
-
- let v = await c.currentValue();
- assert.equal(v, 'buffer');
+ assert.equal(await console.currentValue(), 'buffer');
});
- await c.sendKeys(Key.TAB, Key.TAB);
+ await console.sendKeys(Key.TAB, Key.TAB);
await eventually(async() => {
- let items = await c.getCompletions();
+ let items = await console.getCompletions();
assert.ok(items[3].highlight)
-
- let v = await c.currentValue();
- assert.equal(v, 'bdeletes');
+ assert.equal(await console.currentValue(), 'bdeletes');
});
- await c.sendKeys(Key.TAB);
+ await console.sendKeys(Key.TAB);
await eventually(async() => {
- let v = await c.currentValue();
- assert.equal(v, 'b');
+ assert.equal(await console.currentValue(), 'b');
});
- await c.sendKeys(Key.SHIFT, Key.TAB);
+ await console.sendKeys(Key.SHIFT, Key.TAB);
await eventually(async() => {
- let items = await c.getCompletions();
+ let items = await console.getCompletions();
assert.ok(items[3].highlight)
-
- let v = await c.currentValue();
- assert.equal(v, 'bdeletes');
+ assert.equal(await console.currentValue(), 'bdeletes');
});
});
});