mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
MNT Update behat tests
This commit is contained in:
parent
b544032a22
commit
f816052f06
14
.github/workflows/docs.yml
vendored
Normal file
14
.github/workflows/docs.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Build Docs
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
paths:
|
||||||
|
- 'docs/en/userguide/**'
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build-docs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Run build hook
|
||||||
|
run: curl -X POST -d {} https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}
|
19
.github/workflows/main.yml
vendored
19
.github/workflows/main.yml
vendored
@ -1,14 +1,11 @@
|
|||||||
name: Build Docs
|
name: Module CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
pull_request:
|
||||||
- 'master'
|
|
||||||
paths:
|
|
||||||
- 'docs/en/userguide/**'
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
ci:
|
||||||
name: build-docs
|
uses: silverstripe/github-actions-ci-cd/.github/workflows/ci.yml@0.1.11
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
steps:
|
run_endtoend: true
|
||||||
- name: Run build hook
|
|
||||||
run: curl -X POST -d {} https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}
|
|
||||||
|
@ -6,3 +6,4 @@ import:
|
|||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- BEHAT_SUITE="contentreview"
|
- BEHAT_SUITE="contentreview"
|
||||||
|
- REQUIRE_EXTRA="symbiote/silverstripe-queuedjobs:^4"
|
||||||
|
26
behat.yml
26
behat.yml
@ -2,18 +2,19 @@ default:
|
|||||||
suites:
|
suites:
|
||||||
contentreview:
|
contentreview:
|
||||||
paths:
|
paths:
|
||||||
- '%paths.modules.contentreview%/tests/behat/features'
|
- "%paths.modules.contentreview%/tests/behat/features"
|
||||||
contexts:
|
contexts:
|
||||||
- SilverStripe\Framework\Tests\Behaviour\FeatureContext
|
- SilverStripe\Admin\Tests\Behat\Context\AdminContext
|
||||||
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
|
|
||||||
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
|
|
||||||
- SilverStripe\BehatExtension\Context\BasicContext
|
- SilverStripe\BehatExtension\Context\BasicContext
|
||||||
- SilverStripe\BehatExtension\Context\EmailContext
|
- SilverStripe\BehatExtension\Context\EmailContext
|
||||||
- SilverStripe\CMS\Tests\Behaviour\LoginContext
|
- SilverStripe\BehatExtension\Context\LoginContext
|
||||||
- SilverStripe\CMS\Tests\Behaviour\ThemeContext
|
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
|
||||||
- SilverStripe\CMS\Tests\Behaviour\FixtureContext:
|
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
|
||||||
# Note: double indent for args is intentional
|
- SilverStripe\ContentReview\Tests\Behat\Context\FeatureContext
|
||||||
- '%paths.modules.contentreview%/tests/behat/features/files/'
|
- SilverStripe\ContentReview\Tests\Behat\Context\FixtureContext
|
||||||
|
-
|
||||||
|
SilverStripe\ContentReview\Tests\Behat\Context\FixtureContext:
|
||||||
|
- "%paths.modules.contentreview%/tests/behat/files/"
|
||||||
|
|
||||||
extensions:
|
extensions:
|
||||||
SilverStripe\BehatExtension\MinkExtension:
|
SilverStripe\BehatExtension\MinkExtension:
|
||||||
@ -21,9 +22,8 @@ default:
|
|||||||
javascript_session: facebook_web_driver
|
javascript_session: facebook_web_driver
|
||||||
facebook_web_driver:
|
facebook_web_driver:
|
||||||
browser: chrome
|
browser: chrome
|
||||||
wd_host: "http://127.0.0.1:9515" #chromedriver port
|
wd_host: "http://127.0.0.1:9515"
|
||||||
browser_name: chrome
|
|
||||||
|
|
||||||
SilverStripe\BehatExtension\Extension:
|
SilverStripe\BehatExtension\Extension:
|
||||||
screenshot_path: '%paths.base%/artifacts/screenshots'
|
screenshot_path: "%paths.base%/artifacts/screenshots"
|
||||||
bootstrap_file: "vendor/silverstripe/cms/tests/behat/serve-bootstrap.php"
|
bootstrap_file: vendor/silverstripe/framework/tests/behat/serve-bootstrap.php
|
||||||
|
@ -42,7 +42,8 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"SilverStripe\\ContentReview\\": "src/",
|
"SilverStripe\\ContentReview\\": "src/",
|
||||||
"SilverStripe\\ContentReview\\Tests\\": "tests/php/"
|
"SilverStripe\\ContentReview\\Tests\\": "tests/php/",
|
||||||
|
"SilverStripe\\ContentReview\\Tests\\Behat\\Context\\": "tests/behat/src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
|
54
tests/behat/features/content-reviews.feature
Normal file
54
tests/behat/features/content-reviews.feature
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
Feature: Set up reviews
|
||||||
|
As a CMS user
|
||||||
|
I can set up content reviews for my content
|
||||||
|
In order to ensure my content gets reviewed regularly
|
||||||
|
|
||||||
|
Background:
|
||||||
|
# Note: the review date is deliberately in the past
|
||||||
|
Given a "page" "My page" with "Content"="<p>Welcome</p>", "NextReviewDate"="01/01/2017", "ReviewPeriodDays"="1"
|
||||||
|
And the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "FILE_EDIT_ALL"
|
||||||
|
And the "group" "FILEONLY group" has permissions "FILE_EDIT_ALL"
|
||||||
|
And a "member" "Ed" belonging to "EDITOR group" with "Email"="ed@example.com"
|
||||||
|
And a "member" "Phil" belonging to "FILEONLY group" with "Email"="phil@example.com"
|
||||||
|
# Login in as EDITOR once https://github.com/silverstripe/silverstripe-contentreview/pull/155 is merged
|
||||||
|
# And I am logged in with "EDITOR" permissions
|
||||||
|
And I am logged in with "ADMIN" permissions
|
||||||
|
And I go to "admin/pages"
|
||||||
|
And I click on "My page" in the tree
|
||||||
|
And I click the "Settings" CMS tab
|
||||||
|
And I click the "Content review" CMS tab
|
||||||
|
|
||||||
|
Scenario: I can set content reviewers to users and groups who can edit pages
|
||||||
|
When I select "Custom settings" from "Options" input group
|
||||||
|
And I wait for 1 second
|
||||||
|
|
||||||
|
# Test adding individual member based on them having access to the Pages section fo the CMS
|
||||||
|
Then the "#Form_EditForm_OwnerUsers" select element should have an option with an "Ed" label
|
||||||
|
And the "#Form_EditForm_OwnerUsers" select element should not have an option with a "Phil" label
|
||||||
|
|
||||||
|
# Test adding groups
|
||||||
|
Then the "#Form_EditForm_OwnerGroups" select element should have an option with an "EDITOR group" label
|
||||||
|
|
||||||
|
# Required to avoid "unsaved changed" browser dialog
|
||||||
|
Then I press the "Save" button
|
||||||
|
|
||||||
|
Scenario: There is an alert icon when a content review is overdue
|
||||||
|
When I select "Custom settings" from "Options" input group
|
||||||
|
And I wait for 1 second
|
||||||
|
Then I should not see the ".content-review__button" element
|
||||||
|
When I press the "Save" button
|
||||||
|
And I select "ADMIN group" from "Groups"
|
||||||
|
And I press the "Save" button
|
||||||
|
Then I should see the ".content-review__button" element
|
||||||
|
When I click on the ".content-review__button" element
|
||||||
|
Then I should see the ".modal" element
|
||||||
|
And I should see "Mark as reviewed"
|
||||||
|
|
||||||
|
# Fill in a review
|
||||||
|
When I fill in "Form_EditForm_ReviewContent_Review" with "My review"
|
||||||
|
And I press "Mark as reviewed"
|
||||||
|
And I wait for 1 second
|
||||||
|
Then I should see "Review successfully added"
|
||||||
|
When I click on the ".close" element
|
||||||
|
And I press the "Save" button
|
||||||
|
Then I should see "My review"
|
0
tests/behat/files/blank.txt
Normal file
0
tests/behat/files/blank.txt
Normal file
29
tests/behat/src/FeatureContext.php
Normal file
29
tests/behat/src/FeatureContext.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ContentReview\Tests\Behat\Context;
|
||||||
|
|
||||||
|
use SilverStripe\BehatExtension\Context\SilverStripeContext;
|
||||||
|
|
||||||
|
class FeatureContext extends SilverStripeContext
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Given /^the "([^"]*)" select element should(| not) have an option with (a|an) "([^"]*)" label$/
|
||||||
|
* @param string $id
|
||||||
|
* @param string $should
|
||||||
|
* @param string $label
|
||||||
|
*/
|
||||||
|
public function theSelectElementShouldHaveAnOptionWithALabel($id, $should, $label)
|
||||||
|
{
|
||||||
|
$n = $should === '' ? 1 : 0;
|
||||||
|
$js = <<<JS
|
||||||
|
;let hasLabel = 0;
|
||||||
|
document.querySelectorAll('#{$id} > option').forEach(function(option) {
|
||||||
|
if (option.innerHTML == '$label') {
|
||||||
|
hasLabel = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return hasLabel;
|
||||||
|
JS;
|
||||||
|
return $this->getSession()->evaluateScript($js) == $n;
|
||||||
|
}
|
||||||
|
}
|
9
tests/behat/src/FixtureContext.php
Normal file
9
tests/behat/src/FixtureContext.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ContentReview\Tests\Behat\Context;
|
||||||
|
|
||||||
|
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;
|
||||||
|
|
||||||
|
class FixtureContext extends BaseFixtureContext
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user