Fix debug web-server on e2e testing

jh-changes
Shin'ya Ueoka 7 years ago
parent e17399c4df
commit d844440a30
  1. 23
      e2e/contents/navigate.test.js
  2. 5
      e2e/contents/scroll.test.js
  3. 59
      e2e/contents/tab.test.js
  4. 7
      e2e/contents/zoom.test.js
  5. 28
      e2e/web-server/index.js
  6. 5
      e2e/web-server/url.js

@ -2,8 +2,7 @@ import * as windows from "../ambassador/src/client/windows";
import * as tabs from "../ambassador/src/client/tabs"; import * as tabs from "../ambassador/src/client/tabs";
import * as keys from "../ambassador/src/client/keys"; import * as keys from "../ambassador/src/client/keys";
import * as scrolls from "../ambassador/src/client/scrolls"; import * as scrolls from "../ambassador/src/client/scrolls";
import { CLIENT_URL } from '../web-server/url';
const SERVER_URL = "http://localhost:11111";
describe("navigate test", () => { describe("navigate test", () => {
let targetWindow; let targetWindow;
@ -11,7 +10,7 @@ describe("navigate test", () => {
before(() => { before(() => {
return windows.create().then((win) => { return windows.create().then((win) => {
targetWindow = win; targetWindow = win;
return tabs.create(targetWindow.id, SERVER_URL); return tabs.create(targetWindow.id, CLIENT_URL);
}); });
}); });
@ -21,7 +20,7 @@ describe("navigate test", () => {
it('goes to parent', () => { it('goes to parent', () => {
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL + '/a/b/c').then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c').then((tab) => {
targetTab = tab; targetTab = tab;
return keys.press(targetTab.id, 'g'); return keys.press(targetTab.id, 'g');
}).then(() => { }).then(() => {
@ -29,13 +28,13 @@ describe("navigate test", () => {
}).then(() => { }).then(() => {
return tabs.get(targetTab.id); return tabs.get(targetTab.id);
}).then((tab) => { }).then((tab) => {
expect(tab.url).to.be.equal(SERVER_URL + '/a/b/'); expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/');
}); });
}); });
it('removes hash', () => { it('removes hash', () => {
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL + '/a/b/c#navigate').then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c#navigate').then((tab) => {
targetTab = tab; targetTab = tab;
return keys.press(targetTab.id, 'g'); return keys.press(targetTab.id, 'g');
}).then(() => { }).then(() => {
@ -43,13 +42,13 @@ describe("navigate test", () => {
}).then(() => { }).then(() => {
return tabs.get(targetTab.id); return tabs.get(targetTab.id);
}).then((tab) => { }).then((tab) => {
expect(tab.url).to.be.equal(SERVER_URL + '/a/b/c#'); expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/c#');
}); });
}); });
it('goes to root', () => { it('goes to root', () => {
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL + '/a/b/c').then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c').then((tab) => {
targetTab = tab; targetTab = tab;
return keys.press(targetTab.id, 'g'); return keys.press(targetTab.id, 'g');
}).then(() => { }).then(() => {
@ -57,13 +56,13 @@ describe("navigate test", () => {
}).then(() => { }).then(() => {
return tabs.get(targetTab.id); return tabs.get(targetTab.id);
}).then((tab) => { }).then((tab) => {
expect(tab.url).to.be.equal(SERVER_URL + '/'); expect(tab.url).to.be.equal(CLIENT_URL + '/');
}); });
}); });
it('goes back and forward in history', () => { it('goes back and forward in history', () => {
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL + '/#navigate').then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL + '/#navigate').then((tab) => {
targetTab = tab; targetTab = tab;
return keys.press(targetTab.id, 'g'); return keys.press(targetTab.id, 'g');
}).then(() => { }).then(() => {
@ -75,7 +74,7 @@ describe("navigate test", () => {
}).then(() => { }).then(() => {
return tabs.get(targetTab.id); return tabs.get(targetTab.id);
}).then((tab) => { }).then((tab) => {
expect(tab.url, 'go back in history').to.be.equal(SERVER_URL + '/#navigate'); expect(tab.url, 'go back in history').to.be.equal(CLIENT_URL + '/#navigate');
}).then(() => { }).then(() => {
return new Promise(resolve => { setTimeout(() => resolve(), 2000) }); return new Promise(resolve => { setTimeout(() => resolve(), 2000) });
}).then(() => { }).then(() => {
@ -83,7 +82,7 @@ describe("navigate test", () => {
}).then(() => { }).then(() => {
return tabs.get(targetTab.id); return tabs.get(targetTab.id);
}).then((tab) => { }).then((tab) => {
expect(tab.url, 'go next in history').to.be.equal(SERVER_URL + '/#'); expect(tab.url, 'go next in history').to.be.equal(CLIENT_URL + '/#');
}); });
}); });
}); });

