mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 08:13:38 +00:00
Add tests for viewing options panel
Change-Id: Ic7a856ac4d94f4a65224f4c6373938da7b05f0fd
This commit is contained in:
parent
1853540cd3
commit
feb8e43571
|
@ -229,6 +229,7 @@ class MultimediaViewerHooks {
|
|||
'tests/qunit/mmv/ui/mmv.ui.reuse.tab.test.js',
|
||||
'tests/qunit/mmv/ui/mmv.ui.reuse.utils.test.js',
|
||||
'tests/qunit/mmv/ui/mmv.ui.truncatableTextField.test.js',
|
||||
'tests/qunit/mmv/ui/mmv.ui.viewingOptions.test.js',
|
||||
'tests/qunit/mmv/mmv.testhelpers.js',
|
||||
),
|
||||
'dependencies' => array(
|
||||
|
|
44
tests/browser/features/mmv.options.feature
Normal file
44
tests/browser/features/mmv.options.feature
Normal file
|
@ -0,0 +1,44 @@
|
|||
@en.wikipedia.beta.wmflabs.org @firefox @chrome @internet_explorer_9 @internet_explorer_10 @internet_explorer_11 @safari @test2.wikipedia.org
|
||||
Feature: Options
|
||||
|
||||
Background:
|
||||
Given I am viewing an image using MMV
|
||||
|
||||
Scenario: Clicking the X icon on the enable confirmation closes the options menu
|
||||
Given I reenable MMV
|
||||
When I click the enable X icon
|
||||
Then the options menu should disappear
|
||||
|
||||
Scenario: Clicking the X icon on the disable confirmation closes the options menu
|
||||
Given I disable MMV
|
||||
When I click the disable X icon
|
||||
Then the options menu should disappear
|
||||
|
||||
Scenario: Clicking the image closes the options menu
|
||||
Given I click the options icon
|
||||
When I click the image
|
||||
Then the options menu should disappear
|
||||
|
||||
Scenario: Clicking cancel closes the options menu
|
||||
Given I click the options icon
|
||||
When I click the disable cancel button
|
||||
Then the options menu should disappear
|
||||
|
||||
Scenario: Clicking the options icon brings up the options menu
|
||||
When I click the options icon
|
||||
Then the options menu should appear with the prompt to disable
|
||||
|
||||
Scenario: Clicking enable shows the confirmation
|
||||
Given I click the options icon with MMV disabled
|
||||
When I click the enable button
|
||||
Then the enable confirmation should appear
|
||||
|
||||
Scenario: Clicking disable shows the confirmation
|
||||
Given I click the options icon
|
||||
When I click the disable button
|
||||
Then the disable confirmation should appear
|
||||
|
||||
Scenario: Disabling media viewer makes the next thumbnail click go to the file page
|
||||
Given I disable and close MMV
|
||||
When I click on the first image in the article
|
||||
Then I am taken to the file page
|
121
tests/browser/features/step_definitions/mmv_download_steps.rb
Normal file
121
tests/browser/features/step_definitions/mmv_download_steps.rb
Normal file
|
@ -0,0 +1,121 @@
|
|||
# encoding: utf-8
|
||||
|
||||
Given /^I open the download menu$/ do
|
||||
step "I click the download icon"
|
||||
step "the download menu should appear"
|
||||
end
|
||||
|
||||
Given /^the attribution area is open$/ do
|
||||
step "I click on the attribution area"
|
||||
end
|
||||
|
||||
Given /^I open the download dropdown$/ do
|
||||
step "I open the download menu"
|
||||
step "the download image size label should match the original"
|
||||
step "the download links should be the original image"
|
||||
step "I click the download down arrow icon"
|
||||
step "the download size options should appear"
|
||||
end
|
||||
|
||||
When /^I click the download icon$/ do
|
||||
on(E2ETestPage).mmv_download_icon_element.click
|
||||
end
|
||||
|
||||
When /^I click the download down arrow icon$/ do
|
||||
on(E2ETestPage).mmv_download_down_arrow_icon_element.click
|
||||
end
|
||||
|
||||
When /^I click on the attribution area$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.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].click
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download menu should appear$/ do
|
||||
on(E2ETestPage).mmv_download_menu_element.when_present.should be_visible
|
||||
end
|
||||
|
||||
Then /^the download menu should disappear$/ do
|
||||
on(E2ETestPage).mmv_download_menu_element.should_not be_visible
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the original$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "4000 × 3000 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the small size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "193 × 145 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the medium size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "640 × 480 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the large size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "1200 × 900 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download size options should appear$/ do
|
||||
on(E2ETestPage).mmv_download_size_menu_element.when_present.should be_visible
|
||||
end
|
||||
|
||||
Then /^the download size options should disappear$/ do
|
||||
on(E2ETestPage).mmv_download_size_menu_element.when_not_present
|
||||
end
|
||||
|
||||
Then /^the download links should be the original image$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
page.mmv_download_link_element.attribute('href').should match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /^?download$/
|
||||
page.mmv_download_link_element.attribute('href').should_not match /\/thumb\//
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /\/thumb\//
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download links should be the (\d+) thumbnail$/ do |thumb_size|
|
||||
on(E2ETestPage) do |page|
|
||||
Watir::Wait.until { page.mmv_download_link_element.attribute('href').match thumb_size }
|
||||
page.mmv_download_link_element.attribute('href').should match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should match thumb_size
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download links should be the small thumbnail$/ do
|
||||
step "the download links should be the 193 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the download links should be the medium thumbnail$/ do
|
||||
step "the download links should be the 640 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the download links should be the large thumbnail$/ do
|
||||
step "the download links should be the 1200 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the attribution area should be collapsed$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.attribute('class').should match /mw-mmv-download-attribution-collapsed/
|
||||
end
|
||||
|
||||
Then /^the attribution area should be open$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.attribute('class').should_not match /mw-mmv-download-attribution-collapsed/
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
# encoding: utf-8
|
||||
|
||||
When /^I click the next arrow$/ do
|
||||
on(E2ETestPage).mmv_next_button_element.when_present.click
|
||||
end
|
||||
|
||||
When /^I click the previous arrow$/ do
|
||||
on(E2ETestPage).mmv_previous_button_element.when_present.click
|
||||
end
|
||||
|
||||
When /^I press the browser back button$/ do
|
||||
on(E2ETestPage).execute_script("window.history.back();");
|
||||
end
|
||||
|
||||
Then /^the image and metadata of the next image should appear$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
check_elements_in_viewer_for_image3 page
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the image and metadata of the previous image should appear$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
check_elements_in_viewer_for_image1 page
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the wiki article should be scrolled to the same position as before opening MMV$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
@scrollDifference = page.execute_script("return $(window).scrollTop();") - @articleScrollTop
|
||||
@scrollDifference.abs.should be < 2
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should be navigated back to the original wiki article$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
page.image1_in_article_element.should be_visible
|
||||
page.mmv_wrapper_element.should_not be_visible
|
||||
end
|
||||
end
|
69
tests/browser/features/step_definitions/mmv_options_steps.rb
Normal file
69
tests/browser/features/step_definitions/mmv_options_steps.rb
Normal file
|
@ -0,0 +1,69 @@
|
|||
# encoding: utf-8
|
||||
|
||||
When /^I click the options icon$/ do
|
||||
on(E2ETestPage).mmv_options_icon_element.click
|
||||
end
|
||||
|
||||
Then /^the options menu should appear with the prompt to disable$/ do
|
||||
on(E2ETestPage).mmv_options_menu_disable_element.should be_visible
|
||||
end
|
||||
|
||||
Then /^the options menu should disappear$/ do
|
||||
on(E2ETestPage).mmv_options_menu_disable_element.should_not be_visible
|
||||
end
|
||||
|
||||
When /^I click the enable button$/ do
|
||||
on(E2ETestPage).mmv_options_enable_button_element.click
|
||||
end
|
||||
|
||||
When /^I click the disable button$/ do
|
||||
on(E2ETestPage).mmv_options_disable_button_element.click
|
||||
end
|
||||
|
||||
When /^I click the disable cancel button$/ do
|
||||
on(E2ETestPage).mmv_options_disable_cancel_button_element.click
|
||||
end
|
||||
|
||||
When /^I click the enable X icon$/ do
|
||||
on(E2ETestPage).mmv_options_enable_x_icon_element.click
|
||||
end
|
||||
|
||||
When /^I click the disable X icon$/ do
|
||||
on(E2ETestPage).mmv_options_disable_x_icon_element.click
|
||||
end
|
||||
|
||||
When /^I disable MMV$/ do
|
||||
step "I click the options icon"
|
||||
step "I click the disable button"
|
||||
end
|
||||
|
||||
When /^I reenable MMV$/ do
|
||||
step "I disable MMV"
|
||||
step "I click the options icon"
|
||||
step "I click the enable button"
|
||||
end
|
||||
|
||||
When /^I click the options icon with MMV disabled$/ do
|
||||
step "I disable MMV"
|
||||
step "I click the options icon"
|
||||
end
|
||||
|
||||
When /^I disable and close MMV$/ do
|
||||
step "I disable MMV"
|
||||
step "I close MMV"
|
||||
end
|
||||
|
||||
Then /^the disable confirmation should appear$/ do
|
||||
on(E2ETestPage).mmv_options_disable_confirmation_element.should be_visible
|
||||
end
|
||||
|
||||
Then /^the enable confirmation should appear$/ do
|
||||
on(E2ETestPage).mmv_options_enable_confirmation_element.should be_visible
|
||||
end
|
||||
|
||||
Then /^I am taken to the file page$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
page.current_url.should match /\/wiki\/File:/
|
||||
page.current_url.should_not match /#mediaviewer/
|
||||
end
|
||||
end
|
|
@ -1,3 +1,7 @@
|
|||
When /^I click on an unrelated image in the article to warm up the browser cache$/ do
|
||||
on(E2ETestPage).other_image_in_article
|
||||
end
|
||||
|
||||
Given /^I visit the Commons page$/ do
|
||||
@commons_open_time = Time.now.getutc
|
||||
@browser.goto "https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg"
|
||||
|
|
|
@ -5,29 +5,12 @@ Given /^I am at a wiki article with at least two embedded pictures$/ do
|
|||
on(E2ETestPage).image1_in_article_element.should be_visible
|
||||
end
|
||||
|
||||
Given /^I open the download menu$/ do
|
||||
step "I click the download icon"
|
||||
step "the download menu should appear"
|
||||
end
|
||||
|
||||
Given /^I am viewing an image using MMV$/ do
|
||||
step "I am at a wiki article with at least two embedded pictures"
|
||||
step "I click on the second image in the article"
|
||||
step "the image metadata and the image itself should be there"
|
||||
end
|
||||
|
||||
Given /^the attribution area is open$/ do
|
||||
step "I click on the attribution area"
|
||||
end
|
||||
|
||||
Given /^I open the download dropdown$/ do
|
||||
step "I open the download menu"
|
||||
step "the download image size label should match the original"
|
||||
step "the download links should be the original image"
|
||||
step "I click the download down arrow icon"
|
||||
step "the download size options should appear"
|
||||
end
|
||||
|
||||
When /^I click on the first image in the article$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# We store the offset of the image as the scroll position and scroll to it, because cucumber/selenium
|
||||
|
@ -52,78 +35,14 @@ When /^I click on the second image in the article$/ do
|
|||
end
|
||||
end
|
||||
|
||||
When /^I click on an unrelated image in the article to warm up the browser cache$/ do
|
||||
on(E2ETestPage).other_image_in_article
|
||||
end
|
||||
|
||||
When /^I click the next arrow$/ do
|
||||
on(E2ETestPage).mmv_next_button_element.when_present.click
|
||||
end
|
||||
|
||||
When /^I click the previous arrow$/ do
|
||||
on(E2ETestPage).mmv_previous_button_element.when_present.click
|
||||
end
|
||||
|
||||
When /^I close MMV$/ do
|
||||
on(E2ETestPage).mmv_close_button_element.when_present(30).click
|
||||
end
|
||||
|
||||
When /^I press the browser back button$/ do
|
||||
on(E2ETestPage).execute_script("window.history.back();");
|
||||
end
|
||||
|
||||
When /^I click the download icon$/ do
|
||||
on(E2ETestPage).mmv_download_icon_element.click
|
||||
end
|
||||
|
||||
When /^I click the image$/ do
|
||||
on(E2ETestPage).mmv_image_div_element.click
|
||||
end
|
||||
|
||||
When /^I click the download down arrow icon$/ do
|
||||
on(E2ETestPage).mmv_download_down_arrow_icon_element.click
|
||||
end
|
||||
|
||||
When /^I click on the attribution area$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.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].click
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should be navigated back to the original wiki article$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
page.image1_in_article_element.should be_visible
|
||||
page.mmv_wrapper_element.should_not be_visible
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the image and metadata of the next image should appear$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
check_elements_in_viewer_for_image3 page
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the image metadata and the image itself should be there$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# MMV was launched, article is not visible now
|
||||
|
@ -132,91 +51,6 @@ Then /^the image metadata and the image itself should be there$/ do
|
|||
end
|
||||
end
|
||||
|
||||
Then /^the image and metadata of the previous image should appear$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
check_elements_in_viewer_for_image1 page
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the wiki article should be scrolled to the same position as before opening MMV$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
@scrollDifference = page.execute_script("return $(window).scrollTop();") - @articleScrollTop
|
||||
@scrollDifference.abs.should be < 2
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download menu should appear$/ do
|
||||
on(E2ETestPage).mmv_download_menu_element.when_present.should be_visible
|
||||
end
|
||||
|
||||
Then /^the download menu should disappear$/ do
|
||||
on(E2ETestPage).mmv_download_menu_element.should_not be_visible
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the original$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "4000 × 3000 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the small size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "193 × 145 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the medium size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "640 × 480 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download image size label should match the large size$/ do
|
||||
on(E2ETestPage).mmv_download_size_label_element.when_present.text.should eq "1200 × 900 px jpg"
|
||||
end
|
||||
|
||||
Then /^the download size options should appear$/ do
|
||||
on(E2ETestPage).mmv_download_size_menu_element.when_present.should be_visible
|
||||
end
|
||||
|
||||
Then /^the download size options should disappear$/ do
|
||||
on(E2ETestPage).mmv_download_size_menu_element.when_not_present
|
||||
end
|
||||
|
||||
Then /^the download links should be the original image$/ do
|
||||
on(E2ETestPage) do |page|
|
||||
page.mmv_download_link_element.attribute('href').should match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /^?download$/
|
||||
page.mmv_download_link_element.attribute('href').should_not match /\/thumb\//
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /\/thumb\//
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download links should be the (\d+) thumbnail$/ do |thumb_size|
|
||||
on(E2ETestPage) do |page|
|
||||
Watir::Wait.until { page.mmv_download_link_element.attribute('href').match thumb_size }
|
||||
page.mmv_download_link_element.attribute('href').should match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should_not match /^?download$/
|
||||
page.mmv_download_preview_link_element.attribute('href').should match thumb_size
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the download links should be the small thumbnail$/ do
|
||||
step "the download links should be the 193 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the download links should be the medium thumbnail$/ do
|
||||
step "the download links should be the 640 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the download links should be the large thumbnail$/ do
|
||||
step "the download links should be the 1200 thumbnail"
|
||||
end
|
||||
|
||||
Then /^the attribution area should be collapsed$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.attribute('class').should match /mw-mmv-download-attribution-collapsed/
|
||||
end
|
||||
|
||||
Then /^the attribution area should be open$/ do
|
||||
on(E2ETestPage).mmv_download_attribution_area_element.attribute('class').should_not match /mw-mmv-download-attribution-collapsed/
|
||||
end
|
||||
|
||||
# Helper function that verifies the presence of various elements in viewer
|
||||
# while looking at image1 (Kerala)
|
||||
def check_elements_in_viewer_for_image1(page)
|
||||
|
|
|
@ -45,12 +45,41 @@ class E2ETestPage < CommonsPage
|
|||
span(:mmv_download_size_label, class: "mw-mmv-download-image-size")
|
||||
span(:mmv_download_down_arrow_icon, class: "mw-mmv-download-select-menu")
|
||||
div(:mmv_download_size_menu_container, class: "mw-mmv-download-size")
|
||||
div(:mmv_download_size_menu) { |page| page.mmv_download_size_menu_container_element.div_element(class: "oo-ui-selectWidget") }
|
||||
div(:mmv_download_size_menu) {
|
||||
|page| page.mmv_download_size_menu_container_element.div_element(class: "oo-ui-selectWidget")
|
||||
}
|
||||
divs(:mmv_download_size_options, class: "oo-ui-menuItemWidget")
|
||||
a(:mmv_download_link, class: "mw-mmv-download-go-button")
|
||||
a(:mmv_download_preview_link, class: "mw-mmv-download-preview-link")
|
||||
div(:mmv_download_attribution_area, class: "mw-mmv-download-attribution")
|
||||
p(:mmv_download_attribution_area_close_icon, class: "mw-mmv-download-attribution-close-button")
|
||||
div(:mmv_download_attribution_area_input_container, class: "mw-mmv-download-attr-input")
|
||||
text_field(:mmv_download_attribution_area_input) { |page| page.mmv_download_attribution_area_input_container_element.text_field_element }
|
||||
text_field(:mmv_download_attribution_area_input) {
|
||||
|page| page.mmv_download_attribution_area_input_container_element.text_field_element
|
||||
}
|
||||
|
||||
# Options
|
||||
div(:mmv_options_icon, class: "mw-mmv-options-button")
|
||||
div(:mmv_options_menu_disable, class: "mw-mmv-options-disable")
|
||||
div(:mmv_options_menu_enable, class: "mw-mmv-options-enable")
|
||||
button(:mmv_options_enable_button) {
|
||||
|page| page.mmv_options_menu_enable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-submit-button")
|
||||
}
|
||||
button(:mmv_options_disable_button) {
|
||||
|page| page.mmv_options_menu_disable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-submit-button")
|
||||
}
|
||||
button(:mmv_options_enable_cancel_button) {
|
||||
|page| page.mmv_options_menu_enable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-cancel-button")
|
||||
}
|
||||
button(:mmv_options_disable_cancel_button) {
|
||||
|page| page.mmv_options_menu_disable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-cancel-button")
|
||||
}
|
||||
div(:mmv_options_disable_confirmation, class: "mw-mmv-disable-confirmation")
|
||||
div(:mmv_options_disable_x_icon) {
|
||||
|page| page.mmv_options_disable_confirmation_element.div_element(class: "mw-mmv-confirmation-close")
|
||||
}
|
||||
div(:mmv_options_enable_confirmation, class: "mw-mmv-enable-confirmation")
|
||||
div(:mmv_options_enable_x_icon) {
|
||||
|page| page.mmv_options_enable_confirmation_element.div_element(class: "mw-mmv-confirmation-close")
|
||||
}
|
||||
end
|
||||
|
|
131
tests/qunit/mmv/ui/mmv.ui.viewingOptions.test.js
Normal file
131
tests/qunit/mmv/ui/mmv.ui.viewingOptions.test.js
Normal file
|
@ -0,0 +1,131 @@
|
|||
( function ( mw, $ ) {
|
||||
function makeDialog( initialise ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
$button = $( '<div>' ).appendTo( $qf ),
|
||||
dialog = new mw.mmv.ui.OptionsDialog( $qf, $button, { setMediaViewerEnabledOnClick : $.noop } );
|
||||
|
||||
if ( initialise ) {
|
||||
dialog.initPanel();
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
QUnit.module( 'mmv.ui.viewingOptions', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sanity test', 1, function ( assert ) {
|
||||
var dialog = makeDialog();
|
||||
assert.ok( dialog, 'Dialog is created successfully' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Initialisation functions', 4, function ( assert ) {
|
||||
var dialog = makeDialog( true );
|
||||
|
||||
assert.ok( dialog.$disableDiv, 'Disable div is created.' );
|
||||
assert.ok( dialog.$enableDiv, 'Enable div is created.' );
|
||||
assert.ok( dialog.$disableConfirmation, 'Disable confirmation is created.' );
|
||||
assert.ok( dialog.$enableConfirmation, 'Enable confirmation is created.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Disable', 17, function ( assert ) {
|
||||
var $header, $icon, $text, $textHeader, $textBody,
|
||||
$submitButton, $cancelButton,
|
||||
dialog = makeDialog(),
|
||||
deferred = $.Deferred();
|
||||
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', function() {
|
||||
return deferred;
|
||||
} );
|
||||
|
||||
dialog.initDisableDiv();
|
||||
|
||||
$header = dialog.$disableDiv.find( 'h3.mw-mmv-options-dialog-header' );
|
||||
$icon = dialog.$disableDiv.find( 'div.mw-mmv-options-icon' );
|
||||
|
||||
$text = dialog.$disableDiv.find( 'div.mw-mmv-options-text' );
|
||||
$textHeader = $text.find( 'p.mw-mmv-options-text-header' );
|
||||
$textBody = $text.find( 'p.mw-mmv-options-text-body' );
|
||||
$submitButton = dialog.$disableDiv.find( 'button.mw-mmv-options-submit-button' );
|
||||
$cancelButton = dialog.$disableDiv.find( 'button.mw-mmv-options-cancel-button' );
|
||||
|
||||
assert.strictEqual( $header.length, 1, 'Disable header created successfully.' );
|
||||
assert.strictEqual( $header.text(), 'Disable Media Viewer?', 'Disable header has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $icon.length, 1, 'Icon created successfully.' );
|
||||
assert.strictEqual( $icon.html(), ' ', 'Icon has a blank space in it.' );
|
||||
|
||||
assert.ok( $text, 'Text div created successfully.' );
|
||||
assert.strictEqual( $textHeader.length, 1, 'Text header created successfully.' );
|
||||
assert.strictEqual( $textHeader.text(), 'Skip this viewing feature for all files.', 'Text header has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $textBody.length, 1, 'Text body created successfully.' );
|
||||
assert.strictEqual( $textBody.text(), 'You can enable it later through the file details page.', 'Text body has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $submitButton.length, 1, 'Disable button created successfully.' );
|
||||
assert.strictEqual( $submitButton.text(), 'Disable Media Viewer', 'Disable button has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $cancelButton.length, 1, 'Cancel button created successfully.' );
|
||||
assert.strictEqual( $cancelButton.text(), 'Cancel', 'Cancel button has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
$submitButton.click();
|
||||
|
||||
assert.ok( !dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), 'Disable confirmation not shown yet' );
|
||||
assert.ok( !dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), 'Disable confirmation not shown yet' );
|
||||
|
||||
// Pretend that the async call in mmv.js succeeded
|
||||
deferred.resolve();
|
||||
|
||||
// The confirmation should appear
|
||||
assert.ok( dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), 'Disable confirmation shown' );
|
||||
assert.ok( dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), 'Disable confirmation shown' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Enable', 15, function ( assert ) {
|
||||
var $header, $icon, $text, $textHeader,
|
||||
$submitButton, $cancelButton,
|
||||
dialog = makeDialog(),
|
||||
deferred = $.Deferred();
|
||||
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', function() {
|
||||
return deferred;
|
||||
} );
|
||||
|
||||
dialog.initEnableDiv();
|
||||
|
||||
$header = dialog.$enableDiv.find( 'h3.mw-mmv-options-dialog-header' );
|
||||
$icon = dialog.$enableDiv.find( 'div.mw-mmv-options-icon' );
|
||||
|
||||
$text = dialog.$enableDiv.find( 'div.mw-mmv-options-text' );
|
||||
$textHeader = $text.find( 'p.mw-mmv-options-text-header' );
|
||||
$submitButton = dialog.$enableDiv.find( 'button.mw-mmv-options-submit-button' );
|
||||
$cancelButton = dialog.$enableDiv.find( 'button.mw-mmv-options-cancel-button' );
|
||||
|
||||
assert.strictEqual( $header.length, 1, 'Enable header created successfully.' );
|
||||
assert.strictEqual( $header.text(), 'Enable Media Viewer?', 'Enable header has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $icon.length, 1, 'Icon created successfully.' );
|
||||
assert.strictEqual( $icon.html(), ' ', 'Icon has a blank space in it.' );
|
||||
|
||||
assert.ok( $text, 'Text div created successfully.' );
|
||||
assert.strictEqual( $textHeader.length, 1, 'Text header created successfully.' );
|
||||
assert.strictEqual( $textHeader.text(), 'Enable this media viewing feature for all files by default.', 'Text header has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $submitButton.length, 1, 'Enable button created successfully.' );
|
||||
assert.strictEqual( $submitButton.text(), 'Enable Media Viewer', 'Enable button has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
assert.strictEqual( $cancelButton.length, 1, 'Cancel button created successfully.' );
|
||||
assert.strictEqual( $cancelButton.text(), 'Cancel', 'Cancel button has correct text (if this fails, it may be due to i18n differences)' );
|
||||
|
||||
$submitButton.click();
|
||||
|
||||
assert.ok( !dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), 'Enable confirmation not shown yet' );
|
||||
assert.ok( !dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), 'Enable confirmation not shown yet' );
|
||||
|
||||
// Pretend that the async call in mmv.js succeeded
|
||||
deferred.resolve();
|
||||
|
||||
// The confirmation should appear
|
||||
assert.ok( dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), 'Enable confirmation shown' );
|
||||
assert.ok( dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), 'Enable confirmation shown' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
Loading…
Reference in a new issue