Gilles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/125992
Change subject: Fix E2E scroll assertion logic
......................................................................
Fix E2E scroll assertion logic
It turns out that cucumber/selenium will automatically scroll
to the element you want it to click on. As a result we have to do
the same in order for the assertion to be correct when coming back to
the article.
Change-Id: I7d3b6609cfe7cdae9c08a6d723d652ad1a6a7055
---
M tests/browser/features/step_definitions/basic_mmv_navigation_steps.rb
1 file changed, 4 insertions(+), 5 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer
refs/changes/92/125992/1
diff --git
a/tests/browser/features/step_definitions/basic_mmv_navigation_steps.rb
b/tests/browser/features/step_definitions/basic_mmv_navigation_steps.rb
index 46cd02e..3e57c07 100644
--- a/tests/browser/features/step_definitions/basic_mmv_navigation_steps.rb
+++ b/tests/browser/features/step_definitions/basic_mmv_navigation_steps.rb
@@ -5,10 +5,10 @@
When(/^I click on the first image in the article$/) do
on(LightboxDemoPage) do |page|
- # Scroll the article on purpose
- page.execute_script "window.scroll(10, 100)"
- @articleScrollTop = page.execute_script("return $(window).scrollTop();")
- @articleScrollLeft = page.execute_script("return $(window).scrollLeft();")
+ # We store the offset of the image as the scroll position, because
cucumber/selenium
+ # automatically scrolls to it when we ask it to click on it
+ @articleScrollTop = page.execute_script("return
Math.round($('a[href=\"/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg\"]').first().find('img').offset().top);")
+ # Scrolls to the image and clicks on it
page.image1_in_article
end
end
@@ -68,7 +68,6 @@
Then(/^the wiki article should be scrolled to the same position as before
opening MMV$/) do
on(LightboxDemoPage) do |page|
page.execute_script("return $(window).scrollTop();").should eq
@articleScrollTop
- page.execute_script("return $(window).scrollLeft();").should eq
@articleScrollLeft
end
end
--
To view, visit https://gerrit.wikimedia.org/r/125992
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d3b6609cfe7cdae9c08a6d723d652ad1a6a7055
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits