|
|
@ -6,116 +6,78 @@ import { CLIENT_URL } from '../web-server/url'; |
|
|
|
describe("tab test", () => { |
|
|
|
describe("tab test", () => { |
|
|
|
let targetWindow; |
|
|
|
let targetWindow; |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
beforeEach(async () => { |
|
|
|
return windows.create(CLIENT_URL).then((win) => { |
|
|
|
targetWindow = await windows.create(CLIENT_URL); |
|
|
|
targetWindow = win; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
afterEach(async () => { |
|
|
|
return windows.remove(targetWindow.id); |
|
|
|
await windows.remove(targetWindow.id); |
|
|
|
}); |
|
|
|
});return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('follows link by `f`', async() => { |
|
|
|
|
|
|
|
let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); |
|
|
|
|
|
|
|
await keys.press(tab.id, 'f'); |
|
|
|
|
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
await keys.press(tab.id, 'a'); |
|
|
|
|
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
|
|
|
|
it('follows link by `f`', () => { |
|
|
|
tab = tabs.get(tab.id); |
|
|
|
let targetTab; |
|
|
|
expect(tab.url).to.be.equal(CLIENT_URL + '/follow#a'); |
|
|
|
return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { |
|
|
|
|
|
|
|
targetTab = tab; |
|
|
|
|
|
|
|
return keys.press(targetTab.id, 'f'); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return keys.press(targetTab.id, 'a'); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return tabs.get(targetTab.id); |
|
|
|
|
|
|
|
}).then((tab) => { |
|
|
|
|
|
|
|
expect(tab.url).to.be.equal(CLIENT_URL + '/follow#a'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('follows link into new tab by `F`', () => { |
|
|
|
it('follows link into new tab by `F`', async () => { |
|
|
|
let targetTab; |
|
|
|
let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); |
|
|
|
return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { |
|
|
|
await keys.press(tab.id, 'F', { shiftKey: true }); |
|
|
|
targetTab = tab; |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
return keys.press(targetTab.id, 'F', { shiftKey: true }); |
|
|
|
await keys.press(tab.id, 'a'); |
|
|
|
}).then(() => { |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
let win = await windows.get(targetWindow.id); |
|
|
|
return keys.press(targetTab.id, 'a'); |
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
return windows.get(targetWindow.id); |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#a'); |
|
|
|
}).then((win) => { |
|
|
|
|
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
|
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#a'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('follows link with target=_blank into new tab by `f`', () => { |
|
|
|
it('follows link with target=_blank into new tab by `f`', async () => { |
|
|
|
let targetTab; |
|
|
|
let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); |
|
|
|
return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { |
|
|
|
await keys.press(tab.id, 'f'); |
|
|
|
targetTab = tab; |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
return keys.press(targetTab.id, 'f'); |
|
|
|
await keys.press(tab.id, 'b'); |
|
|
|
}).then(() => { |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
let win = await windows.get(targetWindow.id); |
|
|
|
return keys.press(targetTab.id, 'b'); |
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
return windows.get(targetWindow.id); |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#external'); |
|
|
|
}).then((win) => { |
|
|
|
|
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
|
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#external'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('follows link with target=_blank into new tab by `F`', () => { |
|
|
|
it('follows link with target=_blank into new tab by `F`', async () => { |
|
|
|
let targetTab; |
|
|
|
let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); |
|
|
|
return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { |
|
|
|
await keys.press(tab.id, 'F', { shiftKey: true }); |
|
|
|
targetTab = tab; |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
return keys.press(targetTab.id, 'F', { shiftKey: true }); |
|
|
|
await keys.press(tab.id, 'b'); |
|
|
|
}).then(() => { |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
let win = await windows.get(targetWindow.id); |
|
|
|
}).then(() => { |
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
return keys.press(targetTab.id, 'b'); |
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 500) }); |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
}).then(() => { |
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#external'); |
|
|
|
return windows.get(targetWindow.id); |
|
|
|
|
|
|
|
}).then((win) => { |
|
|
|
|
|
|
|
let urls = win.tabs.map(t => t.url); |
|
|
|
|
|
|
|
expect(urls).to.have.lengthOf(3); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow'); |
|
|
|
|
|
|
|
expect(urls).to.include(CLIENT_URL + '/follow#external'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('follows area by `F`', () => { |
|
|
|
it('follows area by `F`', async () => { |
|
|
|
let targetTab; |
|
|
|
let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); |
|
|
|
return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { |
|
|
|
await keys.press(tab.id, 'f'); |
|
|
|
targetTab = tab; |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
return keys.press(targetTab.id, 'f'); |
|
|
|
await keys.press(tab.id, 'c'); |
|
|
|
}).then(() => { |
|
|
|
await new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
tab = await tabs.get(tab.id); |
|
|
|
return keys.press(targetTab.id, 'c'); |
|
|
|
expect(tab.url).to.be.equal(CLIENT_URL + '/follow#area'); |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return new Promise(resolve => { setTimeout(() => resolve(), 10) }); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
return tabs.get(targetTab.id); |
|
|
|
|
|
|
|
}).then((tab) => { |
|
|
|
|
|
|
|
expect(tab.url).to.be.equal(CLIENT_URL + '/follow#area'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|