Dr0ptp4kt has uploaded a new change for review. https://gerrit.wikimedia.org/r/174042
Change subject: Prepare automation of Cucumber runs ...................................................................... Prepare automation of Cucumber runs Change-Id: I5f8e9c6790b2228c05a4fed4b37fbefa1dec0761 --- A tests/browser/README A tests/browser/cucumber_anon_prod.bash A tests/browser/cucumber_partner_prod.bash M tests/browser/features/header.feature M tests/browser/features/home.feature M tests/browser/features/login.feature 6 files changed, 132 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroPortal refs/changes/42/174042/1 diff --git a/tests/browser/README b/tests/browser/README new file mode 100644 index 0000000..7c695b1 --- /dev/null +++ b/tests/browser/README @@ -0,0 +1,7 @@ +The Cucumber scripts run daily. To get this going, run the BASH +scripts, and setup your ~/.zero/ directory, then get the following +into your crontab with crontab -e. + +# Daily: +30 14 * * * /home/user/ZeroPortal/tests/browser/cucumber_anon_prod.bash &>/dev/null +30 15 * * * /home/user/ZeroPortal/tests/browser/cucumber_partner_prod.bash &>/dev/null diff --git a/tests/browser/cucumber_anon_prod.bash b/tests/browser/cucumber_anon_prod.bash new file mode 100755 index 0000000..9db024d --- /dev/null +++ b/tests/browser/cucumber_anon_prod.bash @@ -0,0 +1,49 @@ +#! /bin/sh + +export PATH=/bin:$PATH +export SCREENSHOT_FAILURES=true +export HEADLESS=true +export MEDIAWIKI_URL=https://zero.wikimedia.org/wiki/ + +if [ ! -e ~/.zero/ ] +then + mkdir ~/.zero + error=true +fi +chmod 700 ~/.zero + +if [ ! -e ~/.zero/email ] +then + touch ~/.zero/email + echo "REPLACE_WITH_EMAIL" > ~/.zero/email + error=true +fi +chmod 600 ~/.zero/email + +if [ "$error" = true ] +then + echo "ERROR" + echo "=====" + echo "Go setup ~/.zero/email" + exit 1 +fi + +# okay, we look good to go +export EMAIL=`cat ~/.zero/email` +if [ ! -e reports/ ] +then + mkdir reports +fi +chmod 755 reports + +d=`date "+%Y%m%d-%H%M-%S"` +report="reports/cucumber_anon_prod-${d}.html" +screenshots="reports/cucumber_anon_prod_screenshots-${d}" +mkdir $screenshots +chmod 755 $screenshots +export SCREENSHOT_FAILURES_PATH=$screenshots +bundle exec cucumber --tags @anon -f html -o $report +if [ $? -eq 1 ] +then + echo "Partner portal ANON PROD failure. See attached." | mailx -s "Portal Cucumber: FAIL Anon Prod" -a $report $EMAIL +fi diff --git a/tests/browser/cucumber_partner_prod.bash b/tests/browser/cucumber_partner_prod.bash new file mode 100755 index 0000000..86cfcae --- /dev/null +++ b/tests/browser/cucumber_partner_prod.bash @@ -0,0 +1,68 @@ +#! /bin/sh + +export PATH=/bin:$PATH +export SCREENSHOT_FAILURES=true +export HEADLESS=true +export MEDIAWIKI_URL=https://zero.wikimedia.org/wiki/ + +if [ ! -e ~/.zero/ ] +then + mkdir ~/.zero + error=true +fi +chmod 700 ~/.zero + +if [ ! -e ~/.zero/prod.partner.u ] +then + touch ~/.zero/prod.partner.u + echo "REPLACE_W_PROD_TESTING_USERNAME" > ~/.zero/prod.partner.u + error=true +fi +chmod 600 ~/.zero/prod.partner.u + +if [ ! -e ~/.zero/prod.partner.p ] +then + touch ~/.zero/prod.partner.p + echo "REPLACE_W_PROD_TESTING_PASSWORD" > ~/.zero/prod.partner.p + error=true +fi +chmod 600 ~/.zero/prod.partner.p + +if [ ! -e ~/.zero/email ] +then + touch ~/.zero/email + echo "REPLACE_WITH_EMAIL" > ~/.zero/email + error=true +fi +chmod 600 ~/.zero/email + +if [ "$error" = true ] +then + echo "ERROR" + echo "=====" + echo "Go setup the ~/.zero/ partner files" + exit 1 +fi + +# okay, we look good to go +export MEDIAWIKI_USER=`cat ~/.zero/prod.partner.u` +export MEDIAWIKI_PASSWORD=`cat ~/.zero/prod.partner.p` +export EMAIL=`cat ~/.zero/email` + +if [ ! -e reports/ ] +then + mkdir reports +fi +chmod 755 reports + +d=`date "+%Y%m%d-%H%M-%S"` +report="reports/cucumber_partner_prod-${d}.html" +screenshots="reports/cucumber_partner_prod_screenshots-${d}" +mkdir $screenshots +chmod 755 $screenshots +export SCREENSHOT_FAILURES_PATH=$screenshots +bundle exec cucumber --tags @partner -f html -o $report +if [ $? -eq 1 ] +then + echo "Partner portal PARTNER PROD failure. See attached." | mailx -s "Portal Cucumber: FAIL Partner Prod" -a $report $EMAIL +fi diff --git a/tests/browser/features/header.feature b/tests/browser/features/header.feature index 2f5000c..9eaa6e8 100644 --- a/tests/browser/features/header.feature +++ b/tests/browser/features/header.feature @@ -6,6 +6,7 @@ Given I am on the home page When I am looking at the header + @anon Scenario: Anonymous user sees links Then I should see the links: | home | @@ -16,6 +17,7 @@ | sign up | And the home link should be highlighted + @partner Scenario: Logged in partner sees links Given I am logged in as a partner Then I should see the links: @@ -25,4 +27,4 @@ | faq | | admin portal | | logout | - And the home link should be highlighted \ No newline at end of file + And the home link should be highlighted diff --git a/tests/browser/features/home.feature b/tests/browser/features/home.feature index e99e3e1..c785011 100644 --- a/tests/browser/features/home.feature +++ b/tests/browser/features/home.feature @@ -1,3 +1,4 @@ +@anon @partner Feature: Home Scenario: Landing page elements are visible diff --git a/tests/browser/features/login.feature b/tests/browser/features/login.feature index f4275ae..0b4bf79 100644 --- a/tests/browser/features/login.feature +++ b/tests/browser/features/login.feature @@ -5,10 +5,12 @@ Background: Given I am on the login page - Scenario: Login is authorized + @partner + Scenario: Login is authorized When I login as a partner Then I should see a link to "logout" + @anon Scenario: Login is not authorized When I try to login with invalid credentials - Then I should not be logged in \ No newline at end of file + Then I should not be logged in -- To view, visit https://gerrit.wikimedia.org/r/174042 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5f8e9c6790b2228c05a4fed4b37fbefa1dec0761 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ZeroPortal Gerrit-Branch: master Gerrit-Owner: Dr0ptp4kt <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
