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 keys from "../ambassador/src/client/keys";
import * as scrolls from "../ambassador/src/client/scrolls";
const SERVER_URL = "http://localhost:11111";
import { CLIENT_URL } from '../web-server/url';
describe("navigate test", () => {
let targetWindow;
@ -11,7 +10,7 @@ describe("navigate test", () => {
before(() => {
return windows.create().then((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', () => {
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;
return keys.press(targetTab.id, 'g');
}).then(() => {
@ -29,13 +28,13 @@ describe("navigate test", () => {
}).then(() => {
return tabs.get(targetTab.id);
}).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', () => {
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;
return keys.press(targetTab.id, 'g');
}).then(() => {
@ -43,13 +42,13 @@ describe("navigate test", () => {
}).then(() => {
return tabs.get(targetTab.id);
}).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', () => {
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;
return keys.press(targetTab.id, 'g');
}).then(() => {
@ -57,13 +56,13 @@ describe("navigate test", () => {
}).then(() => {
return tabs.get(targetTab.id);
}).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', () => {
let targetTab;
return tabs.create(targetWindow.id, SERVER_URL + '/#navigate').then((tab) => {
return tabs.create(targetWindow.id, CLIENT_URL + '/#navigate').then((tab) => {
targetTab = tab;
return keys.press(targetTab.id, 'g');
}).then(() => {
@ -75,7 +74,7 @@ describe("navigate test", () => {
}).then(() => {
return tabs.get(targetTab.id);
}).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(() => {
return new Promise(resolve => { setTimeout(() => resolve(), 2000) });
}).then(() => {
@ -83,7 +82,7 @@ describe("navigate test", () => {
}).then(() => {
return tabs.get(targetTab.id);
}).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 keys from "../ambassador/src/client/keys";
import * as scrolls from "../ambassador/src/client/scrolls";
const SERVER_URL = "localhost:11111";
import { CLIENT_URL } from '../web-server/url';
describe("scroll test", () => {
let targetWindow;
@ -12,7 +11,7 @@ describe("scroll test", () => {
before(() => {
return windows.create().then((win) => {
targetWindow = win;
return tabs.create(targetWindow.id, SERVER_URL);
return tabs.create(targetWindow.id, CLIENT_URL + '/scroll');
}).then((tab) => {
targetTab = tab;
});

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

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

@ -1,14 +1,24 @@
var serverUrl = require('./url');
var http = require('http');
var url = require('url');
const content =
'<!DOCTYPE html>' +
'<html lang="en">' +
'<body style="width:10000px; height:10000px">' +
'</body>' +
'</html">' ;
const handleScroll = (req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<!DOCTYPEhtml><html lang="en"><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) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(content);
}).listen(11111, '127.0.0.1');
let u = url.parse(req.url);
if (req.method === 'GET' && u.pathname === '/scroll') {
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',
}