diff --git a/.travis.yml b/.travis.yml index c244c3b..0dadce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ version: ~> 1.0 import: - - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range.yml + - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range-behat.yml + +env: + global: + - REQUIRE_EXTRA="symbiote/silverstripe-queuedjobs:^4" diff --git a/behat.yml b/behat.yml new file mode 100644 index 0000000..f45b7fc --- /dev/null +++ b/behat.yml @@ -0,0 +1,29 @@ +default: + suites: + externallinks: + paths: + - "%paths.modules.externallinks%/tests/behat/features" + contexts: + - SilverStripe\Admin\Tests\Behat\Context\AdminContext + - SilverStripe\BehatExtension\Context\BasicContext + - SilverStripe\BehatExtension\Context\EmailContext + - SilverStripe\BehatExtension\Context\LoginContext + - SilverStripe\Framework\Tests\Behaviour\CmsFormsContext + - SilverStripe\Framework\Tests\Behaviour\CmsUiContext + - SilverStripe\ExternalLinks\Tests\Behat\Context\FeatureContext + - SilverStripe\ExternalLinks\Tests\Behat\Context\FixtureContext + - + SilverStripe\ExternalLinks\Tests\Behat\Context\FixtureContext: + - "%paths.modules.externallinks%/tests/behat/files/" + + extensions: + SilverStripe\BehatExtension\MinkExtension: + default_session: facebook_web_driver + javascript_session: facebook_web_driver + facebook_web_driver: + browser: chrome + wd_host: "http://127.0.0.1:9515" + + SilverStripe\BehatExtension\Extension: + screenshot_path: "%paths.base%/artifacts/screenshots" + bootstrap_file: vendor/silverstripe/framework/tests/behat/serve-bootstrap.php diff --git a/composer.json b/composer.json index ec36bca..3cca850 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,13 @@ "squizlabs/php_codesniffer": "^3.0" }, "suggest": { - "silverstripe/queuedjobs": "Provides a more efficient method of generating/updating the report" + "ssymbiote/silverstripe-queuedjobs": "Provides a more efficient method of generating/updating the report" }, "autoload": { "psr-4": { "SilverStripe\\ExternalLinks\\": "src/", - "SilverStripe\\ExternalLinks\\Tests\\": "tests/" + "SilverStripe\\ExternalLinks\\Tests\\": "tests/", + "SilverStripe\\ExternalLinks\\Tests\\Behat\\Context\\": "tests/behat/src/" } }, "extra": { diff --git a/tests/behat/_manifest_exclude b/tests/behat/_manifest_exclude new file mode 100644 index 0000000..e69de29 diff --git a/tests/behat/features/external-links.feature b/tests/behat/features/external-links.feature new file mode 100644 index 0000000..104039d --- /dev/null +++ b/tests/behat/features/external-links.feature @@ -0,0 +1,34 @@ +Feature: External links report + As a website user + I want to use the external links report + + Background: + Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" + # Need to use single quotes rather than escaped double quotes when defining the fixture otherwise + # it'll end up saved as " and the hyperlink will be wrong + # When the page is published it should be converted by tinymce to double quotes + Given a "page" "My page" has the "Content" "

My link content

" + + Scenario: Operate the external links report + Given I am logged in with "ADMIN" permissions + + # Publish page + When I go to "/admin/pages" + And I follow "My page" + And I press the "Publish" button + + # Run report + When I go to "/admin/reports" + And I follow "External broken links" + And I press the "Create new report" button + + # Run queuedjob, new job will be the first row + When I go to "/admin/queuedjobs" + When I click on the ".gridfield-button-jobexecute" element + And I wait for 15 seconds + + # Assert report + When I go to "/admin/reports" + And I follow "External broken links" + Then I should see "http://fsdjoifidsohfiohfsoifhiodshfhdosi.com" + And I should see "My page" diff --git a/tests/behat/files/blank.txt b/tests/behat/files/blank.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/behat/src/FeatureContext.php b/tests/behat/src/FeatureContext.php new file mode 100644 index 0000000..1d79bfa --- /dev/null +++ b/tests/behat/src/FeatureContext.php @@ -0,0 +1,9 @@ +