summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/MultimediaViewer/tests/browser/features/step_definitions/mmv_download_steps.rb
blob: 1d94a80480537972306e4bf1cd727036db00b107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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(10).click
end

When /^I click on the attribution area$/ do
  on(E2ETestPage).mmv_download_attribution_area_element.when_present(10).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

When /^the download size options appear$/ do
  on(E2ETestPage).mmv_download_size_menu_element.when_present
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(10)
end

Then /^the download menu should appear$/ do
  expect(on(E2ETestPage).mmv_download_menu_element.when_present(10)).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(10).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 %r{/thumb/}
    expect(page.mmv_download_preview_link_element.attribute('href')).not_to match %r{/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(10).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