diff options
Diffstat (limited to 'e2e')
-rw-r--r-- | e2e/contents/follow.test.js | 162 | ||||
-rw-r--r-- | e2e/contents/navigate.test.js | 200 | ||||
-rw-r--r-- | e2e/contents/scroll.test.js | 183 | ||||
-rw-r--r-- | e2e/contents/tab.test.js | 359 | ||||
-rw-r--r-- | e2e/contents/zoom.test.js | 78 |
5 files changed, 364 insertions, 618 deletions
diff --git a/e2e/contents/follow.test.js b/e2e/contents/follow.test.js index f852dc0..f78780b 100644 --- a/e2e/contents/follow.test.js +++ b/e2e/contents/follow.test.js @@ -6,116 +6,78 @@ import { CLIENT_URL } from '../web-server/url'; describe("tab test", () => { let targetWindow; - beforeEach(() => { - return windows.create(CLIENT_URL).then((win) => { - targetWindow = win; - }); + beforeEach(async () => { + targetWindow = await windows.create(CLIENT_URL); }); - afterEach(() => { - return windows.remove(targetWindow.id); - }); + afterEach(async () => { + 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`', () => { - let targetTab; - 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'); - }); + tab = tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/follow#a'); }); - it('follows link into new tab by `F`', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'F', { shiftKey: true }); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return keys.press(targetTab.id, 'a'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 500) }); - }).then(() => { - 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#a'); - }); + it('follows link into new tab by `F`', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); + await keys.press(tab.id, 'F', { shiftKey: true }); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + await keys.press(tab.id, 'a'); + await new Promise(resolve => { setTimeout(() => resolve(), 500) }); + + let win = await windows.get(targetWindow.id); + 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`', () => { - let targetTab; - 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, 'b'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 500) }); - }).then(() => { - 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 link with target=_blank into new tab 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, 'b'); + await new Promise(resolve => { setTimeout(() => resolve(), 500) }); + + let win = await windows.get(targetWindow.id); + 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`', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/follow').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'F', { shiftKey: true }); - }).then(() => { - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return keys.press(targetTab.id, 'b'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 500) }); - }).then(() => { - 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 link with target=_blank into new tab by `F`', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/follow'); + await keys.press(tab.id, 'F', { shiftKey: true }); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + await keys.press(tab.id, 'b'); + await new Promise(resolve => { setTimeout(() => resolve(), 500) }); + + let win = await windows.get(targetWindow.id); + 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`', () => { - let targetTab; - 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, 'c'); - }).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'); - }); + it('follows area 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, 'c'); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/follow#area'); }); }); diff --git a/e2e/contents/navigate.test.js b/e2e/contents/navigate.test.js index b3f5f32..d36b167 100644 --- a/e2e/contents/navigate.test.js +++ b/e2e/contents/navigate.test.js @@ -7,150 +7,96 @@ import { CLIENT_URL } from '../web-server/url'; describe("navigate test", () => { let targetWindow; - before(() => { - return windows.create().then((win) => { - targetWindow = win; - return tabs.create(targetWindow.id, CLIENT_URL); - }); + before(async () => { + targetWindow = await windows.create(); + await tabs.create(targetWindow.id, CLIENT_URL); }); - after(() => { - return windows.remove(targetWindow.id); + after(async () => { + await windows.remove(targetWindow.id); }); - it('goes to parent', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'g'); - }).then(() => { - return keys.press(targetTab.id, 'u'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/'); - }); + it('goes to parent', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c'); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, 'u'); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/'); }); - it('removes hash', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c#navigate').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'g'); - }).then(() => { - return keys.press(targetTab.id, 'u'); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/c#'); - }); + it('removes hash', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c#navigate'); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, 'u'); + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/a/b/c#'); }); - it('goes to root', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'g'); - }).then(() => { - return keys.press(targetTab.id, 'U', { shiftKey: true }); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/'); - }); + it('goes to root', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/a/b/c'); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, 'U', { shiftKey: true }); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/'); }); - it('goes back and forward in history', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/#navigate').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, 'g'); - }).then(() => { - return keys.press(targetTab.id, 'u'); - }).then(() => { - return keys.press(targetTab.id, 'H', { shiftKey: true }); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url, 'go back in history').to.be.equal(CLIENT_URL + '/#navigate'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return keys.press(targetTab.id, 'L', { shiftKey: true }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url, 'go next in history').to.be.equal(CLIENT_URL + '/#'); - }); + it('goes back and forward in history', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/#navigate'); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, 'u'); + await keys.press(tab.id, 'H', { shiftKey: true }); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url, 'go back in history').to.be.equal(CLIENT_URL + '/#navigate'); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + await keys.press(tab.id, 'L', { shiftKey: true }); + + tab = await tabs.get(tab.id); + expect(tab.url, 'go next in history').to.be.equal(CLIENT_URL + '/#'); }); - it('goes previous page by <a>', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/a-pagenation?page=10').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, '['); - }).then(() => { - return keys.press(targetTab.id, '['); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/a-pagenation?page=9'); - }); + it('goes previous page by <a>', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/a-pagenation?page=10'); + await keys.press(tab.id, '['); + await keys.press(tab.id, '['); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/a-pagenation?page=9'); }) - it('goes next page by <a>', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/a-pagenation?page=10').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, ']'); - }).then(() => { - return keys.press(targetTab.id, ']'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/a-pagenation?page=11'); - }); + it('goes next page by <a>', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/a-pagenation?page=10'); + await keys.press(tab.id, ']'); + await keys.press(tab.id, ']'); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/a-pagenation?page=11'); }) - it('goes previous page by <link>', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/link-pagenation?page=10').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, '['); - }).then(() => { - return keys.press(targetTab.id, '['); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/link-pagenation?page=9'); - }); + it('goes previous page by <link>', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/link-pagenation?page=10'); + await keys.press(tab.id, '['); + await keys.press(tab.id, '['); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/link-pagenation?page=9'); }) - it('goes next page by <link>', () => { - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL + '/link-pagenation?page=10').then((tab) => { - targetTab = tab; - return keys.press(targetTab.id, ']'); - }).then(() => { - return keys.press(targetTab.id, ']'); - }).then(() => { - return new Promise(resolve => { setTimeout(() => resolve(), 10) }); - }).then(() => { - return tabs.get(targetTab.id); - }).then((tab) => { - expect(tab.url).to.be.equal(CLIENT_URL + '/link-pagenation?page=11'); - }); + it('goes next page by <link>', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/link-pagenation?page=10'); + await keys.press(tab.id, ']'); + await keys.press(tab.id, ']'); + await new Promise(resolve => { setTimeout(() => resolve(), 10) }); + + tab = await tabs.get(tab.id); + expect(tab.url).to.be.equal(CLIENT_URL + '/link-pagenation?page=11'); }) }); diff --git a/e2e/contents/scroll.test.js b/e2e/contents/scroll.test.js index 9410343..f364890 100644 --- a/e2e/contents/scroll.test.js +++ b/e2e/contents/scroll.test.js @@ -8,142 +8,99 @@ describe("scroll test", () => { let targetWindow; let targetTab; - before(() => { - return windows.create().then((win) => { - targetWindow = win; - return tabs.create(targetWindow.id, CLIENT_URL + '/scroll'); - }).then((tab) => { - targetTab = tab; - }); + before(async () => { + targetWindow = await windows.create(); + targetTab = await tabs.create(targetWindow.id, CLIENT_URL + '/scroll'); }); - after(() => { - return windows.remove(targetWindow.id); + after(async () => { + await windows.remove(targetWindow.id); }); - it('scrolls up by k', () => { - let before - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'k'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.be.lessThan(before.y); - }); + it('scrolls up by k', async () => { + let before = await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, 'k'); + + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.be.lessThan(before.y); }); - it('scrolls down by j', () => { - let before - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'j'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.be.greaterThan(before.y); - }); + it('scrolls down by j', async () => { + let before = await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, 'j'); + + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.be.greaterThan(before.y); }); - it('scrolls left by h', () => { - let before - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'h'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.x).to.be.lessThan(before.x); - }); + it('scrolls left by h', async () => { + let before = await scrolls.set(targetTab.id, 100, 100) + await keys.press(targetTab.id, 'h'); + + let actual = await scrolls.get(targetTab.id); + expect(actual.x).to.be.lessThan(before.x); }); - it('scrolls top by gg', () => { - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - return keys.press(targetTab.id, 'g'); - }).then(() => { - return keys.press(targetTab.id, 'g'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.be.equals(0); - }); + it('scrolls top by gg', async () => { + await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, 'g'); + await keys.press(targetTab.id, 'g'); + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.be.equals(0); }); - it('scrolls bottom by G', () => { - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - return keys.press(targetTab.id, 'G', { shiftKey: true }); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.be.equals(actual.yMax); - }); + it('scrolls bottom by G', async () => { + await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, 'G', { shiftKey: true }); + + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.be.equals(actual.yMax); }); - it('scrolls bottom by 0', () => { - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - return keys.press(targetTab.id, '0'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.x).to.be.equals(0); - }); + it('scrolls bottom by 0', async () => { + await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, '0'); + + let actual = await scrolls.get(targetTab.id); + expect(actual.x).to.be.equals(0); }); - it('scrolls bottom by $', () => { - return scrolls.set(targetTab.id, 100, 100).then((scroll) => { - return keys.press(targetTab.id, '$'); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.x).to.be.equals(actual.xMax); - }); + it('scrolls bottom by $', async () => { + await scrolls.set(targetTab.id, 100, 100); + await keys.press(targetTab.id, '$'); + + let actual = await scrolls.get(targetTab.id); + expect(actual.x).to.be.equals(actual.xMax); }); - it('scrolls bottom by <C-U>', () => { - let before - return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'u', { ctrlKey: true }); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.closeTo(before.y - before.frameHeight / 2, 1); - }); + it('scrolls bottom by <C-U>', async () => { + let before = await scrolls.set(targetTab.id, 5000, 5000); + await keys.press(targetTab.id, 'u', { ctrlKey: true }); + + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.closeTo(before.y - before.frameHeight / 2, 1); }); - it('scrolls bottom by <C-D>', () => { - let before - return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'd', { ctrlKey: true }); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.closeTo(before.y + before.frameHeight / 2, 1); - }); + it('scrolls bottom by <C-D>', async () => { + let before = await scrolls.set(targetTab.id, 5000, 5000); + await keys.press(targetTab.id, 'd', { ctrlKey: true }); + + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.closeTo(before.y + before.frameHeight / 2, 1); }); - it('scrolls bottom by <C-B>', () => { - let before - return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'b', { ctrlKey: true }); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.equals(before.y - before.frameHeight); - }); + it('scrolls bottom by <C-B>', async () => { + let before = await scrolls.set(targetTab.id, 5000, 5000); + await keys.press(targetTab.id, 'b', { ctrlKey: true }); + + let actual = await await scrolls.get(targetTab.id); + expect(actual.y).to.equals(before.y - before.frameHeight); }); - it('scrolls bottom by <C-F>', () => { - let before - return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { - before = scroll; - return keys.press(targetTab.id, 'f', { ctrlKey: true }); - }).then(() => { - return scrolls.get(targetTab.id); - }).then((actual) => { - expect(actual.y).to.equals(before.y + before.frameHeight); - }); + it('scrolls bottom by <C-F>', async () => { + let before = await scrolls.set(targetTab.id, 5000, 5000); + await keys.press(targetTab.id, 'f', { ctrlKey: true }); + let actual = await scrolls.get(targetTab.id); + expect(actual.y).to.equals(before.y + before.frameHeight); }); }); diff --git a/e2e/contents/tab.test.js b/e2e/contents/tab.test.js index 3846248..2d7f548 100644 --- a/e2e/contents/tab.test.js +++ b/e2e/contents/tab.test.js @@ -6,260 +6,161 @@ import { CLIENT_URL } from '../web-server/url'; describe("tab test", () => { let targetWindow; - beforeEach(() => { - return windows.create(CLIENT_URL).then((win) => { - targetWindow = win; - }); + beforeEach(async () => { + targetWindow = await windows.create(CLIENT_URL); }); - afterEach(() => { - return windows.remove(targetWindow.id); + afterEach(async () => { + await windows.remove(targetWindow.id); }); - it('deletes tab by d', () => { - let before; - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => { - targetTab = tab; - return windows.get(targetWindow.id); - }).then((win) => { - before = win; - return keys.press(targetTab.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((actual) => { - expect(actual.tabs).to.have.lengthOf(before.tabs.length - 1); - }); + it('deletes tab by d', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL); + let before = await windows.get(targetWindow.id); + await keys.press(tab.id, 'd'); + + let actual = await windows.get(targetWindow.id); + expect(actual.tabs).to.have.lengthOf(before.tabs.length - 1); + }); + + it('duplicates tab by zd', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL); + let before = await windows.get(targetWindow.id) + await keys.press(tab.id, 'z'); + await keys.press(tab.id, 'd'); + + let actual = await windows.get(targetWindow.id); + expect(actual.tabs).to.have.lengthOf(before.tabs.length + 1); + }); + + it('makes pinned by zp', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL); + let before = await windows.get(targetWindow.id); + await keys.press(tab.id, 'z'); + await keys.press(tab.id, 'p'); + + let actual = await windows.get(targetWindow.id); + expect(actual.tabs[0].pinned).to.be.true; }); - it('duplicates tab by zd', () => { - let before; - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => { - targetTab = tab; - return windows.get(targetWindow.id) - }).then((win) => {; - before = win; - return keys.press(targetTab.id, 'z'); - }).then(() => { - return keys.press(targetTab.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((actual) => { - expect(actual.tabs).to.have.lengthOf(before.tabs.length + 1); - }); - }) - - it('makes pinned by zp', () => { - let before; - let targetTab; - return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => { - targetTab = tab; - return windows.get(targetWindow.id) - }).then((win) => {; - before = win; - return keys.press(targetTab.id, 'z'); - }).then(() => { - return keys.press(targetTab.id, 'p'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((actual) => { - expect(actual.tabs[0].pinned).to.be.true; - }); - }) - - it('selects previous tab by K', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 2); - }).then((tab) => { - return keys.press(tab.id, 'K', { shiftKey: true }); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[1].active).to.be.true; - }); + it('selects previous tab by K', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 2); + await keys.press(tab.id, 'K', { shiftKey: true }); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[1].active).to.be.true; }); - it('selects previous tab by K rotatory', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 0); - }).then((tab) => { - return keys.press(tab.id, 'K', { shiftKey: true }); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[3].active).to.be.true; - }); + it('selects previous tab by K rotatory', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 0); + await keys.press(tab.id, 'K', { shiftKey: true }); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[3].active).to.be.true; }); - it('selects next tab by J', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 2); - }).then((tab) => { - return keys.press(tab.id, 'J', { shiftKey: true }); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[3].active).to.be.true; - }); + it('selects next tab by J', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 2); + await keys.press(tab.id, 'J', { shiftKey: true }); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[3].active).to.be.true; }); - it('selects previous tab by J rotatory', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 3); - }).then((tab) => { - return keys.press(tab.id, 'J', { shiftKey: true }); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[0].active).to.be.true; - }); + it('selects previous tab by J rotatory', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 3); + await keys.press(tab.id, 'J', { shiftKey: true }); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[0].active).to.be.true; }); - it('selects first tab by g0', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 2); - }).then((tab) => { - return keys.press(tab.id, 'g').then(() => tab); - }).then((tab) => { - return keys.press(tab.id, '0'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[0].active).to.be.true; - }); + it('selects first tab by g0', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 2); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, '0'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[0].active).to.be.true; }); - it('selects last tab by g$', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 2); - }).then((tab) => { - return keys.press(tab.id, 'g').then(() => tab); - }).then((tab) => { - return keys.press(tab.id, '$'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[3].active).to.be.true; - }); + it('selects last tab by g$', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + let tab = await tabs.selectAt(targetWindow.id, 2); + await keys.press(tab.id, 'g'); + await keys.press(tab.id, '$'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[3].active).to.be.true; }); - it('selects last selected tab by <C-6>', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#2') - }).then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#3'); - }).then(() => { - return tabs.selectAt(targetWindow.id, 1); - }).then(() => { - return tabs.selectAt(targetWindow.id, 3); - }).then((tab) => { - return keys.press(tab.id, '6', { ctrlKey: true }); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs[1].active).to.be.true; - }); + it('selects last selected tab by <C-6>', async () => { + await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await tabs.create(targetWindow.id, CLIENT_URL + '#2'); + await tabs.create(targetWindow.id, CLIENT_URL + '#3'); + await tabs.selectAt(targetWindow.id, 1); + let tab = await tabs.selectAt(targetWindow.id, 3); + await keys.press(tab.id, '6', { ctrlKey: true }); + + let win = await windows.get(targetWindow.id); + expect(win.tabs[1].active).to.be.true; }); - it('deletes tab by d', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1'); - }).then((tab) => { - return keys.press(tab.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs).to.have.lengthOf(1); - }); + it('deletes tab by d', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await keys.press(tab.id, 'd'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs).to.have.lengthOf(1); }); - it('reopen tab by u', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1'); - }).then((tab) => { - return keys.press(tab.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs).to.have.lengthOf(1); - return keys.press(win.tabs[0].id, 'u'); - }).then(() => { - return new Promise((resolve) => setTimeout(resolve, 100)); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs).to.have.lengthOf(2); - }); + it('reopen tab by u', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + await keys.press(tab.id, 'd'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs).to.have.lengthOf(1); + + await keys.press(win.tabs[0].id, 'u'); + await new Promise((resolve) => setTimeout(resolve, 100)); + + win = await windows.get(targetWindow.id); + expect(win.tabs).to.have.lengthOf(2); }); - it('does not delete pinned tab by d', () => { - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1'); - }).then((tab) => { - return tabs.update(tab.id, { pinned: true }); - }).then((tab) => { - return keys.press(tab.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs).to.have.lengthOf(2); - }); + it('does not delete pinned tab by d', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + tab = await tabs.update(tab.id, { pinned: true }); + await keys.press(tab.id, 'd'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs).to.have.lengthOf(2); }); - it('deletes pinned tab by !d', () => { - let target; - return Promise.resolve().then(() => { - return tabs.create(targetWindow.id, CLIENT_URL + '#1'); - }).then((tab) => { - return tabs.update(tab.id, { pinned: true }); - }).then((tab) => { - target = tab; - return keys.press(target.id, '!'); - }).then(() => { - return keys.press(target.id, 'd'); - }).then(() => { - return windows.get(targetWindow.id); - }).then((win) => { - expect(win.tabs).to.have.lengthOf(1); - }); + it('deletes pinned tab by !d', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '#1'); + tab = await tabs.update(tab.id, { pinned: true }); + await keys.press(tab.id, '!'); + await keys.press(tab.id, 'd'); + + let win = await windows.get(targetWindow.id); + expect(win.tabs).to.have.lengthOf(1); }); }); diff --git a/e2e/contents/zoom.test.js b/e2e/contents/zoom.test.js index c7efc93..2d90e28 100644 --- a/e2e/contents/zoom.test.js +++ b/e2e/contents/zoom.test.js @@ -7,64 +7,44 @@ describe("zoom test", () => { let targetWindow; let targetTab; - before(() => { - return windows.create(CLIENT_URL).then((win) => { - targetWindow = win; - }); + before(async () => { + targetWindow = await windows.create(CLIENT_URL); }); - after(() => { - return windows.remove(targetWindow.id); + after(async () => { + await windows.remove(targetWindow.id); }); - beforeEach(() => { - return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => { - targetTab = tab; - }); + beforeEach(async () => { + targetTab = await tabs.create(targetWindow.id, CLIENT_URL); }); - it('zooms-in by zi', () => { - let before; - return tabs.getZoom(targetTab.id).then((zoom) => { - before = zoom; - return keys.press(targetTab.id, 'z'); - }).then(() => { - return keys.press(targetTab.id, 'i'); - }).then(() => { - return tabs.getZoom(targetTab.id); - }).then((actual) => { - expect(actual).to.be.greaterThan(before); - }); + it('zooms-in by zi', async () => { + let before = await tabs.getZoom(targetTab.id); + await keys.press(targetTab.id, 'z'); + await keys.press(targetTab.id, 'i'); + + let actual = await tabs.getZoom(targetTab.id); + expect(actual).to.be.greaterThan(before); }); - it('zooms-in by zo', () => { - let before; - return tabs.getZoom(targetTab.id).then((zoom) => { - before = zoom; - return keys.press(targetTab.id, 'z'); - }).then(() => { - return keys.press(targetTab.id, 'o'); - }).then(() => { - return tabs.getZoom(targetTab.id); - }).then((actual) => { - expect(actual).to.be.lessThan(before); - }); + it('zooms-in by zo', async () => { + let before = await tabs.getZoom(targetTab.id); + await keys.press(targetTab.id, 'z'); + await keys.press(targetTab.id, 'o'); + + let actual = await tabs.getZoom(targetTab.id); + expect(actual).to.be.lessThan(before); }); - it('zooms-in by zz', () => { - let before; - tabs.setZoom(targetTab.id, 1.5).then(() => { - return tabs.getZoom(targetTab.id); - }).then((zoom) => { - before = zoom; - return keys.press(targetTab.id, 'z'); - }).then(() => { - return keys.press(targetTab.id, 'z'); - }).then(() => { - return tabs.getZoom(targetTab.id); - }).then((actual) => { - expect(actual).to.be.lessThan(before); - expect(actual).to.be.be(1); - }); + it('zooms-in by zz', async () => { + await tabs.setZoom(targetTab.id, 1.5); + let before = await tabs.getZoom(targetTab.id); + await keys.press(targetTab.id, 'z'); + await keys.press(targetTab.id, 'z'); + + let actual = await tabs.getZoom(targetTab.id); + expect(actual).to.be.lessThan(before); + expect(actual).to.equal(1); }); }); |