Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/226085
Change subject: Browser tests: make faster ...................................................................... Browser tests: make faster * Convert logged in tests to anonymous * Use api instead of UI for preconditions Change-Id: I08228ea1b4b565c014b1127dbce54676f552b304 --- M tests/browser/features/action_menu_permalink.feature M tests/browser/features/anon_interface.feature M tests/browser/features/description.feature M tests/browser/features/edit_existing.feature M tests/browser/features/flow_in_recent_changes.feature M tests/browser/features/flow_logged_in.feature M tests/browser/features/flow_no_javascript.feature M tests/browser/features/mark_topic_as_resolved.feature M tests/browser/features/moderation.feature M tests/browser/features/new_topic.feature M tests/browser/features/post_links.feature M tests/browser/features/reopen_topic.feature M tests/browser/features/reply.feature M tests/browser/features/sorting_topics.feature M tests/browser/features/special_enableflow.feature A tests/browser/features/step_definitions/api_steps.rb M tests/browser/features/step_definitions/reply_steps.rb M tests/browser/features/support/env.rb M tests/browser/features/support/pages/abstract_flow_page.rb M tests/browser/features/suppress.feature M tests/browser/features/thank.feature M tests/browser/features/watch.feature 22 files changed, 154 insertions(+), 170 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/85/226085/1 diff --git a/tests/browser/features/action_menu_permalink.feature b/tests/browser/features/action_menu_permalink.feature index cbeb5b5..03f6bc2 100644 --- a/tests/browser/features/action_menu_permalink.feature +++ b/tests/browser/features/action_menu_permalink.feature @@ -1,14 +1,13 @@ @chrome @firefox @internet_explorer_10 -@clean @login +@clean @en.wikipedia.beta.wmflabs.org Feature: Actions menu Permalink Background: - Given I am logged in + Given there is a new topic with title "Permalinktest" And I am on Flow page Scenario: Topic Actions menu Permalink - Given I have created a Flow topic with title "Permalinktest" When I hover on the Topic Actions link And I click Permalink from the Actions menu And I am viewing Topic page @@ -16,15 +15,13 @@ And the top post should have a heading which contains "Permalinktest" Scenario: Actions menu Permalink - Given I have created a Flow topic - And I reply with comment "this is my response" + Given I reply with comment "this is my response" When I select the permalink for the second post of the first topic Then I am viewing Topic page And I see only one topic on the page And the highlighted comment is "this is my response" Scenario: Old style topic permalink - Given I have created a Flow topic with title "Permalinktest" When I go to an old style permalink to my topic And I am viewing Topic page Then I see only one topic on the page diff --git a/tests/browser/features/anon_interface.feature b/tests/browser/features/anon_interface.feature index a9f95f4..25b2049 100644 --- a/tests/browser/features/anon_interface.feature +++ b/tests/browser/features/anon_interface.feature @@ -1,11 +1,10 @@ -@chrome @firefox @internet_explorer_10 @phantomjs -@clean @login +@chrome @firefox @internet_explorer_10 +@clean @en.wikipedia.beta.wmflabs.org Feature: Check the interface for anonymous users Scenario: Anon does not see block or actions - Given I am on Flow page - And I have created a Flow topic - # which is not hidden (this is implicit from the above step) - When I see a flow creator element - Then the block author link should not be visible + Given there is a new topic + When I am on Flow page + Then I see a flow creator element + And the block author link should not be visible diff --git a/tests/browser/features/description.feature b/tests/browser/features/description.feature index 41b1af0..cdc1976 100644 --- a/tests/browser/features/description.feature +++ b/tests/browser/features/description.feature @@ -1,5 +1,4 @@ @chrome @firefox @internet_explorer_10 -@login @en.wikipedia.beta.wmflabs.org Feature: Board description diff --git a/tests/browser/features/edit_existing.feature b/tests/browser/features/edit_existing.feature index edd99d9..c3bd8a9 100644 --- a/tests/browser/features/edit_existing.feature +++ b/tests/browser/features/edit_existing.feature @@ -3,24 +3,22 @@ @en.wikipedia.beta.wmflabs.org Feature: Edit existing title - Assumes that the test Flow page has at least two topics (with posts). - Background: - Given I am logged in - And I am on Flow page - And I have created a Flow topic + Given there is a new topic with title "original title" Scenario: Edit an existing title + Given I am on Flow page When I hover on the Topic Actions link - And I click the Edit title action - And I edit the title field with Title edited - And I save the new title + And I click the Edit title action + And I edit the title field with Title edited + And I save the new title Then the top post should have a heading which contains "Title edited" - @phantomjs Scenario: Edit existing post + Given I am logged in + And I am on Flow page When I hover on the Post Actions link - And I click Edit post - And I edit the post field with Post edited - And I save the new post + And I click Edit post + And I edit the post field with Post edited + And I save the new post Then the saved post should contain Post edited diff --git a/tests/browser/features/flow_in_recent_changes.feature b/tests/browser/features/flow_in_recent_changes.feature index 8ecc0a4..94a8b87 100644 --- a/tests/browser/features/flow_in_recent_changes.feature +++ b/tests/browser/features/flow_in_recent_changes.feature @@ -1,11 +1,10 @@ @chrome @firefox @internet_explorer_10 -@clean @login +@clean @en.wikipedia.beta.wmflabs.org Feature: Flow updates are in Recent Changes Background: - Given I am logged in - And I am on Flow page + Given I am on Flow page And I have created a Flow topic with title "New topic should be in Recent Changes" Scenario: New topic is in Recent Changes diff --git a/tests/browser/features/flow_logged_in.feature b/tests/browser/features/flow_logged_in.feature index 1c4e1d6..d109db4 100644 --- a/tests/browser/features/flow_logged_in.feature +++ b/tests/browser/features/flow_logged_in.feature @@ -6,30 +6,29 @@ It requires the cldr extension, a "Flow QA" page, and a "Selenium user" who has permission to flow-delete (usually 'sysop'/administrator user right), to flow-suppress (usually the 'oversight' user right), and to block (usually 'sysop'). - If the Selenium_user's Flow editor is VisualEditor, then the flow_page - definitions have to change. Background: - Given I am logged in - And I have created a Flow topic + Given there is a new topic created by me + And I am logged in + And I am on Flow page Scenario: Add new Flow topic and show author and block links Given the author link is visible - And the talk to author link is not visible - And the block author link is not visible - # hover doesn't work in IE, bug 67723 + And the talk to author link is not visible + And the block author link is not visible When I hover over the author link Then the talk to author link should be visible - And the block author link should be visible + And the block author link should be visible + # todo: replace with actual tests on those actions Scenario: Post Actions When I hover on the Post Actions link Then I should see a Hide button - And I should see a Delete button - And I should see a Suppress button + And I should see a Delete button + And I should see a Suppress button Scenario: Topic Actions When I hover on the Topic Actions link Then I should see a Hide topic button - And I should see a Delete topic button - And I should see a Suppress topic button + And I should see a Delete topic button + And I should see a Suppress topic button diff --git a/tests/browser/features/flow_no_javascript.feature b/tests/browser/features/flow_no_javascript.feature index 0437696..9932bc9 100644 --- a/tests/browser/features/flow_no_javascript.feature +++ b/tests/browser/features/flow_no_javascript.feature @@ -1,5 +1,4 @@ -@custom-browser @firefox -@login +@firefox @en.wikipedia.beta.wmflabs.org Feature: Basic site for legacy devices diff --git a/tests/browser/features/mark_topic_as_resolved.feature b/tests/browser/features/mark_topic_as_resolved.feature index d6f5f45..ae8d14e 100644 --- a/tests/browser/features/mark_topic_as_resolved.feature +++ b/tests/browser/features/mark_topic_as_resolved.feature @@ -4,9 +4,9 @@ Feature: Mark topic as resolved Background: - Given I am logged in + Given there is a new topic + And I am logged in And I am on Flow page - And I have created a Flow topic Scenario: Resolving a topic without a summary When I mark the first topic as resolved diff --git a/tests/browser/features/moderation.feature b/tests/browser/features/moderation.feature index 2f0bd10..7bfb63d 100644 --- a/tests/browser/features/moderation.feature +++ b/tests/browser/features/moderation.feature @@ -3,35 +3,15 @@ @en.wikipedia.beta.wmflabs.org Feature: Moderation - Assumes Flow is enabled for the User_talk namespace. - Background: - Given I am logged in - And I am on Flow page + Given there is a new topic + And I am logged in + And I am on Flow page Scenario: Deleting a topic - Given I have created a Flow topic with title "Deletemeifyoudare" When I hover on the Topic Actions link - And I click the Delete topic button - And I see a dialog box - And I give reason for deletion as being "He's a naughty boy" - And I click Delete topic + And I click the Delete topic button + And I see a dialog box + And I give reason for deletion as being "He's a naughty boy" + And I click Delete topic Then the top post should be marked as deleted - - Scenario: Cancelling a dialog without text - Given I have created a Flow topic with title "Testing cancel deletion of topic" - When I hover on the Topic Actions link - And I click the Delete topic button - And I see a dialog box - And I cancel the dialog - Then I do not see the dialog box - - Scenario: Cancelling a dialog with text - Given I have created a Flow topic with title "Testing cancel deletion of topic" - When I hover on the Topic Actions link - And I click the Delete topic button - And I see a dialog box - And I give reason for deletion as being "About to change my mind" - And I cancel the dialog - And I confirm - Then I do not see the dialog box diff --git a/tests/browser/features/new_topic.feature b/tests/browser/features/new_topic.feature index a9ae4a4..2eef363 100644 --- a/tests/browser/features/new_topic.feature +++ b/tests/browser/features/new_topic.feature @@ -1,16 +1,11 @@ -@chrome @firefox @internet_explorer_10 @phantomjs +@chrome @firefox @internet_explorer_10 @en.wikipedia.beta.wmflabs.org Feature: Creating a new topic Background: Given I am on Flow page - Scenario: Cannot create a new topic without content - When I type "Anonymous user topic creation test" into the new topic title field - Then the Save New Topic button should be disabled - Scenario: Add new Flow topic as anonymous user When I have created a Flow topic with title "Anonymous user topic creation" - # TODO the terminology below is terrible, posts don't have headings. It's the top topic's title and first post. Then the top post should have a heading which contains "Anonymous user topic creation" - And the top post should have content which contains "Anonymous user topic creation" + And the top post should have content which contains "Anonymous user topic creation" diff --git a/tests/browser/features/post_links.feature b/tests/browser/features/post_links.feature index 5c1c39b..54cbe52 100644 --- a/tests/browser/features/post_links.feature +++ b/tests/browser/features/post_links.feature @@ -1,14 +1,12 @@ @chrome @firefox @internet_explorer_10 -@clean @login +@clean @en.wikipedia.beta.wmflabs.org Feature: Follow user links - Scenario: User links takes me to the user page - Given I am logged in - And I am on Flow page - And I have created a Flow topic - And I see a flow creator element - When I click the flow creator element - Then I am on my user page + Background: + Given there is a new topic created by me - + Scenario: User links takes me to the user page + Given I am on Flow page + When I click the flow creator element + Then I am on my user page \ No newline at end of file diff --git a/tests/browser/features/reopen_topic.feature b/tests/browser/features/reopen_topic.feature index 71d35ef..e64556e 100644 --- a/tests/browser/features/reopen_topic.feature +++ b/tests/browser/features/reopen_topic.feature @@ -4,9 +4,9 @@ Feature: Reopen a resolved topic Background: - Given I am logged in + Given there is a new topic + And I am logged in And I am on Flow page - And I have created a Flow topic Scenario: Reopening a resolved topic and changing the summary Given I mark the first topic as resolved diff --git a/tests/browser/features/reply.feature b/tests/browser/features/reply.feature index 0213c0c..b3614b9 100644 --- a/tests/browser/features/reply.feature +++ b/tests/browser/features/reply.feature @@ -3,19 +3,16 @@ @en.wikipedia.beta.wmflabs.org Feature: Replying - Background: - Given I am logged in - And I am on Flow page - - @phantomjs Scenario: I can reply - Given I have created a Flow topic with title "Reply test" - When I reply with comment "Boom boom shake shake the room" - Then the top post's first reply should contain the text "Boom boom shake shake the room" + Given there is a new topic + And I am on Flow page + When I reply with comment "hi there" + Then the top post's first reply should contain the text "hi there" - @phantomjs Scenario: Replying updates watched state - Given I have created a Flow topic with title "Reply watch test" - And I am not watching my new Flow topic + Given there is a new topic created by me + And I am logged in + And I am on Flow page + And I am not watching my new Flow topic When I reply with comment "I want to watch this title" Then I should see an unwatch link on the topic diff --git a/tests/browser/features/sorting_topics.feature b/tests/browser/features/sorting_topics.feature index 177ecd1..d0da113 100644 --- a/tests/browser/features/sorting_topics.feature +++ b/tests/browser/features/sorting_topics.feature @@ -1,5 +1,5 @@ @chrome @firefox @internet_explorer_10 @phantomjs -@clean @login +@clean @en.wikipedia.beta.wmflabs.org Feature: Sorting topics @@ -8,14 +8,14 @@ Scenario: Switch topic sorting to Recently Active Topics When I click Newest topics link - And I click Recently active topics choice + And I click Recently active topics choice Then the Flow page should show Recently active topics link - And the Flow page should not show Newest topics link + And the Flow page should not show Newest topics link Scenario: Switch topic sorting to Recently Active Topics and then back to Newest topics When I click Newest topics link - And I click Recently active topics choice - And I click Recently active topics link - And I click Newest topics choice + And I click Recently active topics choice + And I click Recently active topics link + And I click Newest topics choice Then the Flow page should show Newest topics link - And the Flow page should not show Recently active topics link + And the Flow page should not show Recently active topics link diff --git a/tests/browser/features/special_enableflow.feature b/tests/browser/features/special_enableflow.feature index def6a87..6952a43 100644 --- a/tests/browser/features/special_enableflow.feature +++ b/tests/browser/features/special_enableflow.feature @@ -3,24 +3,21 @@ @en.wikipedia.beta.wmflabs.org Feature: Flow Special:EnableFlow enables new flow boards - - - Background: Given I am logged in - And I navigate to enable flow page + And I navigate to enable flow page Scenario: Enabling a new Flow page When I enable a new Flow board Then I get confirmation for enabling a new Flow board - And I click on the new Flow board link - And The page I am on is a Flow board + And I click on the new Flow board link + And The page I am on is a Flow board Scenario: Enabling a Flow page on existing page Given I have an existing talk page When I enable a new Flow board on the talk page Then I get confirmation for enabling a new Flow board - And I click on the new Flow board link - And The page I am on is a Flow board - And I click the archive link - And The archive contains the original text + And I click on the new Flow board link + And The page I am on is a Flow board + And I click the archive link + And The archive contains the original text diff --git a/tests/browser/features/step_definitions/api_steps.rb b/tests/browser/features/step_definitions/api_steps.rb new file mode 100644 index 0000000..4b9674e --- /dev/null +++ b/tests/browser/features/step_definitions/api_steps.rb @@ -0,0 +1,13 @@ +Given(/^there is a new topic with title \"(.*?)\"$/) do |title| + title = @data_manager.get title + api.action('flow', submodule: 'new-topic', page: 'Talk:Flow_QA', nttopic: title, ntcontent: 'created via API') +end + +Given(/^there is a new topic$/) do + step "there is a new topic with title \"title\"" +end + +Given(/^there is a new topic created by me$/) do + api.log_in user, password unless api.logged_in? + step "there is a new topic with title \"title\"" +end \ No newline at end of file diff --git a/tests/browser/features/step_definitions/reply_steps.rb b/tests/browser/features/step_definitions/reply_steps.rb index 9aa5472..4d098f9 100644 --- a/tests/browser/features/step_definitions/reply_steps.rb +++ b/tests/browser/features/step_definitions/reply_steps.rb @@ -17,7 +17,7 @@ on(FlowPage) do |page| page.new_reply_save_element.when_not_present page.new_reply_placeholder_element.when_present.click - page.new_reply_editor_element.send_keys(content) + page.new_reply_editor_element.when_present.send_keys(content) page.new_reply_save_element.when_present.click page.new_reply_save_element.when_not_present page.flow_first_topic_element.paragraph_element(text: content).when_present diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index fa9bdeb..0fba164 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -4,3 +4,11 @@ require 'mediawiki_selenium/step_definitions' require_relative 'div_extension' + +if ENV['PAGE_WAIT_TIMEOUT'] + PageObject.default_page_wait = ENV['PAGE_WAIT_TIMEOUT'].to_i +end + +if ENV['ELEMENT_WAIT_TIMEOUT'] + PageObject.default_element_wait = ENV['ELEMENT_WAIT_TIMEOUT'].to_i +end diff --git a/tests/browser/features/support/pages/abstract_flow_page.rb b/tests/browser/features/support/pages/abstract_flow_page.rb index dfb2fa4..e77e960 100644 --- a/tests/browser/features/support/pages/abstract_flow_page.rb +++ b/tests/browser/features/support/pages/abstract_flow_page.rb @@ -1,8 +1,9 @@ require_relative 'wiki_page' class AbstractFlowPage < WikiPage - def visualeditor_or_textarea(parent_form_class) - parent = form_element(class: parent_form_class).when_present + def visualeditor_or_textarea(form) + parent = form.is_a?(String) ? form_element(css: form) : form + parent.when_present if parent.div_element(class: 'flow-editor-visualeditor').exists? parent.div_element(class: 've-ce-documentNode') else @@ -20,7 +21,7 @@ form(:edit_description_form, css: ".edit-header-form") a(:sidebar_toggle, class: "side-rail-toggle-button") def edit_description_textbox_element - visualeditor_or_textarea 'edit-header-form' + visualeditor_or_textarea '.edit-header-form' end # If page has an archive template from a flow conversion @@ -164,7 +165,7 @@ page.summary_element.button_element(text: 'Update summary') end def edit_summary_element - visualeditor_or_textarea 'flow-edit-form' + visualeditor_or_textarea '.flow-edit-form' end span(:first_topic_resolved_mark) do |page| page.flow_first_topic_heading_element.span_element(css: '.mw-ui-icon-check') @@ -240,7 +241,7 @@ text_field(:new_topic_title, name: "topiclist_topic") def new_topic_body_element - visualeditor_or_textarea 'flow-newtopic-form' + visualeditor_or_textarea '.flow-newtopic-form' end button(:new_topic_cancel, css: ".flow-newtopic-form .mw-ui-destructive") @@ -257,7 +258,8 @@ end def new_reply_editor_element - visualeditor_or_textarea 'flow-reply-form' + form = flow_first_topic_element.form_element(class: 'flow-reply-form') + visualeditor_or_textarea form end button(:new_reply_cancel, css: ".flow-reply-form .mw-ui-destructive") @@ -267,7 +269,7 @@ # Editing post workflow def post_edit_element - visualeditor_or_textarea 'flow-edit-post-form' + visualeditor_or_textarea '.flow-edit-post-form' end button(:change_post_save, css: ".flow-edit-post-form .mw-ui-constructive") diff --git a/tests/browser/features/suppress.feature b/tests/browser/features/suppress.feature index 034aadf..628146d 100644 --- a/tests/browser/features/suppress.feature +++ b/tests/browser/features/suppress.feature @@ -7,22 +7,24 @@ Background: Given I am logged in - And I am on Flow page Scenario: Suppressing a topic - Given I have created a Flow topic with title "suppress-topic" + Given there is a new topic with title "suppress-topic" + And I am on Flow page When I suppress the first topic with reason "I suppress you" Then the top post should be marked as suppressed Scenario: Restoring a topic - Given I have created a Flow topic with title "suppress-restore-topic" + Given there is a new topic with title "suppress-restore-topic" + And I am on Flow page When I suppress the first topic with reason "I suppress you temporarily" And I undo the suppression Then I see the topic "suppress-restore-topic" on the board And everybody sees the topic "suppress-restore-topic" on the board Scenario: A suppressed topic is not in board history - Given I have created a Flow topic with title "suppress-not-in-history" + Given there is a new topic with title "suppress-not-in-history" + And I am on Flow page And I suppress the first topic When I visit the board history page Then I see the following entries in board history @@ -37,7 +39,8 @@ |commented on |suppress-not-in-history| Scenario: A suppressed and restored topic is in board history - Given I have created a Flow topic with title "suppress-restore-in-history" + Given there is a new topic with title "suppress-restore-in-history" + And I am on Flow page And I have suppressed and restored the first topic When I visit the board history page Then I see the following entries in board history @@ -56,7 +59,8 @@ |suppressed the topic|suppress-restore-in-history| Scenario: A suppressed and restored topic is in topic history - Given I have created a Flow topic with title "suppress-restore-in-history" + Given there is a new topic with title "suppress-restore-in-history" + And I am on Flow page And I have suppressed and restored the first topic When I visit the topic history page Then I see the following entries in topic history diff --git a/tests/browser/features/thank.feature b/tests/browser/features/thank.feature index 54af7ec..697de9d 100644 --- a/tests/browser/features/thank.feature +++ b/tests/browser/features/thank.feature @@ -4,22 +4,21 @@ Feature: Thank author of a Flow post Scenario: Anon does not see Thank button - Given the "Talk:Flow QA" page has a new unmoderated topic created by me - And I am on Flow page + Given there is a new topic + When I am on Flow page Then I should not see a Thank button @login Scenario: Thank the user Given I am logged in - And the most recent topic on "Talk:Flow QA" is written by another user - And I am on Flow page - And I see a Thank button + And the most recent topic on "Talk:Flow QA" is written by another user + And I am on Flow page When I click on the Thank button Then I should see the Thank button be replaced with Thanked button @login Scenario: I cannot thank my own post - Given I am logged in - And the "Talk:Flow QA" page has a new unmoderated topic created by me - And I am on Flow page + Given there is a new topic created by me + And I am logged in + When I am on Flow page Then I should not see a Thank button diff --git a/tests/browser/features/watch.feature b/tests/browser/features/watch.feature index 704ecd3..7937e00 100644 --- a/tests/browser/features/watch.feature +++ b/tests/browser/features/watch.feature @@ -1,38 +1,39 @@ -@chrome @firefox @internet_explorer_10 @phantomjs +@chrome @firefox @internet_explorer_10 @clean @login @en.wikipedia.beta.wmflabs.org Feature: Watching/Unwatching Boards and Topics - Scenario: Watch topic - Given I am logged in - And I am on Flow page - And I have created a Flow topic - And I am not watching the Flow topic - When I click the Watch Topic link - Then I should see the Unwatch Topic link + Background: + Given there is a new topic - Scenario: Unwatch topic - Given I am logged in - And I am on Flow page - And I have created a Flow topic - And I am watching the Flow topic - When I click the Unwatch Topic link - Then I should see the Watch Topic link + Scenario: Watch topic + Given I am logged in + And I am on Flow page + And I am not watching the Flow topic + When I click the Watch Topic link + Then I should see the Unwatch Topic link - Scenario: Watch board - Given I am logged in - And I am on Flow page - And I am not watching the Flow board - When I click the Watch Board link - Then I should see the Unwatch Board link + Scenario: Unwatch topic + Given I am logged in + And I am on Flow page + And I am watching the Flow topic + When I click the Unwatch Topic link + Then I should see the Watch Topic link - Scenario: Unwatch board - Given I am logged in - And I am on Flow page - And I am watching the Flow board - When I click the Unwatch Board link - Then I should see the Watch Board link + Scenario: Watch board + Given I am logged in + And I am on Flow page + And I am not watching the Flow board + When I click the Watch Board link + Then I should see the Unwatch Board link - Scenario: No watch links for anonymous users - When I am on Flow page - Then I should not see any watch links + Scenario: Unwatch board + Given I am logged in + And I am on Flow page + And I am watching the Flow board + When I click the Unwatch Board link + Then I should see the Watch Board link + + Scenario: No watch links for anonymous users + When I am on Flow page + Then I should not see any watch links -- To view, visit https://gerrit.wikimedia.org/r/226085 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I08228ea1b4b565c014b1127dbce54676f552b304 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits