From d23c9c80ac4223b222d0bda83b7f911fb9e16c20 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 13 Jun 2022 16:34:12 +1200 Subject: [PATCH 1/2] MNT Refactor group tests into their own feature. Move group tests into a new feature Refactor tests into distinct scenarios --- tests/behat/features/manage-groups.feature | 40 +++++++++++++++++++ tests/behat/features/manage-users.feature | 46 ---------------------- 2 files changed, 40 insertions(+), 46 deletions(-) create mode 100644 tests/behat/features/manage-groups.feature diff --git a/tests/behat/features/manage-groups.feature b/tests/behat/features/manage-groups.feature new file mode 100644 index 000000000..6267ecc28 --- /dev/null +++ b/tests/behat/features/manage-groups.feature @@ -0,0 +1,40 @@ +@javascript @retry +Feature: Manage groups + As a site administrator + I want to create and manage user groups on my site + So that I can control access to the CMS + + Background: + Given a "group" "BOB group" + And a "group" "Jane group" with permissions "View draft content" + And the "page" "My page" + And I am logged in with "ADMIN" permissions + And I go to "/admin/security" + + Scenario: I can create a new group with permissions + # Create a user group + When I click the "Groups" CMS tab + And I press the "Add Group" button + And I fill in "Group name" with "MyGroup" + And I press the "Create" button + Then I should not see "Validation Error" + + # Assign various permissions to the group + And I click the "Permissions" CMS tab + And I check "View draft content" + And I press the "Save" button + Then I should not see "Validation Error" + + Scenario: Members of a group without permissions cannot view draft content + Given I go to "/Security/login" + And I press the "Log in as someone else" button + And I am logged in with "BOB" permissions + When I go to "/my-page?stage=Stage" + Then I should not see "My page" + + Scenario: Members of a group with relevant permissions can view draft content + Given I go to "/Security/login" + And I press the "Log in as someone else" button + And I am logged in with "Jane" permissions + When I go to "/my-page?stage=Stage" + Then I should see "My page" diff --git a/tests/behat/features/manage-users.feature b/tests/behat/features/manage-users.feature index b587b4ed1..7a184f6bc 100644 --- a/tests/behat/features/manage-users.feature +++ b/tests/behat/features/manage-users.feature @@ -131,49 +131,3 @@ Feature: Manage users And I press the "Delete" button, confirming the dialog Then I should see "admin@example.org" And I should not see "staffmember@example.org" - - Scenario: User group - - Given the "group" "BOB group" - And the "page" "My page" has the "Content" "

My content

" - - # Login to create BOB member - When I go to "/Security/login" - And I press the "Log in as someone else" button - And I am logged in with "BOB" permissions - - # BOB cannot view draft content - When I go to "/my-page?stage=Stage" - Then I should not see "My page" - - # Log back in as ADMIN - When I go to "/Security/login" - And I press the "Log in as someone else" button - And I am logged in with "ADMIN" permissions - - # Create a user group - And I go to "/admin/security" - And I click the "Groups" CMS tab - And I press the "Add Group" button - And I fill in "Group name" with "MyGroup" - And I press the "Create" button - - # Assign various permissions to the group - And I click the "Permissions" CMS tab - And I check "View draft content" - And I press the "Save" button - - # Users that belong to that group have permissions applied - And I click the "Members" CMS tab - And I fill in "Form_ItemEditForm_gridfield_relationsearch" with "BOB" - And I click on the ".ui-menu-item > a" element - And I click on the "#Form_ItemEditForm_action_gridfield_relationadd" element - - # Log back in as BOB - Given I go to "/Security/login" - And I press the "Log in as someone else" button - And I am logged in with "BOB" permissions - - # BOB can now view draft content - When I go to "/my-page?stage=Stage" - Then I should see "My page" From b00e44c6e76d23e93dde3027f6ebb6f910ab1b94 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 13 Jun 2022 16:34:53 +1200 Subject: [PATCH 2/2] MNT add new test for Group title validation --- tests/behat/features/manage-groups.feature | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/behat/features/manage-groups.feature b/tests/behat/features/manage-groups.feature index 6267ecc28..cec252b43 100644 --- a/tests/behat/features/manage-groups.feature +++ b/tests/behat/features/manage-groups.feature @@ -25,6 +25,13 @@ Feature: Manage groups And I press the "Save" button Then I should not see "Validation Error" + Scenario: Group cannot have a blank name + When I click the "Groups" CMS tab + And I press the "Add Group" button + And I fill in "Group name" with "" + And I press the "Create" button + Then I should see "Validation Error" + Scenario: Members of a group without permissions cannot view draft content Given I go to "/Security/login" And I press the "Log in as someone else" button