-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from creative-commoners/pulls/2.5/behat
MNT Update behat test
- Loading branch information
Showing
8 changed files
with
103 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
# Run sharedraftcontent behat tests with this command | ||
# Note that sharedraftcontent behat tests require CMS module | ||
# ========================================================================= # | ||
# chromedriver | ||
# vendor/bin/behat @sharedraftcontent | ||
# ========================================================================= # | ||
default: | ||
suites: | ||
sharedraftcontent: | ||
paths: | ||
- '%paths.modules.sharedraftcontent%/tests/Behat/features' | ||
- "%paths.modules.sharedraftcontent%/tests/behat/features" | ||
contexts: | ||
- SilverStripe\Framework\Tests\Behaviour\FeatureContext | ||
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext | ||
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext | ||
- 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\ShareDraftContent\Tests\Behat\Context\FeatureContext | ||
- SilverStripe\ShareDraftContent\Tests\Behat\Context\FixtureContext | ||
- | ||
SilverStripe\BehatExtension\Context\FixtureContext: | ||
- '%paths.modules.sharedraftcontent%/tests/Behat/files/' | ||
SilverStripe\ShareDraftContent\Tests\Behat\Context\FixtureContext: | ||
- "%paths.modules.sharedraftcontent%/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" #chromedriver port | ||
browser_name: chrome | ||
wd_host: "http://127.0.0.1:9515" | ||
|
||
SilverStripe\BehatExtension\Extension: | ||
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php | ||
screenshot_path: '%paths.base%/artifacts/screenshots' | ||
retry_seconds: 4 # default is 2 | ||
screenshot_path: "%paths.base%/artifacts/screenshots" | ||
bootstrap_file: vendor/silverstripe/framework/tests/behat/serve-bootstrap.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@javascript | ||
Feature: Share the draft version of a page | ||
As a CMS author | ||
I want to share the draft version of a page | ||
So that unauthenticated users can view draft changes before I publish them | ||
|
||
Background: | ||
Given a "page" "My page" with "Content"="Initial content" | ||
And the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" | ||
|
||
Scenario: I can generate a share draft link | ||
# Setup | ||
Given I am logged in with "EDITOR" permissions | ||
And I go to "/admin/pages" | ||
And I click on "My page" in the tree | ||
|
||
# Test link generation works | ||
Given I press the "Share" button | ||
Then I should see "Share draft content" | ||
And I should see "Anyone with this link can view the draft version of this page" | ||
And I save the link to share draft content local storage | ||
|
||
# Test the link allows us to view content on the front end when not logged in | ||
When I go to "/Security/login" | ||
And I press the "Log in as someone else" button | ||
And I follow the link in share draft content local storage | ||
And I clear the link from share draft content local storage | ||
Then I should see "My page" | ||
|
||
# Test that still cannot view regular draft content | ||
When I go to "/my-page" | ||
Then I should not see "My Page" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace SilverStripe\ShareDraftContent\Tests\Behat\Context; | ||
|
||
use SilverStripe\BehatExtension\Context\SilverStripeContext; | ||
|
||
class FeatureContext extends SilverStripeContext | ||
{ | ||
private const KEY = 'behat.sharedraftcontent.link'; | ||
|
||
/** | ||
* @Given /^I save the link to share draft content local storage$/ | ||
*/ | ||
public function iSaveTheLinkToShareDraftContentLocalStorage() | ||
{ | ||
$key = self::KEY; | ||
$js = <<<JS | ||
window.localStorage.setItem('{$key}', document.querySelector('.share-draft-content__link').value); | ||
JS; | ||
$this->getSession()->evaluateScript($js); | ||
} | ||
|
||
/** | ||
* @Given /^I follow the link in share draft content local storage$/ | ||
*/ | ||
public function iFollowTheLinkInShareDraftContentLocalStorage() | ||
{ | ||
$key = self::KEY; | ||
$js = <<<JS | ||
window.location = window.localStorage.getItem('{$key}'); | ||
JS; | ||
$this->getSession()->evaluateScript($js); | ||
} | ||
|
||
/** | ||
* @Given /^I clear the link from share draft content local storage$/ | ||
*/ | ||
public function iClearTheLinkFromShareDraftContentLocalStorage() | ||
{ | ||
$key = self::KEY; | ||
$js = <<<JS | ||
window.localStorage.removeItem('{$key}'); | ||
JS; | ||
$this->getSession()->evaluateScript($js); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace SilverStripe\ShareDraftContent\Tests\Behat\Context; | ||
|
||
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext; | ||
|
||
class FixtureContext extends BaseFixtureContext | ||
{ | ||
} |