MNT Add behat tests

This commit is contained in:
Steve Boyd 2021-10-01 19:55:27 +13:00
parent b4c210f211
commit 3da3567a7a
13 changed files with 89 additions and 3 deletions

View File

@ -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"

29
behat.yml Normal file
View File

@ -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

View File

@ -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": {

View File

View File

@ -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" "<p>My <a href='http://fsdjoifidsohfiohfsoifhiodshfhdosi.com'>link</a> content</p>"
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"

View File

View File

@ -0,0 +1,9 @@
<?php
namespace SilverStripe\ExternalLinks\Tests\Behat\Context;
use SilverStripe\BehatExtension\Context\SilverStripeContext;
class FeatureContext extends SilverStripeContext
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace SilverStripe\ExternalLinks\Tests\Behat\Context;
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;
class FixtureContext extends BaseFixtureContext
{
}