From 1671a07d7d4510c1a04df408b5611c89791100fa Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 4 Jul 2016 14:56:00 +0100 Subject: [PATCH] Allow browser tests to add more revisions easily This allows an arbitrary number of revisions to be created on a page very easily. The page created will have a name relating to RevisionSlider suffixed by a random float. The base logic for this is taken from: Ic165f108517c534a4b1c12883621b3624c7b0336 This patch also removes the @vagrant tags as RevisonSlider is not yet in vragrant. Please see T139296 for the ticket to add it. Bug: T133278 Change-Id: I8a25db411bee2fa44555a23d1a840907a185c998 --- tests/browser/features/betafeature.feature | 11 ++++------- tests/browser/features/help.feature | 9 +++------ .../support/step_definitions/common_steps.rb | 15 ++++++++------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/tests/browser/features/betafeature.feature b/tests/browser/features/betafeature.feature index 11db0511..1a026af9 100644 --- a/tests/browser/features/betafeature.feature +++ b/tests/browser/features/betafeature.feature @@ -1,19 +1,16 @@ -@chrome @en.wikipedia.beta.wmflabs.org @firefox @test2.wikipedia.org @vagrant @integration +@chrome @en.wikipedia.beta.wmflabs.org @firefox @integration Feature: RevisionSlider betafeature Background: Given I am logged in - And The page "RevisionSliderTestPage1" has the following edits: - | RS text | - | RS longer text | - | RS less text | + And a page with 2 revision(s) exists Scenario: RevisionSlider is not loaded when feature disabled Given RevisionSlider is disabled as a beta feature - And I am on the "RevisionSliderTestPage1" diff page + And I am on the diff page Then There should not be a RevisionSlider placeholder Scenario: RevisionSlider is loaded when feature enabled Given RevisionSlider is enabled as a beta feature - And I am on the "RevisionSliderTestPage1" diff page + And I am on the diff page And The RevisionSlider has loaded Then There should be a RevisionSlider container \ No newline at end of file diff --git a/tests/browser/features/help.feature b/tests/browser/features/help.feature index 1b4d2039..f3a275b8 100644 --- a/tests/browser/features/help.feature +++ b/tests/browser/features/help.feature @@ -1,14 +1,11 @@ -@chrome @en.wikipedia.beta.wmflabs.org @firefox @test2.wikipedia.org @vagrant @integration +@chrome @en.wikipedia.beta.wmflabs.org @firefox @integration Feature: RevisionSlider help Background: Given I am logged in - And The page "RevisionSliderTestPage1" has the following edits: - | RS text | - | RS longer text | - | RS less text | + And a page with 2 revision(s) exists And I have reset my preferences And RevisionSlider is enabled as a beta feature - And I am on the "RevisionSliderTestPage1" diff page + And I am on the diff page Scenario: RevisionSlider tutorial is present on first load only Given The RevisionSlider has loaded diff --git a/tests/browser/features/support/step_definitions/common_steps.rb b/tests/browser/features/support/step_definitions/common_steps.rb index 56a65859..d8cf7961 100644 --- a/tests/browser/features/support/step_definitions/common_steps.rb +++ b/tests/browser/features/support/step_definitions/common_steps.rb @@ -1,14 +1,15 @@ -Given(/^I am on the "(.*?)" page$/) do |page| - visit(ArticlePage, using_params: { article_name: page }) +Given(/^I am on the page$/) do + visit(ArticlePage, using_params: { article_name: "RevisionSlider-#{@random_string}" }) end -Given(/^I am on the "(.*?)" diff page$/) do |page| - visit(ArticlePage, using_params: { article_name: page, query: 'type=revision&diff=' }) +Given(/^I am on the diff page$/) do + visit(ArticlePage, using_params: { article_name: "RevisionSlider-#{@random_string}", query: 'type=revision&diff=' }) end -Given(/^The page "(.+)" has the following edits:$/) do |page, table| - page = page.gsub(' ', '_') - table.rows.each { |(text)| api.edit(title: page, text: text) } +Given(/^a page with (\d+) revision\(s\) exists$/) do |number_of_revisions| + (1..number_of_revisions.to_i).each do |i| + api.edit(title: "RevisionSlider-#{@random_string}", text: "Text-#{i}") + end end Given(/^I refresh the page$/) do