From 19e9dc49208a9d3480ad5b34d9c5f660090baf22 Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Tue, 6 Sep 2022 08:44:46 +1200 Subject: [PATCH] ENH Replace ADMIN permissions with less permissions in Behat test --- tests/behat/features/apply-formatting.feature | 3 +- tests/behat/features/create-a-page.feature | 14 ++++++---- tests/behat/features/duplicate-a-page.feature | 5 ++-- tests/behat/features/edit-a-page.feature | 8 +++++- tests/behat/features/insert-a-link.feature | 3 +- .../behat/features/insert-anchor-link.feature | 3 +- .../features/manage-page-permissions.feature | 28 ++++++++++--------- tests/behat/features/preview-a-page.feature | 4 +-- tests/behat/features/publish-a-page.feature | 12 ++++---- tests/behat/features/redirector-page.feature | 3 +- .../behat/features/search-for-a-page.feature | 3 +- tests/behat/features/sitetree.feature | 4 +-- tests/behat/features/view-reports.feature | 3 +- 13 files changed, 54 insertions(+), 39 deletions(-) diff --git a/tests/behat/features/apply-formatting.feature b/tests/behat/features/apply-formatting.feature index 2a96ebc0..a7e7dfff 100644 --- a/tests/behat/features/apply-formatting.feature +++ b/tests/behat/features/apply-formatting.feature @@ -5,7 +5,8 @@ Feature: Apply rich formatting to content Background: Given a "page" "About Us" has the "Content" "

My awesome headline

Some amazing content

" - And I am logged in with "ADMIN" permissions + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" Then I click on "About Us" in the tree diff --git a/tests/behat/features/create-a-page.feature b/tests/behat/features/create-a-page.feature index e8f8ae74..a7c16566 100644 --- a/tests/behat/features/create-a-page.feature +++ b/tests/behat/features/create-a-page.feature @@ -6,12 +6,12 @@ Feature: Create a page Background: Given a "page" "MyPage" And a "virtual page" "MyVirtualPage" - And a "group" "AUTHOR group" has permissions "Access to 'Pages' section" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" @javascript Scenario: I can create a page from the pages section - When I go to "/admin/pages" + When I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" Then I should see "MyPage" in the tree And I should see a "Add new" button in CMS Content Toolbar When I press the "Add new" button @@ -21,7 +21,8 @@ Feature: Create a page @javascript Scenario: I can create a page under another page - When I go to "/admin/pages" + When I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" Then I should see "MyPage" in the tree And I should see a "Add new" button in CMS Content Toolbar When I press the "Add new" button @@ -39,12 +40,13 @@ Feature: Create a page Then I should see an edit page form Scenario: I cannot add root level pages without permission - When I go to "/admin/settings" + When I am logged in with "ADMIN" permissions + And I go to "/admin/settings" And I click the "Access" CMS tab And I click on the "#Form_EditForm_CanCreateTopLevelType_OnlyTheseUsers" element And I press the "Save" button And I click on the ".cms-login-status__logout-link" element - When I am logged in with "AUTHOR" permissions + When I am logged in as a member of "EDITOR" group And I press the "Add new" button Then I see the "Top level" radio button "disabled" attribute equals "1" And I see the "Under another page" radio button "checked" attribute equals "1" diff --git a/tests/behat/features/duplicate-a-page.feature b/tests/behat/features/duplicate-a-page.feature index 07cc477b..486bad37 100644 --- a/tests/behat/features/duplicate-a-page.feature +++ b/tests/behat/features/duplicate-a-page.feature @@ -4,8 +4,9 @@ Feature: Duplicate a page So that I can grow my website Background: - Given I am logged in with "ADMIN" permissions - Given a "page" "Page1" + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group + And a "page" "Page1" And the "page" "Page1a" is a child of the "page" "Page1" And the "page" "Page1b" is a child of the "page" "Page1" And the "page" "Page1b1" is a child of the "page" "Page1b" diff --git a/tests/behat/features/edit-a-page.feature b/tests/behat/features/edit-a-page.feature index 90ec8a09..1d12d47e 100644 --- a/tests/behat/features/edit-a-page.feature +++ b/tests/behat/features/edit-a-page.feature @@ -7,7 +7,9 @@ Feature: Edit a page Given a "page" "About Us" has the "Content" "

My content

