jenkins-bot has submitted this change and it was merged.

Change subject: Refactor history and pointers browsertests
......................................................................


Refactor history and pointers browsertests

- Applied the Given-When-Then rule
- Created alias for the "diff-has-loaded" step for readability
- Created higher-level step for loading the revisionslider
- Added assertions where missing
- Added ability to click the upper or lower area of revisionbars

Bug: T146276
Change-Id: Iad5abbb6e73a31afad1e2058b26ece3fbc7ad942
---
M tests/browser/features/history.feature
M tests/browser/features/pointers.feature
M tests/browser/features/support/pages/diff_page.rb
M tests/browser/features/support/step_definitions/common_steps.rb
M tests/browser/features/support/step_definitions/pointers.rb
5 files changed, 93 insertions(+), 67 deletions(-)

Approvals:
  WMDE-Fisch: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/browser/features/history.feature 
b/tests/browser/features/history.feature
index d8a5dc2..389e0b4 100644
--- a/tests/browser/features/history.feature
+++ b/tests/browser/features/history.feature
@@ -5,40 +5,39 @@
     And I have reset my preferences
     And RevisionSlider is enabled as a beta feature
     And a page with 4 revision(s) exists
-    And I am on the diff page
-    And I click on the expand button
-    And The RevisionSlider has loaded
-    And I have dismissed the help dialog
-    And The help dialog is hidden
 
   Scenario: RevisionSlider history can be accessed using browser back and 
forward buttons after clicking on a revision
-    Given I click on revision 1
-    And the diff has loaded
+    Given I am on the diff page
+    When I have loaded the RevisionSlider and dismissed the help dialog
+    And I click on revision 1 to move the lower pointer
+    And I wait until the diff has loaded
+    And I click on revision 2 to move the upper pointer
+    And I wait until the diff has loaded
     And I click the browser back button
-    And the diff has loaded
-    Then the lower pointer should be on revision 3
-    And the lower pointer should be on revision 4
-    And revision 3 should be loaded on the left of the diff
-    And revision 4 should be loaded on the right of the diff
-    Given I click the browser forward button
-    And the diff has loaded
+    And I wait until the diff has loaded
+    And I click the browser back button
+    And I wait until the diff has loaded
+    And I click the browser forward button
+    And I wait until the diff has loaded
     Then the lower pointer should be on revision 1
-    And the lower pointer should be on revision 4
+    And the upper pointer should be on revision 4
     And revision 1 should be loaded on the left of the diff
     And revision 4 should be loaded on the right of the diff
 
   Scenario: RevisionSlider history can be accessed using browser back and 
forward buttons after dragging to a revision
-    Given I drag the lower pointer to revision 1
-    And the diff has loaded
+    Given I am on the diff page
+    When I have loaded the RevisionSlider and dismissed the help dialog
+    And I drag the lower pointer to revision 1
+    And I wait until the diff has loaded
+    And I drag the upper pointer to revision 2
+    And I wait until the diff has loaded
     And I click the browser back button
-    And the diff has loaded
-    Then the lower pointer should be on revision 3
-    And the lower pointer should be on revision 4
-    And revision 3 should be loaded on the left of the diff
-    And revision 4 should be loaded on the right of the diff
-    Given I click the browser forward button
-    And the diff has loaded
+    And I wait until the diff has loaded
+    And I click the browser back button
+    And I wait until the diff has loaded
+    And I click the browser forward button
+    And I wait until the diff has loaded
     Then the lower pointer should be on revision 1
-    And the lower pointer should be on revision 4
+    And the upper pointer should be on revision 4
     And revision 1 should be loaded on the left of the diff
-    And revision 4 should be loaded on the right of the diff
\ No newline at end of file
+    And revision 4 should be loaded on the right of the diff
diff --git a/tests/browser/features/pointers.feature 
b/tests/browser/features/pointers.feature
index e09b377..6f812e8 100644
--- a/tests/browser/features/pointers.feature
+++ b/tests/browser/features/pointers.feature
@@ -5,39 +5,39 @@
     And I have reset my preferences
     And RevisionSlider is enabled as a beta feature
     And a page with 5 revision(s) exists
