mediawiki-extensions-Multim.../tests/browser/features/step_definitions/mmv_download_steps.rb
Gilles Dubuc 8c37b7abb4 Wait for the download menu to appear before closing it
In practice doing this quickly still works, but the browser test in IE
catches the menu at exactly the wrong time (when it appears briefly
before disappearing).

Bug: T89087
Change-Id: I4076943bf33a566ec882f69d17f6a3a9f1a28002
2015-02-11 20:28:13 +01:00

97 lines
3.3 KiB
Ruby

# encoding: utf-8
When /^I open the download dropdown$/ do
step "I click the download icon"
step "I click the download down arrow icon"
end
When /^I click the download icon$/ do
on(E2ETestPage).mmv_download_icon_element.when_present.click
end
When /^I click the download down arrow icon$/ do
sleep 1
on(E2ETestPage).mmv_download_down_arrow_icon_element.when_present.click
end
When /^I click on the attribution area$/ do
on(E2ETestPage).mmv_download_attribution_area_element.when_present.click
end
When /^I click on the attribution area close icon$/ do
on(E2ETestPage).mmv_download_attribution_area_close_icon_element.click
end
When /^I click the (.*) download size$/ do |size_option|
on(E2ETestPage) do |page|
case size_option
when "small"
@index = 1
when "medium"
@index = 2
when "large"
@index = 3
else
@index = 0
end
page.mmv_download_size_options_elements[@index].when_present.click
end
end
When /^the download size options disappears$/ do
on(E2ETestPage).mmv_download_size_menu_element.when_not_present
end
When /^the download menu appears$/ do
on(E2ETestPage).mmv_download_menu_element.when_present
end
Then /^the download menu should appear$/ do
expect(on(E2ETestPage).mmv_download_menu_element.when_present).to be_visible
end
Then /^the download menu should disappear$/ do
expect(on(E2ETestPage).mmv_download_menu_element).not_to be_visible
end
Then /^the original beginning download image size label should be "(.*)"$/ do |size_in_pixels|
expect(on(E2ETestPage).mmv_download_size_label_element.when_present.text).to eq size_in_pixels
end
Then /^the download image size label should be "(.*)"$/ do |size_in_pixels|
on(E2ETestPage) do |page|
page.mmv_download_size_options_elements[0].when_not_present
expect(page.mmv_download_size_label_element.when_present.text).to eq size_in_pixels
end
end
Then /^the download size options should appear$/ do
expect(on(E2ETestPage).mmv_download_size_menu_element.when_present).to be_visible
end
Then /^the download links should be the original image$/ do
on(E2ETestPage) do |page|
expect(page.mmv_download_link_element.attribute('href')).to match /^?download$/
expect(page.mmv_download_preview_link_element.attribute('href')).not_to match /^?download$/
expect(page.mmv_download_link_element.attribute('href')).not_to match /\/thumb\//
expect(page.mmv_download_preview_link_element.attribute('href')).not_to match /\/thumb\//
end
end
Then /^the download links should be the (\d+) thumbnail$/ do |thumb_size|
on(E2ETestPage) do |page|
page.wait_until { page.mmv_download_link_element.attribute('href').match thumb_size }
expect(page.mmv_download_link_element.attribute('href')).to match /^?download$/
expect(page.mmv_download_preview_link_element.attribute('href')).not_to match /^?download$/
expect(page.mmv_download_preview_link_element.attribute('href')).to match thumb_size
end
end
Then /^the attribution area should be collapsed$/ do
expect(on(E2ETestPage).mmv_download_attribution_area_element.when_present.attribute('class')).to match 'mw-mmv-download-attribution-collapsed'
end
Then /^the attribution area should be open$/ do
expect(on(E2ETestPage).mmv_download_attribution_area_element.when_present.attribute('class')).not_to match 'mw-mmv-download-attribution-collapsed'
end