aboutsummaryrefslogtreecommitdiff
path: root/e2e
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-04-06 23:28:10 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-04-06 23:31:27 +0900
commit4f63499aa9e687ad21a683812b989a3497ee95bc (patch)
treec0dcf54d9c0dff9752d1f65cce2cc47ed392d954 /e2e
parentbc26dbdd77b4f9dce7505cd6e78b9161dbc5d928 (diff)
Add r/R tests
Diffstat (limited to 'e2e')
-rw-r--r--e2e/navigate.test.js64
1 files changed, 63 insertions, 1 deletions
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 = () => {
</head>
</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) => {
res.send(`<!DOCTYPEhtml>
@@ -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);
+ });
+ });
+ });
+});