2014-10-15 18:06:41 +00:00
|
|
|
When /^I click on an unrelated image in the article to warm up the browser cache$/ do
|
|
|
|
on(E2ETestPage).other_image_in_article
|
|
|
|
end
|
|
|
|
|
2014-04-01 08:46:48 +00:00
|
|
|
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"
|
|
|
|
end
|
|
|
|
|
|
|
|
Given /^I visit an unrelated Commons page to warm up the browser cache$/ do
|
|
|
|
@browser.goto "https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg"
|
|
|
|
end
|
|
|
|
|
|
|
|
Given /^I have a small browser window$/ do
|
|
|
|
@browser.window.resize_to 900, 700
|
|
|
|
end
|
|
|
|
|
|
|
|
Given /^I have an average browser window$/ do
|
|
|
|
@browser.window.resize_to 1366, 768
|
|
|
|
end
|
|
|
|
|
|
|
|
Given /^I have a large browser window$/ do
|
|
|
|
@browser.window.resize_to 1920, 1080
|
|
|
|
end
|
|
|
|
|
2014-04-24 14:52:13 +00:00
|
|
|
Given /^I am using a custom user agent$/ do
|
2014-09-17 21:48:44 +00:00
|
|
|
@browser = browser(test_name(@scenario), user_agent: ENV["BROWSER_USERAGENT"])
|
2014-04-24 14:52:13 +00:00
|
|
|
end
|
|
|
|
|
2014-04-01 08:46:48 +00:00
|
|
|
Then /^the File: page image is loaded$/ do
|
|
|
|
on(CommonsPage) do |page|
|
2014-09-17 21:48:44 +00:00
|
|
|
page.wait_for_image_load ".fullImageLink img"
|
2014-04-01 08:46:48 +00:00
|
|
|
#Has to be a global variable, otherwise it doesn't survive between scenarios
|
|
|
|
$commons_time = Time.now.getutc - @commons_open_time
|
2014-09-17 21:48:44 +00:00
|
|
|
page.log_performance type: "file-page", duration: $commons_time * 1000
|
2014-04-01 08:46:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^the MMV image is loaded in (\d+) percent of the time with a (.*) cache and an? (.*) browser window$/ do |percentage, cache, window_size|
|
2014-04-20 15:42:40 +00:00
|
|
|
on(E2ETestPage) do |page|
|
2014-09-17 21:48:44 +00:00
|
|
|
page.wait_for_image_load ".mw-mmv-image img"
|
2014-04-01 08:46:48 +00:00
|
|
|
mmv_time = Time.now.getutc - @image_click_time
|
2014-09-17 21:48:44 +00:00
|
|
|
page.log_performance type: "mmv", duration: mmv_time * 1000, cache: cache, windowSize: window_size
|
2014-04-01 08:46:48 +00:00
|
|
|
|
2014-09-17 21:48:44 +00:00
|
|
|
expected_time = $commons_time * (percentage.to_f / 100.0)
|
|
|
|
expect(mmv_time).to be < expected_time
|
2014-04-01 08:46:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|