Bmansurov has uploaded a new change for review. https://gerrit.wikimedia.org/r/234710
Change subject: Add browser tests for external surveys ...................................................................... Add browser tests for external surveys Bug: T110225 Change-Id: I70a93e28d3ad9b40bd2ee5063c0e9d8ee1e3f96b --- M tests/browser/LocalSettings.php A tests/browser/features/external_survey.feature M tests/browser/features/internal_survey.feature M tests/browser/features/support/pages/article_page.rb M tests/browser/features/support/step_definitions/common_steps.rb A tests/browser/features/support/step_definitions/external_survey_steps.rb M tests/browser/features/support/step_definitions/internal_survey_steps.rb 7 files changed, 82 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys refs/changes/10/234710/1 diff --git a/tests/browser/LocalSettings.php b/tests/browser/LocalSettings.php index 4ffc204..7ac103d 100644 --- a/tests/browser/LocalSettings.php +++ b/tests/browser/LocalSettings.php @@ -18,4 +18,18 @@ "mobile" => array( "stable", "beta", "alpha" ), ), ), + array( + 'name' => 'external example survey', + 'type' => 'external', + "question" => "ext-quicksurveys-example-external-survey-question", + "description" => "ext-quicksurveys-example-external-survey-description", + "link" => "ext-quicksurveys-example-external-survey-link", + "privacyPolicy" => "ext-quicksurveys-example-external-survey-privacy-policy", + 'coverage' => .5, + 'enabled' => true, + 'platform' => array( + 'desktop' => array( 'stable' ), + 'mobile' => array( 'stable', 'beta', 'alpha' ), + ), + ) ); diff --git a/tests/browser/features/external_survey.feature b/tests/browser/features/external_survey.feature new file mode 100644 index 0000000..7dabdd2 --- /dev/null +++ b/tests/browser/features/external_survey.feature @@ -0,0 +1,32 @@ +@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @integration +Feature: External surveys + Background: + Given the quick survey test pages are installed + + Scenario: External survey is visible with flag + And I am on the "Quick survey test page stub" page with the external quick survey flag enabled + Then I should see the survey + + Scenario: External survey is not present without flag + And I'm not bucketed with storage key "ext-quicksurvey-external-example-survey" + And I am on the "Quick survey test page stub" page + And the page has fully loaded + Then I should not see the survey + + Scenario: External survey is visible when bucketed + And I'm bucketed with storage key "ext-quicksurvey-external-example-survey" + And I am on the "Quick survey test page stub" page + Then I should see the survey + + Scenario: External survey is not present when dismissed + And I've dismissed the storage key "ext-quicksurvey-external-example-survey" + And I am on the "Quick survey test page stub" page + And the page has fully loaded + Then I should not see the survey + + Scenario: User can participate in external survey + And I am on the "Quick survey test page stub" page with the external quick survey flag enabled + And I see the external survey + When I answer the external survey in the positive + Then I get thanks for my external survey feedback + diff --git a/tests/browser/features/internal_survey.feature b/tests/browser/features/internal_survey.feature index 99bde0a..bff406d 100644 --- a/tests/browser/features/internal_survey.feature +++ b/tests/browser/features/internal_survey.feature @@ -4,7 +4,7 @@ Given the quick survey test pages are installed Scenario: Internal survey is visible with flag - And I am on the "Quick survey test page stub" page with the quick survey flag enabled + And I am on the "Quick survey test page stub" page with the internal quick survey flag enabled Then I should see the survey Scenario: Internal survey is not present without flag @@ -25,7 +25,7 @@ Then I should not see the survey Scenario: User can participate in internal survey - And I am on the "Quick survey test page stub" page with the quick survey flag enabled - And I see the survey - When I answer the survey in the positive - Then I get thanks for my feedback + And I am on the "Quick survey test page stub" page with the internal quick survey flag enabled + And I see the internal survey + When I answer the internal survey in the positive + Then I get thanks for my internal survey feedback diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb index e970410..e8847e5 100644 --- a/tests/browser/features/support/pages/article_page.rb +++ b/tests/browser/features/support/pages/article_page.rb @@ -3,7 +3,7 @@ include PageObject page_url '<%= URI.encode(params[:article_name]) %>'\ - '<%=params[:query_string]%><%= params[:hash] %>' + '<%= URI.encode(params[:query_string])%><%= params[:hash] %>' div(:survey, css: '.panel') a(:survey_yes, css: '.panel .oo-ui-buttonSelectWidget .oo-ui-buttonElement-button', diff --git a/tests/browser/features/support/step_definitions/common_steps.rb b/tests/browser/features/support/step_definitions/common_steps.rb index e89c086..ab3f983 100644 --- a/tests/browser/features/support/step_definitions/common_steps.rb +++ b/tests/browser/features/support/step_definitions/common_steps.rb @@ -23,6 +23,22 @@ using_params: { article_name: arg1, query_string: '?quicksurvey=true' }) end +Given(/^I am on the "(.*?)" page with the internal quick survey flag enabled$/) do |arg1| + visit(ArticlePage, + using_params: { + article_name: arg1, + query_string: '?quicksurvey=internal-survey-internal example survey' + }) +end + +Given(/^I am on the "(.*?)" page with the external quick survey flag enabled$/) do |arg1| + visit(ArticlePage, + using_params: { + article_name: arg1, + query_string: '?quicksurvey=external-survey-external example survey' + }) +end + Given(/^I am on the "(.*?)" page$/) do |arg1| visit(ArticlePage, using_params: { article_name: arg1 }) end diff --git a/tests/browser/features/support/step_definitions/external_survey_steps.rb b/tests/browser/features/support/step_definitions/external_survey_steps.rb new file mode 100644 index 0000000..06fef22 --- /dev/null +++ b/tests/browser/features/support/step_definitions/external_survey_steps.rb @@ -0,0 +1,11 @@ +Given(/^I see the external survey$/) do + expect(on(ArticlePage).survey_element.when_present).to be_visible +end + +Given(/^I answer the external survey in the positive$/) do + on(ArticlePage).survey_yes_element.when_present.click +end + +Then(/^I get thanks for my external survey feedback$/) do + expect(on(ArticlePage).survey_complete_element.when_present).to be_visible +end diff --git a/tests/browser/features/support/step_definitions/internal_survey_steps.rb b/tests/browser/features/support/step_definitions/internal_survey_steps.rb index 1e375b2..ad53038 100644 --- a/tests/browser/features/support/step_definitions/internal_survey_steps.rb +++ b/tests/browser/features/support/step_definitions/internal_survey_steps.rb @@ -1,11 +1,11 @@ -Given(/^I see the survey$/) do +Given(/^I see the internal survey$/) do expect(on(ArticlePage).survey_element.when_present).to be_visible end -Given(/^I answer the survey in the positive$/) do +Given(/^I answer the internal survey in the positive$/) do on(ArticlePage).survey_yes_element.when_present.click end -Then(/^I get thanks for my feedback$/) do +Then(/^I get thanks for my internal survey feedback$/) do expect(on(ArticlePage).survey_complete_element.when_present).to be_visible end -- To view, visit https://gerrit.wikimedia.org/r/234710 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I70a93e28d3ad9b40bd2ee5063c0e9d8ee1e3f96b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/QuickSurveys Gerrit-Branch: dev Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits