Skip to content

Commit

Permalink
Merge pull request #469 from creative-commoners/pulls/2.4/behat
Browse files Browse the repository at this point in the history
MNT Update behat tests
  • Loading branch information
Maxime Rainville authored Nov 15, 2021
2 parents 5049a5e + cae9bd5 commit 2a16e1e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 32 deletions.
5 changes: 3 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ default:
- SilverStripe\BehatExtension\Context\EmailContext
- SilverStripe\CMS\Tests\Behaviour\LoginContext
- SilverStripe\CMS\Tests\Behaviour\ThemeContext
- SilverStripe\CMS\Tests\Behaviour\FixtureContext:
# Using asset-admin for fixture context to get iAttachTheFileToDropzone()
- SilverStripe\AssetAdmin\Tests\Behat\Context\FixtureContext:
# Note: double indent for args is intentional
- '%paths.modules.subsites%/tests/behat/features/files/'
- '%paths.modules.subsites%/tests/behat/files/'

extensions:
SilverStripe\BehatExtension\MinkExtension:
Expand Down
82 changes: 82 additions & 0 deletions tests/behat/features/operate-subsites.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@javascript
Feature: Create and select a subsite
As a CMS user
I want to be able to select a subsite
So that I can edit content for a specific subsite

Background:
# There's a bug where you need CMS_ACCESS_CMSMain rather than CMS_ACCESS_LeftAndMain permissions to
# use subsites as expected
# Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "FILE_EDIT_ALL"
Given the "group" "EDITOR group" has permissions "CMS_ACCESS_CMSMain" and "CMS_ACCESS_AssetAdmin" and "FILE_EDIT_ALL"
And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content"
And an "image" "file1.jpg"
And an "image" "file2.jpg"

Scenario: I can operate subsites

# Create subsite as Admin
Given I am logged in with "ADMIN" permissions
Then I go to "admin/subsites"

# Add subsites button is not a regular button, so click using css selector
And I click on the ".btn-toolbar .btn__title" element
And I fill in "Subsite Name" with "My subsite"
And I press "Create"

# Add a file to the main site
When I go to "admin/assets"
And I press the "Add folder" button
And I select "Main site" from "SubsitesSelect"
# Using a short folder name so that it doesn't get truncated on the frontend
And I fill in "Folder name" with "mfol"
And I press the "Create" button
When I go to "admin/assets"

And I click on the file named "mfol" in the gallery
And I attach the file "file1.jpg" to dropzone "gallery-container"

# Change to Editor user
When I go to "/Security/login"
And I press the "Log in as someone else" button
When I am logged in with "EDITOR" permissions
And I go to "admin/pages"

# Can see main site page on main site
When I go to "admin/pages"
Then I should see "My page" in the tree

# Cannot see main site page on subsite
When I select "My subsite" from "SubsitesSelect"
And I go to "admin/pages"
Then I should not see "My page" in the tree

# Create a page on the subsite
When I press the "Add new" button
And I select the "Page" radio button
And I press the "Create" button
When I fill in "Page name" with "My subsite page"
And I press the "Publish" button
Then I should see "My subsite page"

# Can see main site folders/files from subsite
When I go to "admin/assets"
Then I should see "mfol"
When I click on the file named "mfol" in the gallery
Then I should see "file1"

# Add a file to the subsite
When I go to "admin/assets"
And I select "My subsite" from "SubsitesSelect"
And I press the "Add folder" button
And I fill in "Folder name" with "sfol"
And I press the "Create" button
When I go to "admin/assets"
And I click on the file named "sfol" in the gallery
And I attach the file "file2.jpg" to dropzone "gallery-container"

# Change back to main subsite - cannot see subsite folders/files
When I go to "admin/assets"
And I select "Main site" from "SubsitesSelect"
Then I should see "mfol"
Then I should not see "My subsite page"
19 changes: 10 additions & 9 deletions tests/behat/features/preview-navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ Feature: Preview navigation
In order to preview my content

Background:
Given a "subsite" "My subsite"
And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content <a name='aname'>aname</a><a href='other-page'>ahref</a>" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite"
And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content <a href='my-page'>Goto my page></a>" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite"
Given a "member" "Joe" belonging to "Admin Group" with "Email"="[email protected]" and "Password"="Password1"
And the "group" "Admin Group" has permissions "Full administrative rights"
And I log in with "[email protected]" and "Password1"
Given a "subsite" "MySubsite"
And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content <a name='aname'>aname</a> <a href='[sitetree_link,id=5]'>ahref</a>" and "SubsiteID"="1"
And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content <a href='[sitetree_link,id=4]'>Goto my page</a>" and "SubsiteID"="1"

@javascript
Scenario: I can navigate the subsite preview
When I go to "admin"
And I select "My subsite" from "SubsitesSelect"
And I go to "admin/pages"
Given I am logged in with "ADMIN" permissions
When I go to "/admin/pages"
And I select "MySubsite" from "SubsitesSelect"
And I click on "My page" in the tree
And I press the "Publish" button
And I click on "Other page" in the tree
And I press the "Publish" button
And I click on "My page" in the tree
And I set the CMS mode to "Preview mode"
And I follow "ahref" in preview
Expand Down
21 changes: 0 additions & 21 deletions tests/behat/features/select-a-subsite.feature

This file was deleted.

Binary file added tests/behat/files/file1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/behat/files/file2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a16e1e

Please sign in to comment.