-    And I am on the diff page
-    And I click on the expand button
-    And The RevisionSlider has loaded
-    And I have dismissed the help dialog
-    And The help dialog is hidden
 
-  Scenario: RevisionSlider pointers move then revision bars are clicked
-    Given I click on revision 3
-    And the diff has loaded
-    Then the lower pointer should be on revision 3
-    And revision 3 should be loaded on the left of the diff
-    Given I click on revision 4
-    And the diff has loaded
-    Then the upper pointer should be on revision 4
-    And revision 4 should be loaded on the right of the diff
-
-  Scenario: RevisionSlider pointers can be dragged
-    Given I drag the lower pointer to revision 3
-    And the diff has loaded
-    Then the lower pointer should be on revision 3
-    And revision 3 should be loaded on the left of the diff
-    Given I drag the upper pointer to revision 4
-    And the diff has loaded
-    Then the upper pointer should be on revision 4
-    And revision 4 should be loaded on the right of the diff
-
-  Scenario: RevisionSlider pointers switch when crossed over
-    Given I drag the upper pointer to revision 3
-    And the diff has loaded
+  Scenario: RevisionSlider pointers move when revision bars are clicked
+    Given I am on the diff page
+    When I have loaded the RevisionSlider and dismissed the help dialog
+    And I click on revision 3 to move the lower pointer
+    And I wait until the diff has loaded
+    And I click on revision 4 to move the upper pointer
+    And I wait until the diff has loaded
     Then the lower pointer should be on revision 3
     And the upper pointer should be on revision 4
     And revision 3 should be loaded on the left of the diff
-    Given I drag the lower pointer to revision 5
-    And the diff has loaded
-    Then the upper pointer should be on revision 5
-    And revision 5 should be loaded on the right of the diff
\ No newline at end of file
+    And revision 4 should be loaded on the right of the diff
+
+  Scenario: RevisionSlider pointers can be dragged
+    Given I am on the diff page
+    When I have loaded the RevisionSlider and dismissed the help dialog
+    And I drag the lower pointer to revision 3
+    And I wait until the diff has loaded
+    And I drag the upper pointer to revision 4
+    And I wait until the diff has loaded
+    Then the lower pointer should be on revision 3
+    And the upper pointer should be on revision 4
+    And revision 3 should be loaded on the left of the diff
+    And revision 4 should be loaded on the right of the diff
+
+  Scenario: RevisionSlider pointers switch when crossed over
+    Given I am on the diff page
+    When I have loaded the RevisionSlider and dismissed the help dialog
+    And I drag the lower pointer to revision 3
+    And I wait until the diff has loaded
+    And I click on revision 1 to move the upper pointer
+    And I wait until the diff has loaded
+    Then the lower pointer should be on revision 1
+    And the upper pointer should be on revision 3
+    And revision 1 should be loaded on the left of the diff
+    And revision 3 should be loaded on the right of the diff
diff --git a/tests/browser/features/support/pages/diff_page.rb 
b/tests/browser/features/support/pages/diff_page.rb
index c2d9538..1dc11d7 100644
--- a/tests/browser/features/support/pages/diff_page.rb
+++ b/tests/browser/features/support/pages/diff_page.rb
@@ -27,9 +27,18 @@
     element('div', css: '.mw-revslider-revision[data-pos="' + index.to_s + 
'"]')
   end
 
+  def click_revision_lower(index = 1)
+    revbar = revisionslider_rev(index).element.wd
+    browser.driver.action.move_to(revbar, 1, revbar.size.height - 
1).click.perform
+  end
+
+  def click_revision_upper(index = 1)
+    revbar = revisionslider_rev(index).element.wd
+    browser.driver.action.move_to(revbar, 1, 0).click.perform
+  end
+
   def revisionslider_tooltip(index = 1)
     element('div', css: '.mw-revslider-revision-tooltip-' + index.to_s)
-
   end
 
   def wait_for_slider_to_load
