]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test(scroll): test stored position over anchor
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 1 May 2020 08:04:03 +0000 (10:04 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 1 May 2020 08:04:03 +0000 (10:04 +0200)
e2e/specs/scroll-behavior.js

index 7ff21e3bd5cfcd0b4e70c6ba800a281d36586e27..8fe376469f404632b755be2cb85535e327d957bf 100644 (file)
@@ -152,6 +152,28 @@ module.exports = {
         'restores scroll position when reloading'
       )
 
+      // going to an anchor entry, scrolling, then back then forward restores the position
+      .click('li:nth-child(4) a')
+      .waitForElementPresent('.view.bar', TIMEOUT)
+      // at this point we scrolled to the anchor, scroll again somewhere else
+      // and then go back
+      .execute(function () {
+        window.scrollTo(0, 100)
+        window.history.back()
+      })
+      .waitForElementPresent('.view.foo', TIMEOUT)
+      .execute(function () {
+        window.history.forward()
+      })
+      .waitForElementPresent('.view.bar', TIMEOUT)
+      .assert.evaluate(
+        function () {
+          return window.pageYOffset === 100
+        },
+        null,
+        'scroll to stored position over anchor'
+      )
+
       // going again to a popped entry should not restore the saved position
       .click('li:nth-child(1) a')
       .waitForElementPresent('.view.home', TIMEOUT)