diff --git a/behat.yml b/behat.yml index 0cc5f068..f772c879 100644 --- a/behat.yml +++ b/behat.yml @@ -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: diff --git a/tests/behat/features/operate-subsites.feature b/tests/behat/features/operate-subsites.feature new file mode 100644 index 00000000..dd2eaf5b --- /dev/null +++ b/tests/behat/features/operate-subsites.feature @@ -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" diff --git a/tests/behat/features/preview-navigation.feature b/tests/behat/features/preview-navigation.feature index 81492ac1..fa2c2a86 100644 --- a/tests/behat/features/preview-navigation.feature +++ b/tests/behat/features/preview-navigation.feature @@ -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 anameahref" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite" - And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content Goto my page>" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite" - Given a "member" "Joe" belonging to "Admin Group" with "Email"="joe@test.com" and "Password"="Password1" - And the "group" "Admin Group" has permissions "Full administrative rights" - And I log in with "joe@test.com" and "Password1" + Given a "subsite" "MySubsite" + And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content aname ahref" and "SubsiteID"="1" + And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content Goto my page" 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 diff --git a/tests/behat/features/select-a-subsite.feature b/tests/behat/features/select-a-subsite.feature deleted file mode 100644 index 1b183d1b..00000000 --- a/tests/behat/features/select-a-subsite.feature +++ /dev/null @@ -1,21 +0,0 @@ -@javascript -Feature: 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: - Given a "subsite" "Subsite B" - And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content" - And I am logged in with "ADMIN" permissions - Then I go to "admin/pages" - - Scenario: Default site contains default pages - When I select "Main site" from "SubsitesSelect" - And I go to "admin/pages" - Then I should see "My page" in the tree - - Scenario: I can switch to another subsite - When I select "Subsite B" from "SubsitesSelect" - And I go to "admin/pages" - Then I should not see "My page" in the tree diff --git a/tests/behat/files/file1.jpg b/tests/behat/files/file1.jpg new file mode 100644 index 00000000..beb5a91b Binary files /dev/null and b/tests/behat/files/file1.jpg differ diff --git a/tests/behat/files/file2.jpg b/tests/behat/files/file2.jpg new file mode 100644 index 00000000..fc834a45 Binary files /dev/null and b/tests/behat/files/file2.jpg differ