From 1b8b5d92b87ad897a463703fb039fcae3c2bb569 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 8 Aug 2023 13:03:24 +1200 Subject: [PATCH] MNT Add behat test for form validation --- tests/behat/features/validation.feature | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/behat/features/validation.feature diff --git a/tests/behat/features/validation.feature b/tests/behat/features/validation.feature new file mode 100644 index 000000000..b1a928500 --- /dev/null +++ b/tests/behat/features/validation.feature @@ -0,0 +1,25 @@ +Feature: Form validation + As a content author + I want form validation to work in the CMS + So that I know my data is sane + + Background: + Given the "Company" "Walmart" with "Category"="Retail" + And the "Company" "ExxonMobil" with "Category"="Oil" + And the "Company" "Vitol" with "Category"="Other" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "Access to 'Test ModelAdmin' section" and "TEST_DATAOBJECT_EDIT" + And I am logged in as a member of "EDITOR" group + And I go to "/admin/test/SilverStripe-FrameworkTest-Model-Employee" + And I press the "Add Employee" button + + Scenario: Field validation works as expected even if no validator is explicitly declared + When I fill in "Name" with "any name" + And I fill in "Email" with "invalid email" + And I press the "Create" button + Then I should not see "Saved Employee" + And I should see "Please enter an email address" + + And I fill in "Email" with "email@example.com" + And I press the "Create" button + Then I should see "Saved Employee" + And I should not see "Please enter an email address"