diff --git a/tests/behat/features/userforms.feature b/tests/behat/features/userforms.feature new file mode 100644 index 000000000..2d4917d9a --- /dev/null +++ b/tests/behat/features/userforms.feature @@ -0,0 +1,89 @@ +Feature: Userforms + As a website user + I want to user userforms + + Background: + Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" + # TODO: remove + Given I take a screenshot after every step + +@sboyd + Scenario: Operate userforms + Given I am logged in with "ADMIN" permissions + When I go to "/admin/pages" + And I press the "Add new" button + And I select the "User Defined Form" radio button + And I press the "Create" button + And I fill in "Page name" with "My userform" + And I press the "Save" button + + When I click the "Recipients" CMS tab + And I press the "Add Email Recipient" button + And I fill in "Type subject" with "New userform submission" + And I fill in "Type to address" with "to@example.com" + And I fill in "Send email from" with "from@example.com" + And I press the "Create" button + And I follow "My userform" + + When I click the "Form Fields" CMS tab + And I press the "Add Field" button + And I press the "Add Field" button + When I fill in "Form_Fields_GridFieldEditableColumns_2_Title" with "My textfield 1" + When I fill in "Form_Fields_GridFieldEditableColumns_3_Title" with "My textfield 2" + And I press the "Save" button + When I press the "Add Page Break" button + And I press the "Add Field" button + And I fill in "Form_Fields_GridFieldEditableColumns_4_Title" with "Second Page" + When I fill in "Form_Fields_GridFieldEditableColumns_5_Title" with "My textfield 3" + And I press the "Save" button + + # Edit My textfield 3 + When I click on the ".ss-gridfield-item[data-id='5'] .edit-link" element + And I click the "Validation" CMS tab + And I check "Is this field Required?" + And I press the "Save" button + And I follow "My userform" + + # Drag and drop my text field 2 to Page Two + Then I drag the ".ss-gridfield-item[data-id='3'] .handle" element to the ".ss-gridfield-item[data-id='5'] .handle" element + And I press the "Publish" button + + # View frontend + When I go to "/my-userform" + Then I should see "Page 1 of 2" + Then I should see "First Page" + And I should not see "Second Page" + And I should see "My textfield 1" + And I should not see "My textfield 2" + And I should not see "My textfield 3" + + # Pressing '2' buton should do nothing at this stage + When I press the "2" button + Then I should see "First Page" + + When I press the "Next" button + Then I should see "Page 2 of 2" + Then I should not see "First Page" + And I should see "Second Page" + And I should not see "My textfield 1" + And I should see "My textfield 2" + And I should see "My textfield 3" + + When I press the "1" button + Then I should see "First Page" + When I press the "2" button + Then I should see "Second Page" + When I press the "Prev" button + Then I should see "First Page" + + When I fill in "My textfield 1" with "My value 1" + And I press the "Next" button + And I fill in "My textfield 2" with "My value 2" + And I press the "Submit" button + Then I should see "'My textfield 3' is required" + + When I fill in "My textfield 3" with "My value 3" + And I press the "Submit" button + Then I should see "Thanks, we've received your submission." + + And there should be an email to "to@example.com" titled "New userform submission"