Bencmq has uploaded a new change for review. https://gerrit.wikimedia.org/r/123874
Change subject: [WIP] Browser tests for paging nagivation ...................................................................... [WIP] Browser tests for paging nagivation This feature tests for two things - Infinite scrolling should keep returning new (older) topics - 'Older posts' should load the old posts correctly Bug: 61340 Change-Id: I3d35f65367956f005cc3554301cc7a9cf0b17d19 --- A tests/browser/features/paging.feature M tests/browser/features/step_definitions/flow_steps.rb M tests/browser/features/support/pages/flow_page.rb 3 files changed, 90 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/74/123874/1 diff --git a/tests/browser/features/paging.feature b/tests/browser/features/paging.feature new file mode 100644 index 0000000..55fe5bc --- /dev/null +++ b/tests/browser/features/paging.feature @@ -0,0 +1,22 @@ [email protected] @en.wikipedia.beta.wmflabs.org @ee-prototype.wmflabs.org + +Feature: Navigate to older topics on pages with paging + + @clean + Scenario: Infinite scrolling + Given I am on Flow page + When I scroll down to the bottom of the page + # Alternatively - Then I can keep scrolling down 2 times to see older topics + Then I can keep scrolling down to see older topics + + @clean @login + Scenario: Scroll to see older topics that are initially not displayed + Given I am on Flow page + And I am logged in + And I have created a topic and note the content + And I have created 11 topics + When I refresh the page + Then I do not see the first topic + And I scroll down to the bottom of the page + And older topics are loaded in 10 seconds + And I see the first topic diff --git a/tests/browser/features/step_definitions/flow_steps.rb b/tests/browser/features/step_definitions/flow_steps.rb index 6ac6c30..ec05547 100644 --- a/tests/browser/features/step_definitions/flow_steps.rb +++ b/tests/browser/features/step_definitions/flow_steps.rb @@ -21,6 +21,25 @@ end end +Given(/^I have created a topic and note the content$/) do + @random_string2 = Random.new.rand.to_s + step "I am on Flow page" + step "I create a Special " + @random_string2 + " in Flow new topic" + step "I create a Body of Flow Topic into Flow body" + step "I click New topic save" + step "the Flow page should contain " + @random_string2 +end + +Given(/^I have created (.+) topics$/) do |count| + step "I am on Flow page" + count.to_i.times do + step "I create a Title of Flow Topic in Flow new topic" + step "I create a Body of Flow Topic into Flow body" + step "I click New topic save" + step "the Flow page should contain Title of Flow Topic" + end +end + When(/^I click the Post Actions link$/) do on(FlowPage).post_actions_link_element.when_present.click end @@ -54,6 +73,14 @@ When(/^I see a flow creator element$/) do on(FlowPage).author_link_element.should be_visible +end + +When(/^I scroll down to the bottom of the page$/) do + on(FlowPage).flow_body_element.send_keys :end +end + +When(/^I refresh the page$/) do + on(FlowPage).refresh end Then(/^I do not see an actions link$/) do @@ -104,3 +131,42 @@ Then(/^I should see a Suppress topic button$/) do on(FlowPage).topic_suppress_button_element.when_present.should be_visible end + +Then(/^I can keep scrolling down to see older topics$/) do + step "I can keep scrolling down -1 times to see older topics" +end + +Then(/^I can keep scrolling down (.+) times to see older topics$/) do |count| + # This step keeps scrolling down until no more old topics can be loaded. + # It asserts that after each loading, more topics are displayed. + on(FlowPage) do |page| + topic_count = page.div_elements(class: 'flow-topic-container').size + count = count.to_i + # infinite scrolling + while page.next_page_element.exists? and count != 0 + step "I scroll down to the bottom of the page" + step "older topics are loaded in 10 seconds" + + # there should be more topics loaded... + if topic_count >= page.div_elements(class: 'flow-topic-container').size + raise "New topics are not loaded" + else + topic_count = page.div_elements(class: 'flow-topic-container').size + count -= 1 + end + end + end +end + +Then (/^older topics are loaded in (.+) seconds$/) do |seconds| + on(FlowPage).loading_next_page_element.when_present # need sometime for next page to start loading + on(FlowPage).loading_next_page_element.when_not_present seconds.to_i +end + +Then(/^I do not see the first topic$/) do + on(FlowPage).flow_body.should_not match(@random_string2) +end + +Then(/^I see the first topic$/) do + on(FlowPage).flow_body.should match(@random_string2) +end diff --git a/tests/browser/features/support/pages/flow_page.rb b/tests/browser/features/support/pages/flow_page.rb index ac19e03..9d3b13c 100644 --- a/tests/browser/features/support/pages/flow_page.rb +++ b/tests/browser/features/support/pages/flow_page.rb @@ -67,4 +67,6 @@ a(:topic_actions_link, xpath: "//div[contains(concat(' ', normalize-space(@class), ' '), ' flow-topic-container ')]//a[text()='Actions']", index: actions_index) div(:topic_post, class: "flow-post-content", index: topic_index) div(:topic_title, class: "flow-topic-title", index: topic_index) + div(:next_page, class: "flow-paging-fwd") + div(:loading_next_page, class: "flow-paging-loading") end -- To view, visit https://gerrit.wikimedia.org/r/123874 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d35f65367956f005cc3554301cc7a9cf0b17d19 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Bencmq <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