" And a "image" "assets/file1.jpg" #And a file "assets/file1.jpg" with changes "image"="assets/folder1/file2.jpg" and "page"="About Us" - And I am logged in with "ADMIN" permissions + And the "group" "AUTHOR" has permissions "Access to 'Pages' section" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "SITETREE_GRANT_ACCESS" + And I am logged in as a member of "AUTHOR" group And I go to "/admin/pages" Then I should see "About Us" in the tree @@ -115,6 +117,10 @@ Feature: Edit a page Then I should see "Please choose a linked page in the main content fields in order to publish" Scenario: Change permission levels for who can view and edit the page, at an individual page level + Given I am not logged in + And I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" + Then I should see "About Us" in the tree When I click on "About Us" in the tree And I click the "Settings" CMS tab And I select the "Form_EditForm_CanViewType_LoggedInUsers" radio button diff --git a/tests/behat/features/insert-a-link.feature b/tests/behat/features/insert-a-link.feature index 1783ba1d..8d83dc97 100644 --- a/tests/behat/features/insert-a-link.feature +++ b/tests/behat/features/insert-a-link.feature @@ -8,7 +8,8 @@ So that I can link to a external website or a page on my site Given a "page" "Home" And a "page" "About Us" has the "Content" "

My awesome content

" And a "file" "file1.jpg" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I click on "About Us" in the tree diff --git a/tests/behat/features/insert-anchor-link.feature b/tests/behat/features/insert-anchor-link.feature index 23468c12..a6f1ea17 100644 --- a/tests/behat/features/insert-anchor-link.feature +++ b/tests/behat/features/insert-anchor-link.feature @@ -9,7 +9,8 @@ So that I can link to a external website or a page on my site And a "page" "Home" And a "page" "About Us" has the "Content" "

My awesome content

" And a "page" "Details" has the "Content" "

My sub-par content

" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I click on "About Us" in the tree diff --git a/tests/behat/features/manage-page-permissions.feature b/tests/behat/features/manage-page-permissions.feature index 2a50e8b4..eee84f8f 100644 --- a/tests/behat/features/manage-page-permissions.feature +++ b/tests/behat/features/manage-page-permissions.feature @@ -5,8 +5,8 @@ Feature: Manage page permissions Background: Given a "page" "Home" with "Content"="

Welcome

" - And a "group" "AUTHOR group" has permissions "Access to 'Pages' section" - And a "group" "SECURITY group" has permissions "Access to 'Security' section" + And a "group" "EDITOR" has permissions "Access to 'Pages' section" + And a "group" "SECURITY" has permissions "Access to 'Security' section" And I am logged in with "ADMIN" permissions And I go to "/admin/pages" And I click on "Home" in the tree @@ -20,42 +20,44 @@ Feature: Manage page permissions # When I am not logged in # And I go to the homepage # Then I should see "Welcome" - Scenario: I can limit page view permissions to logged-in users Given I select "Logged-in users" from "Who can view this page?" input group And I press the "Publish" button When I am not logged in And I go to the homepage Then I should see a log-in form - When I am logged in with "AUTHOR" permissions + When I am logged in as a member of "EDITOR" group And I go to the homepage Then I should see "Welcome" - Scenario: I can limit page view permissions to certain groups Given I select "Only these groups (choose from list)" from "Who can view this page?" input group - And I select "AUTHOR group" in the "#Form_EditForm_ViewerGroups_Holder" tree dropdown + And I select "EDITOR" in the "#Form_EditForm_ViewerGroups_Holder" tree dropdown And I press the "Publish" button When I am not logged in And I go to the homepage Then I should see a log-in form - When I am logged in with "SECURITY" permissions + When I am logged in as a member of "SECURITY" group And I go to the homepage Then I will see a "warning" log-in message When I am not logged in - And I am logged in with "AUTHOR" permissions + And I am logged in as a member of "EDITOR" group And I go to the homepage Then I should see "Welcome" - Scenario: I can limit page edit permissions to logged-in users - Given I select "Logged-in users" from "Who can edit this page?" input group + Given I am not logged in + And I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" + And I click on "Home" in the tree + Then I should see an edit page form + And I click the "Settings" CMS tab + And I select "Logged-in users" from "Who can edit this page?" input group And I press the "Publish" button - Then pages should be editable by "AUTHOR" + Then pages should be editable by "EDITOR" And pages should be editable by "ADMIN" - Scenario: I can limit page edit permissions to certain groups Given I select "Only these groups (choose from list)" from "Who can edit this page?" input group And I select "ADMIN group" in the "#Form_EditForm_EditorGroups_Holder" tree dropdown And I press the "Publish" button - Then pages should not be editable by "AUTHOR" + Then pages should not be editable by "EDITOR" But pages should be editable by "ADMIN" diff --git a/tests/behat/features/preview-a-page.feature b/tests/behat/features/preview-a-page.feature index 8769117b..c856803a 100644 --- a/tests/behat/features/preview-a-page.feature +++ b/tests/behat/features/preview-a-page.feature @@ -5,10 +5,11 @@ Feature: Preview a page Background: Given a "page" "About Us" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group @javascript Scenario: I can show a preview of the current page from the pages section - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" Then I should see "About Us" in the tree @@ -23,7 +24,6 @@ Feature: Preview a page # - We should continue testing against it after we have fixtures ready @javascript Scenario: I can see an updated preview when editing content - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" Then I should see "About Us" in the tree diff --git a/tests/behat/features/publish-a-page.feature b/tests/behat/features/publish-a-page.feature index 5181c914..5d863446 100644 --- a/tests/behat/features/publish-a-page.feature +++ b/tests/behat/features/publish-a-page.feature @@ -6,6 +6,8 @@ Feature: Publish a page Background: Given a "page" "My Page" with "URLSegment"="my-page" and "Content"="

