diff --git a/assets/js/src/form_editor/components/form_title.jsx b/assets/js/src/form_editor/components/form_title.jsx index e92b1198a8..e57ea833f2 100644 --- a/assets/js/src/form_editor/components/form_title.jsx +++ b/assets/js/src/form_editor/components/form_title.jsx @@ -25,6 +25,7 @@ export default () => { id="form-title" className="editor-post-title__input" placeholder={MailPoet.I18n.t('addFormName')} + data-automation-id="form_title_input" rows="1" onFocus={() => setIsSelected(true)} onKeyPress={() => setIsSelected(false)} diff --git a/assets/js/src/form_editor/components/header.jsx b/assets/js/src/form_editor/components/header.jsx index 65c212558e..551ded89ca 100644 --- a/assets/js/src/form_editor/components/header.jsx +++ b/assets/js/src/form_editor/components/header.jsx @@ -24,6 +24,7 @@ export default () => { isLarge isDefault className="editor-post-publish-button" + data-automation-id="form_save_button" isBusy={isFormSaving} onClick={saveForm} > diff --git a/assets/js/src/form_editor/components/notices.jsx b/assets/js/src/form_editor/components/notices.jsx index fd00c4d39f..92e690aa34 100644 --- a/assets/js/src/form_editor/components/notices.jsx +++ b/assets/js/src/form_editor/components/notices.jsx @@ -22,7 +22,7 @@ export default () => { /> diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 2e2ead6ff3..19ebdde35c 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -125,6 +125,18 @@ class AcceptanceTester extends \Codeception\Actor { // phpcs:ignore PSR1.Classes $I->pressKey($element, \WebDriverKeys::ENTER); } + /** + * Check selected value in select2.. + * + * @param string $value + * @param string $element + */ + public function seeSelectedInSelect2($value, $element = '.select2-container') { + $I = $this; + $I->waitForElement($element); + $I->see($value, $element); + } + /** * Navigate to the editor for a newsletter. * diff --git a/tests/acceptance/FormEditorUpdateNewFormCest.php b/tests/acceptance/FormEditorUpdateNewFormCest.php new file mode 100644 index 0000000000..6dbd27732e --- /dev/null +++ b/tests/acceptance/FormEditorUpdateNewFormCest.php @@ -0,0 +1,40 @@ +withName($segment_name)->create(); + $features = new Features(); + $features->withFeatureEnabled(FeaturesController::NEW_FORM_EDITOR); + $I->wantTo('Create and update form'); + $I->login(); + $I->amOnMailPoetPage('Forms'); + // Create a new form + $form_name = 'My awesome form'; + $I->click('[data-automation-id="create_new_form"]'); + $I->waitForElement('[data-automation-id="form_title_input"]'); + $I->fillField('[data-automation-id="form_title_input"]', $form_name); + // Try saving form without selected list + $I->click('[data-automation-id="form_save_button"]'); + $I->waitForText('Please select a list', 10, '.automation-dismissible-notices'); + $I->seeNoJSErrors(); + // Select list and save form + $I->selectOptionInSelect2($segment_name); + $I->click('[data-automation-id="form_save_button"]'); + $I->waitForText('Form saved', 10, '.automation-dismissible-notices'); + $I->seeNoJSErrors(); + // Reload page and check data were saved + $I->reloadPage(); + $I->waitForElement('[data-automation-id="form_title_input"]'); + $I->see($form_name, '[data-automation-id="form_title_input"]'); + $I->seeSelectedInSelect2($segment_name); + $I->seeNoJSErrors(); + } +}