Add r/R tests

jh-changes
Shin'ya Ueoka 6 years ago
parent bc26dbdd77
commit 4f63499aa9
  1. 5
      QA.md
  2. 62
      e2e/navigate.test.js

@ -14,11 +14,6 @@ The behaviors of the console are tested in [Console section](#consoles).
- [ ] <kbd>b</kbd>: open a console with `buffer` - [ ] <kbd>b</kbd>: open a console with `buffer`
- [ ] <kbd>a</kbd>: open a console with `addbookmark` and the current page's title - [ ] <kbd>a</kbd>: open a console with `addbookmark` and the current page's title
#### Tabs
- [ ] <kbd>r</kbd>: reload current tab
- [ ] <kbd>R</kbd>: reload current tab without cache
#### Misc #### Misc
- [ ] <kbd>y</kbd>: yank current URL and show a message - [ ] <kbd>y</kbd>: yank current URL and show a message

@ -24,6 +24,15 @@ const newApp = () => {
</head> </head>
</html">`); </html">`);
}); });
app.get('/reload', (req, res) => {
res.status(200).send(`
<html lang="en">
<head>
<script>window.location.hash = Date.now()</script>
</head>
<body style="width:10000px; height:10000px"></body>
</html">`);
});
app.get('/*', (req, res) => { app.get('/*', (req, res) => {
res.send(`<!DOCTYPEhtml> res.send(`<!DOCTYPEhtml>
@ -192,6 +201,59 @@ describe("zoom test", () => {
assert.equal(tabs[1].active, true); 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);
});
});
});
});