initial content

" And the "page" "My Page" is not published + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group @javascript Scenario: I can have a unpublished version of a page that is not publicly available @@ -14,8 +16,7 @@ Feature: Publish a page @javascript Scenario: I can publish a previously never published page - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree And I press the "Publish" button @@ -27,8 +28,7 @@ Feature: Publish a page @javascript Scenario: I will get different options depending on the current publish state of the page - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree @@ -58,7 +58,6 @@ Feature: Publish a page And I go to "/hello" Then I should see "hello world" - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" And I should see "Hello" in the tree And I click on "Hello" in the tree @@ -72,8 +71,7 @@ Feature: Publish a page @javascript Scenario: I can delete a page from live and draft stage to completely remove it - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree And I press the "Publish" button diff --git a/tests/behat/features/redirector-page.feature b/tests/behat/features/redirector-page.feature index 9fb7b244..40eca4d6 100644 --- a/tests/behat/features/redirector-page.feature +++ b/tests/behat/features/redirector-page.feature @@ -8,7 +8,8 @@ Feature: Redirector Pages Given a "page" "Page 1" And a "page" "My Redirect" which redirects to a "page" "Page 1" And a "image" "assets/file1.jpg" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" Scenario: Only the appropriate fields are shown diff --git a/tests/behat/features/search-for-a-page.feature b/tests/behat/features/search-for-a-page.feature index 82f58812..34dfd7b8 100644 --- a/tests/behat/features/search-for-a-page.feature +++ b/tests/behat/features/search-for-a-page.feature @@ -8,7 +8,8 @@ Feature: Search for a page Given a "page" "Home" And a "page" "About Us" And a "page" "Contact Us" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I press the "Filter" button diff --git a/tests/behat/features/sitetree.feature b/tests/behat/features/sitetree.feature index 0bc356a6..c019d8a3 100644 --- a/tests/behat/features/sitetree.feature +++ b/tests/behat/features/sitetree.feature @@ -4,8 +4,8 @@ Feature: Sitetree So that I can operate my website Background: - Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "SITETREE_REORGANISE" - And I am logged in with "EDITOR" permissions + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" and "SITETREE_REORGANISE" + And I am logged in as a member of "EDITOR" group And a "page" "One" And a "page" "Two" And a "page" "Three" diff --git a/tests/behat/features/view-reports.feature b/tests/behat/features/view-reports.feature index 4b071a2c..1192bd82 100644 --- a/tests/behat/features/view-reports.feature +++ b/tests/behat/features/view-reports.feature @@ -6,7 +6,8 @@ Feature: View Reports Background: Given a "page" "Empty Page" And a "page" "Filled Page" with "Content"="

Some Content

" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "Access to 'Reports' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/reports" Scenario: I can view the "Pages with no content" report