From ef182b50ad5cda08be4a736ea82896cc91a9f441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Tue, 14 Sep 2021 11:12:17 +0200 Subject: [PATCH] Add acceptance test for error messages in form [MAILPOET-3786] --- .../Forms/GutenbergFormBlockCest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/acceptance/Forms/GutenbergFormBlockCest.php b/tests/acceptance/Forms/GutenbergFormBlockCest.php index 4b1d253d14..043aa4c41d 100644 --- a/tests/acceptance/Forms/GutenbergFormBlockCest.php +++ b/tests/acceptance/Forms/GutenbergFormBlockCest.php @@ -66,6 +66,42 @@ class GutenbergFormBlockCest { $i->seeNoJSErrors(); } + public function subscriptionGutenbergBlockWithNameErrorMessages(\AcceptanceTester $i): void { + $formFactory = new Form(); + $formId = (int)$formFactory + ->withName('Acceptance Test Block Form Error Messages') + ->withLastName() + ->withFirstName() + ->create()->getId(); + $postId = $this->createPost($i, $formId); + + $i->wantTo('Add Gutenberg form block to the post and test error messages'); + $i->amOnPage("/?p={$postId}"); + $i->waitForElementVisible('[data-automation-id="form_email"]'); + + $i->wantTo('Test error message for angle brackets'); + $i->fillField('[data-automation-id="form_first_name"]', '>'); + $i->click('.mailpoet_submit'); + $i->waitForText('Please specify a valid name'); + + $i->wantTo('Test error message for name with URL'); + $i->fillField('[data-automation-id="form_first_name"]', 'Здравствуйте, Забирайте подарок http://bit.ly/2Z8SdDC .'); + $i->click('.mailpoet_submit'); + $i->waitForText('Addresses in names are not permitted, please add your name instead.'); + + $i->wantTo('Test error message for invalid email'); + $i->fillField('[data-automation-id="form_first_name"]', $this->firstName); + $i->fillField('[data-automation-id="form_last_name"]', $this->lastName); + $i->fillField('[data-automation-id="form_email"]', $this->firstName); + $i->click('.mailpoet_submit'); + $i->waitForText('Please specify a valid email address.'); + + $i->fillField('[data-automation-id="form_email"]', $this->subscriberEmail); + $i->click('.mailpoet_submit'); + $i->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); + $i->seeNoJSErrors(); + } + private function createPost(\AcceptanceTester $i, int $formId): int { return $i->havePostInDatabase([ 'post_author' => 1,