@ -2,8 +2,7 @@ import * as windows from "../ambassador/src/client/windows";
import * as tabs from "../ambassador/src/client/tabs"; import * as tabs from "../ambassador/src/client/tabs";
import * as keys from "../ambassador/src/client/keys"; import * as keys from "../ambassador/src/client/keys";
import * as scrolls from "../ambassador/src/client/scrolls"; import * as scrolls from "../ambassador/src/client/scrolls";
import { CLIENT_URL } from '../web-server/url';
const SERVER_URL = "localhost:11111";
describe("scroll test", () => { describe("scroll test", () => {
let targetWindow; let targetWindow;
@ -12,7 +11,7 @@ describe("scroll test", () => {
before(() => { before(() => {
return windows.create().then((win) => { return windows.create().then((win) => {
targetWindow = win; targetWindow = win;
return tabs.create(targetWindow.id, SERVER_URL); return tabs.create(targetWindow.id, CLIENT_URL + '/scroll');
}).then((tab) => { }).then((tab) => {
targetTab = tab; targetTab = tab;
}); });

@ -1,14 +1,13 @@
import * as windows from "../ambassador/src/client/windows"; import * as windows from "../ambassador/src/client/windows";
import * as tabs from "../ambassador/src/client/tabs"; import * as tabs from "../ambassador/src/client/tabs";
import * as keys from "../ambassador/src/client/keys"; import * as keys from "../ambassador/src/client/keys";
import { CLIENT_URL } from '../web-server/url';
const SERVER_URL = "localhost:11111/";
describe("tab test", () => { describe("tab test", () => {
let targetWindow; let targetWindow;
beforeEach(() => { beforeEach(() => {
return windows.create(SERVER_URL).then((win) => { return windows.create(CLIENT_URL).then((win) => {
targetWindow = win; targetWindow = win;
}); });
}); });
@ -20,7 +19,7 @@ describe("tab test", () => {
it('deletes tab by d', () => { it('deletes tab by d', () => {
let before; let before;
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => {
targetTab = tab; targetTab = tab;
return windows.get(targetWindow.id); return windows.get(targetWindow.id);
}).then((win) => { }).then((win) => {
@ -36,7 +35,7 @@ describe("tab test", () => {
it('duplicates tab by zd', () => { it('duplicates tab by zd', () => {
let before; let before;
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => {
targetTab = tab; targetTab = tab;
return windows.get(targetWindow.id) return windows.get(targetWindow.id)
}).then((win) => {; }).then((win) => {;
@ -54,7 +53,7 @@ describe("tab test", () => {
it('makes pinned by zp', () => { it('makes pinned by zp', () => {
let before; let before;
let targetTab; let targetTab;
return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => {
targetTab = tab; targetTab = tab;
return windows.get(targetWindow.id) return windows.get(targetWindow.id)
}).then((win) => {; }).then((win) => {;
@ -71,11 +70,11 @@ describe("tab test", () => {
it('selects previous tab by K', () => { it('selects previous tab by K', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 2); return tabs.selectAt(targetWindow.id, 2);
}).then((tab) => { }).then((tab) => {
@ -89,11 +88,11 @@ describe("tab test", () => {
it('selects previous tab by K rotatory', () => { it('selects previous tab by K rotatory', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 0); return tabs.selectAt(targetWindow.id, 0);
}).then((tab) => { }).then((tab) => {
@ -107,11 +106,11 @@ describe("tab test", () => {
it('selects next tab by J', () => { it('selects next tab by J', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 2); return tabs.selectAt(targetWindow.id, 2);
}).then((tab) => { }).then((tab) => {
@ -125,11 +124,11 @@ describe("tab test", () => {
it('selects previous tab by J rotatory', () => { it('selects previous tab by J rotatory', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 3); return tabs.selectAt(targetWindow.id, 3);
}).then((tab) => { }).then((tab) => {
@ -143,11 +142,11 @@ describe("tab test", () => {
it('selects first tab by g0', () => { it('selects first tab by g0', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 2); return tabs.selectAt(targetWindow.id, 2);
}).then((tab) => { }).then((tab) => {
@ -163,11 +162,11 @@ describe("tab test", () => {
it('selects last tab by g$', () => { it('selects last tab by g$', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 2); return tabs.selectAt(targetWindow.id, 2);
}).then((tab) => { }).then((tab) => {
@ -183,11 +182,11 @@ describe("tab test", () => {
it('selects last selected tab by <C-6>', () => { it('selects last selected tab by <C-6>', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1') return tabs.create(targetWindow.id, CLIENT_URL + '#1')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#2') return tabs.create(targetWindow.id, CLIENT_URL + '#2')
}).then(() => { }).then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#3'); return tabs.create(targetWindow.id, CLIENT_URL + '#3');
}).then(() => { }).then(() => {
return tabs.selectAt(targetWindow.id, 1); return tabs.selectAt(targetWindow.id, 1);
}).then(() => { }).then(() => {
@ -203,7 +202,7 @@ describe("tab test", () => {
it('deletes tab by d', () => { it('deletes tab by d', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1'); return tabs.create(targetWindow.id, CLIENT_URL + '#1');
}).then((tab) => { }).then((tab) => {
return keys.press(tab.id, 'd'); return keys.press(tab.id, 'd');
}).then(() => { }).then(() => {
@ -215,7 +214,7 @@ describe("tab test", () => {
it('does not delete pinned tab by d', () => { it('does not delete pinned tab by d', () => {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1'); return tabs.create(targetWindow.id, CLIENT_URL + '#1');
}).then((tab) => { }).then((tab) => {
return tabs.update(tab.id, { pinned: true }); return tabs.update(tab.id, { pinned: true });
}).then((tab) => { }).then((tab) => {
@ -230,7 +229,7 @@ describe("tab test", () => {
it('deletes pinned tab by !d', () => { it('deletes pinned tab by !d', () => {
let target; let target;
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1'); return tabs.create(targetWindow.id, CLIENT_URL + '#1');
}).then((tab) => { }).then((tab) => {
return tabs.update(tab.id, { pinned: true }); return tabs.update(tab.id, { pinned: true });
}).then((tab) => { }).then((tab) => {

@ -1,15 +1,14 @@
import * as windows from "../ambassador/src/client/windows"; import * as windows from "../ambassador/src/client/windows";
import * as tabs from "../ambassador/src/client/tabs"; import * as tabs from "../ambassador/src/client/tabs";
import * as keys from "../ambassador/src/client/keys"; import * as keys from "../ambassador/src/client/keys";
import { CLIENT_URL } from '../web-server/url';
const SERVER_URL = "localhost:11111/";
describe("zoom test", () => { describe("zoom test", () => {
let targetWindow; let targetWindow;
let targetTab; let targetTab;
before(() => { before(() => {
return windows.create(SERVER_URL).then((win) => { return windows.create(CLIENT_URL).then((win) => {
targetWindow = win; targetWindow = win;
}); });
}); });
@ -19,7 +18,7 @@ describe("zoom test", () => {
}); });
beforeEach(() => { beforeEach(() => {
return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => {
targetTab = tab; targetTab = tab;
}); });
}); });

@ -1,14 +1,24 @@
var serverUrl = require('./url');
var http = require('http'); var http = require('http');
var url = require('url');
const content = const handleScroll = (req, res) => {
'<!DOCTYPE html>' + res.writeHead(200, {'Content-Type': 'text/html'});
'<html lang="en">' + res.end('<!DOCTYPEhtml><html lang="en"><body style="width:10000px; height:10000px"></body></html">');
'<body style="width:10000px; height:10000px">' + };
'</body>' +
'</html">' ;
const handle404 = (req, res) => {
res.writeHead(404, {'Content-Type': 'text/plain'});
res.end('not found')
};
http.createServer(function (req, res) { http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'}); let u = url.parse(req.url);
res.end(content); if (req.method === 'GET' && u.pathname === '/scroll') {
}).listen(11111, '127.0.0.1'); handleScroll(req, res);
} else {
handle404(req, res);
}
console.log(`"${req.method} ${req.url}"`, res.statusCode)
}).listen(serverUrl.PORT, serverUrl.HOST);

@ -0,0 +1,5 @@
module.exports = {
PORT: 11111,
HOST: '127.0.0.1',
CLIENT_URL: 'http://127.0.0.1:11111',
}