From 8ace297b082cc5273d98cd15ce360ee0d2c64dec Mon Sep 17 00:00:00 2001 From: Pieter Frenssen <pieter@frenssen.be> Date: Mon, 26 Dec 2016 18:28:23 +0100 Subject: [PATCH] Test blackbox scenarios against a static HTML site. Fixes #310. --- .travis.yml | 5 ++++- behat.yml.dist | 2 +- features/blackbox.feature | 4 ++-- fixtures/blackbox/community.html | 10 ++++++++++ fixtures/blackbox/download.html | 11 +++++++++++ fixtures/blackbox/form.html | 17 +++++++++++++++++ fixtures/blackbox/index.html | 23 +++++++++++++++++++++++ fixtures/blackbox/irc.html | 13 +++++++++++++ fixtures/blackbox/user.html | 12 ++++++++++++ 9 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 fixtures/blackbox/community.html create mode 100644 fixtures/blackbox/download.html create mode 100644 fixtures/blackbox/form.html create mode 100644 fixtures/blackbox/index.html create mode 100644 fixtures/blackbox/irc.html create mode 100644 fixtures/blackbox/user.html diff --git a/.travis.yml b/.travis.yml index 050bc420..18ce4cf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,10 +55,13 @@ before_script: - test ${DRUPAL_VERSION} -eq 8 && export PROJECT_NAME='drupal-8.1.x' || export PROJECT_NAME="drupal-${DRUPAL_VERSION}.x" # Set sendmail so drush doesn't throw an error during site install. - echo "sendmail_path='true'" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'` - # Setup a stack Drupal 6 install to test api abilities. + # Download and install Drupal so we can test API abilities. - mysql -e 'create database drupal' - drush --quiet dl ${PROJECT_NAME} --all --drupal-project-rename=drupal - drush --yes --root=$PWD/drupal site-install --db-url=mysql://travis:@127.0.0.1/drupal + # Copy the static HTML that is used for blackbox testing in the web root. + - cp -r fixtures/blackbox $PWD/drupal + # Copy our test module to the correct location. - cp -r fixtures/drupal${DRUPAL_VERSION}/modules/behat_test ${MODULE_PATH} - cd drupal - drush --yes en behat_test diff --git a/behat.yml.dist b/behat.yml.dist index 62a37d33..eb9bcce0 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -14,7 +14,7 @@ default: Behat\MinkExtension: goutte: ~ zombie: ~ - base_url: http://drupal.org + base_url: http://127.0.0.1:8888/blackbox javascript_session: zombie Drupal\DrupalExtension: blackbox: ~ diff --git a/features/blackbox.feature b/features/blackbox.feature index 96549dd2..59a43368 100644 --- a/features/blackbox.feature +++ b/features/blackbox.feature @@ -10,7 +10,7 @@ Feature: Test DrupalContext Then I should see the heading "Download" in the "content" region Scenario: Clicking content in a region - Given I am at "community" + Given I am at "community.html" When I click "IRC" in the "content" region Then I should see "Page status" in the "right sidebar" And I should see the link "Drupal News" in the "footer" region @@ -62,7 +62,7 @@ Feature: Test DrupalContext Then I should see "Drupal" in the "h1" element with the "id" attribute set to "site-name" in the "left header" region Scenario: Error messages - Given I am on "/user" + Given I am on "user.html" When I press "Log in" Then I should see the error message "Password field is required" And I should not see the error message "Sorry, unrecognized username or password" diff --git a/fixtures/blackbox/community.html b/fixtures/blackbox/community.html new file mode 100644 index 00000000..6b13a757 --- /dev/null +++ b/fixtures/blackbox/community.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>Where is the Drupal community? | Drupal.org</title> + </head> + <body> + <div id="content"> + <a href="irc.html">IRC</a> + </div> + </body> +</html> diff --git a/fixtures/blackbox/download.html b/fixtures/blackbox/download.html new file mode 100644 index 00000000..fb4d5fcb --- /dev/null +++ b/fixtures/blackbox/download.html @@ -0,0 +1,11 @@ +<html> + <head> + <title>Download & Extend | Drupal.org</title> + </head> + <body> + <div id="content"> + <h2>Download</h2> + <a href="index.html">Distributions</a> + </div> + </body> +</html> diff --git a/fixtures/blackbox/form.html b/fixtures/blackbox/form.html new file mode 100644 index 00000000..b06f6531 --- /dev/null +++ b/fixtures/blackbox/form.html @@ -0,0 +1,17 @@ +<html> + <head> + <title>Search results | Drupal.org</title> + </head> + <body> + </div> + <div id="aside-region"> + <a href="index.html">Search again</a> + </div> + <div class="messages error"> + <ul> + <li>Username or email field is required.</li> + <li>Password field is required.</li> + </ul> + </div> + </body> +</html> diff --git a/fixtures/blackbox/index.html b/fixtures/blackbox/index.html new file mode 100644 index 00000000..d50b7dba --- /dev/null +++ b/fixtures/blackbox/index.html @@ -0,0 +1,23 @@ +<html> + <head> + <title>Drupal - Open Source CMS | Drupal.org</title> + </head> + <body> + <div id="nav-header"> + <div id="header-left"> + <h1 id="site-name">Drupal</h1> + <p>Build something amazing.</p> + <form action="form.html"> + <label for="search">Search…</label> + <input id="search" name="search" type="text"/> + <input type="submit" value="Search"/> + </form> + </div> + <div id="header-right"> + <a href="download.html">Download & Extend</a> + </div> + </div> + <div id="footer"> + </div> + </body> +</html> diff --git a/fixtures/blackbox/irc.html b/fixtures/blackbox/irc.html new file mode 100644 index 00000000..a853ae69 --- /dev/null +++ b/fixtures/blackbox/irc.html @@ -0,0 +1,13 @@ +<html> + <head> + <title>Chat with the Drupal community on IRC | Drupal.org</title> + </head> + <body> + <div id="aside-region"> + <p>Page status"</p> + </div> + <div id="footer"> + <a href="index.html">Drupal News</a> + </div> + </body> +</html> diff --git a/fixtures/blackbox/user.html b/fixtures/blackbox/user.html new file mode 100644 index 00000000..0082078e --- /dev/null +++ b/fixtures/blackbox/user.html @@ -0,0 +1,12 @@ +<html> + <head> + <title>Log in | Drupal.org</title> + </head> + <body> + <div id="content"> + <form action="form.html"> + <input type="submit" value="Log in"/> + </form> + </div> + </body> +</html>