diff --git a/QA.md b/QA.md index 4f37879..1e71bf6 100644 --- a/QA.md +++ b/QA.md @@ -14,11 +14,6 @@ The behaviors of the console are tested in [Console section](#consoles). - [ ] b: open a console with `buffer` - [ ] a: open a console with `addbookmark` and the current page's title -#### Tabs - -- [ ] r: reload current tab -- [ ] R: reload current tab without cache - #### Misc - [ ] y: yank current URL and show a message diff --git a/e2e/navigate.test.js b/e2e/navigate.test.js index 70d45ce..5c4e2d4 100644 --- a/e2e/navigate.test.js +++ b/e2e/navigate.test.js @@ -24,6 +24,15 @@ const newApp = () => { `); }); + app.get('/reload', (req, res) => { + res.status(200).send(` + + + + + +`); + }); app.get('/*', (req, res) => { res.send(` @@ -192,6 +201,59 @@ describe("zoom test", () => { assert.equal(tabs[1].active, true); }); }); -}); + it('should reload current tab by r', async () => { + await session.navigateTo(`http://127.0.0.1:${port}/reload`); + await session.executeScript(() => window.scrollTo(500, 500)); + let before + await eventually(async() => { + let tab = (await browser.tabs.query({}))[0]; + before = Number(new URL(tab.url).hash.split('#')[1]); + assert(before > 0); + }); + + let body = await session.findElementByCSS('body'); + await body.sendKeys('r'); + + let after + await eventually(async() => { + let tab = (await browser.tabs.query({}))[0]; + after = Number(new URL(tab.url).hash.split('#')[1]); + assert(after > before); + }); + await eventually(async() => { + let pageYOffset = await session.executeScript(() => window.pageYOffset); + assert.equal(pageYOffset, 500); + }); + }); + + it('should reload current tab without cache by R', async () => { + await session.navigateTo(`http://127.0.0.1:${port}/reload`); + await session.executeScript(() => window.scrollTo(500, 500)); + let before + await eventually(async() => { + let tab = (await browser.tabs.query({}))[0]; + before = Number(new URL(tab.url).hash.split('#')[1]); + assert(before > 0); + }); + + let body = await session.findElementByCSS('body'); + await body.sendKeys(Key.Shift, 'R'); + + let after + await eventually(async() => { + let tab = (await browser.tabs.query({}))[0]; + after = Number(new URL(tab.url).hash.split('#')[1]); + assert(after > before); + }); + + // assert that the page offset is reset to 0, and 'eventually' is timed-out. + await assert.rejects(async () => { + await eventually(async() => { + let pageYOffset = await session.executeScript(() => window.pageYOffset); + assert.equal(pageYOffset, 500); + }); + }); + }); +});