Timeline browser tests

This adds tests for navigating the timeline using the back
and forward buttons.
It also makes sure that the buttons are disabled / enabled
at the correct times.

Bug: T133278
Change-Id: I9834dd3d3bf107557b15fdd105a946902d53b8f2
This commit is contained in:
addshore 2016-07-04 15:43:47 +01:00 committed by WMDE-Fisch
parent 1671a07d7d
commit 50fdb7b1c9
5 changed files with 69 additions and 0 deletions

View file

@ -11,10 +11,18 @@ class DiffPage
a(:revisionslider_help_close_start, css: '#revisionslider-help-close-start > a')
a(:revisionslider_help_close_end, css: '#revisionslider-help-close-end > a')
a(:revisionslider_timeline_backwards, css: '#mw-revslider-container > div > a.mw-revslider-arrow.mw-revslider-arrow-backwards')
a(:revisionslider_timeline_forwards, css: '#mw-revslider-container > div > a.mw-revslider-arrow.mw-revslider-arrow-forwards')
def wait_for_slider_to_load
wait_until do
revisionslider_placeholder? == false
end
end
def wait_for_help_dialog_to_hide
wait_until do
revisionslider_help_dialog_element.visible? == false
end
end
end

View file

@ -22,6 +22,10 @@ Given(/^The RevisionSlider has loaded$/) do
on(DiffPage).wait_for_slider_to_load
end
Given(/^The window size is (\d+) by (\d+)$/) do |width,height|
browser.window.resize_to(width.to_i, height.to_i)
end
Then(/^RevisionSlider is enabled as a beta feature$/) do
visit(SpecialPreferencesPage).enable_revisionslider
end

View file

@ -10,6 +10,10 @@ Given(/^I have moved to the next step$/) do
on(DiffPage).revisionslider_help_next_element.click
end
Given(/^The help dialog is hidden$/) do
on(DiffPage).wait_for_help_dialog_to_hide
end
Then(/^The help dialog should be visible/) do
on(DiffPage).revisionslider_help_dialog_element.visible?.should be_truthy
end

View file

@ -0,0 +1,23 @@
Then(/^The forward arrow should be disabled/) do
expect(on(DiffPage).revisionslider_timeline_forwards_element.class_name).to match 'mw-revslider-arrow-disabled'
end
Then(/^The backward arrow should be disabled/) do
expect(on(DiffPage).revisionslider_timeline_backwards_element.class_name).to match 'mw-revslider-arrow-disabled'
end
Then(/^The forward arrow should be enabled/) do
expect(on(DiffPage).revisionslider_timeline_forwards_element.class_name).not_to match 'mw-revslider-arrow-disabled'
end
Then(/^The backward arrow should be enabled/) do
expect(on(DiffPage).revisionslider_timeline_backwards_element.class_name).not_to match 'mw-revslider-arrow-disabled'
end
Given(/^I click on the forward arrow$/) do
on(DiffPage).revisionslider_timeline_forwards_element.click
end
Given(/^I click on the backward arrow$/) do
on(DiffPage).revisionslider_timeline_backwards_element.click
end

View file

@ -0,0 +1,30 @@
@chrome @en.wikipedia.beta.wmflabs.org @firefox @integration
Feature: RevisionSlider timeline
Background:
Given I am logged in
And I have reset my preferences
And RevisionSlider is enabled as a beta feature
Scenario: RevisionSlider timeline arrows to be disabled with 3 revisions
Given a page with 3 revision(s) exists
And I am on the diff page
And The RevisionSlider has loaded
And I have closed the help dialog at the start
Then The backward arrow should be disabled
And The forward arrow should be disabled
Scenario: RevisionSlider timeline arrows to be enabled with adequate revisions
Given a page with 30 revision(s) exists
And The window size is 800 by 600
And I am on the diff page
And The RevisionSlider has loaded
And I have closed the help dialog at the start
And The help dialog is hidden
Then The backward arrow should be enabled
And The forward arrow should be disabled
Given I click on the backward arrow
Then The backward arrow should be disabled
And The forward arrow should be enabled
Given I click on the forward arrow
Then The backward arrow should be enabled
And The forward arrow should be disabled