diff --git a/tests/browser/features/support/step_definitions/common_steps.rb 
b/tests/browser/features/support/step_definitions/common_steps.rb
index 5dbccb7..4c7d995 100644
--- a/tests/browser/features/support/step_definitions/common_steps.rb
+++ b/tests/browser/features/support/step_definitions/common_steps.rb
@@ -30,6 +30,12 @@
   step 'The RevisionSlider has loaded'
 end
 
+When(/^I have loaded the RevisionSlider and dismissed the help dialog$/) do
+  step 'I click on the expand button'
+  step 'I wait until the RevisionSlider has loaded'
+  step 'I have dismissed the help dialog'
+end
+
 Then(/^The RevisionSlider has loaded$/) do
   on(DiffPage).wait_for_slider_to_load
 end
diff --git a/tests/browser/features/support/step_definitions/pointers.rb 
b/tests/browser/features/support/step_definitions/pointers.rb
index 571498f..d73073f 100644
--- a/tests/browser/features/support/step_definitions/pointers.rb
+++ b/tests/browser/features/support/step_definitions/pointers.rb
@@ -1,31 +1,43 @@
-Given(/^I click on revision (\d+)$/) do |index|
-  on(DiffPage).revisionslider_rev(index.to_i).when_visible.click
+When(/^I click on revision (\d+) to move the lower pointer$/) do |index|
+  on(DiffPage).click_revision_lower(index.to_i)
+end
+
+When(/^I click on revision (\d+) to move the upper pointer$/) do |index|
+  on(DiffPage).click_revision_upper(index.to_i)
 end
 
 Given(/^I drag the lower pointer to revision (\d+)$/) do |index|
-  on(DiffPage).revisionslider_pointer_lower_element.element.drag_and_drop_on 
on(DiffPage).revisionslider_rev(index.to_i).element
+  on(DiffPage) do |page|
+    page.revisionslider_pointer_lower_element.element.drag_and_drop_on 
page.revisionslider_rev(index.to_i).element
+  end
 end
 
 Given(/^I drag the upper pointer to revision (\d+)$/) do |index|
-  on(DiffPage).revisionslider_pointer_upper_element.element.drag_and_drop_on 
on(DiffPage).revisionslider_rev(index.to_i).element
+  on(DiffPage) do |page|
+    page.revisionslider_pointer_upper_element.element.drag_and_drop_on 
page.revisionslider_rev(index.to_i).element
+  end
 end
 
 Given(/^the diff has loaded$/) do
   on(DiffPage).wait_for_diff_to_load
 end
 
+When(/^I wait until the diff has loaded$/) do
+  step 'the diff has loaded'
+end
+
 Then(/^revision (\d+) should be loaded on the left of the diff$/) do |index|
-  on(DiffPage).revisionslider_left_summary_element.text.include? "RS-Summary-" 
+ index.to_s
+  expect(on(DiffPage).revisionslider_left_summary_element.text).to include 
"RS-Summary-" + index.to_s
 end
 
 Then(/^revision (\d+) should be loaded on the right of the diff$/) do |index|
-  on(DiffPage).revisionslider_right_summary_element.text.include? 
"RS-Summary-" + index.to_s
+  expect(on(DiffPage).revisionslider_right_summary_element.text).to include 
"RS-Summary-" + index.to_s
 end
 
 Then(/^the upper pointer should be on revision (\d+)$/) do |index|
-  on(DiffPage).revisionslider_pointer_upper_element.style('left') == ( 
index.to_i - 1 ) * 16
+  
expect(on(DiffPage).revisionslider_pointer_upper_element.attribute('data-pos')).to
 eq index
 end
 
 Then(/^the lower pointer should be on revision (\d+)$/) do |index|
-  on(DiffPage).revisionslider_pointer_lower_element.style('left') == ( 
index.to_i - 1 ) * 16
+  
expect(on(DiffPage).revisionslider_pointer_lower_element.attribute('data-pos')).to
 eq index
 end
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/314706
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iad5abbb6e73a31afad1e2058b26ece3fbc7ad942
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/extensions/RevisionSlider
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: WMDE-Fisch <christoph.jau...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to