Add acceptance test for email and submit editing

[MAILPOET-2451]
This commit is contained in:
Rostislav Wolny
2019-12-03 14:14:30 +01:00
committed by Jack Kitterhing
parent 270798ceeb
commit e9ee0323d3
3 changed files with 80 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ const EmailEdit = ({ attributes, setAttributes }) => {
<TextControl <TextControl
label={MailPoet.I18n.t('label')} label={MailPoet.I18n.t('label')}
value={attributes.label} value={attributes.label}
data-automation-id="settings_email_label_input"
onChange={(label) => (setAttributes({ label }))} onChange={(label) => (setAttributes({ label }))}
/> />
<ToggleControl <ToggleControl
@@ -29,16 +30,27 @@ const EmailEdit = ({ attributes, setAttributes }) => {
</InspectorControls> </InspectorControls>
); );
const getTextInput = (placeholder) => (
<input
id="email"
className="mailpoet_text"
type="email"
name="name"
placeholder={placeholder}
data-automation-id="editor_email_input"
/>
);
return ( return (
<> <>
{inspectorControls} {inspectorControls}
{attributes.labelWithinInput ? ( {attributes.labelWithinInput ? (getTextInput(attributes.label)
<input className="mailpoet_text" type="email" name="name" placeholder={attributes.label} />
) : ( ) : (
<label className="mailpoet_text_label"> <label className="mailpoet_text_label" data-automation-id="editor_email_label" htmlFor="email">
{attributes.label} {attributes.label}
<br /> <br />
<input className="mailpoet_text" type="email" name="email" placeholder="" /> {getTextInput('')}
</label> </label>
)} )}
</> </>

View File

@@ -14,6 +14,7 @@ const SubmitEdit = ({ attributes, setAttributes }) => {
label={MailPoet.I18n.t('label')} label={MailPoet.I18n.t('label')}
value={attributes.label} value={attributes.label}
onChange={(label) => (setAttributes({ label }))} onChange={(label) => (setAttributes({ label }))}
data-automation-id="settings_submit_label_input"
/> />
</PanelBody> </PanelBody>
</Panel> </Panel>
@@ -25,7 +26,12 @@ const SubmitEdit = ({ attributes, setAttributes }) => {
<> <>
{ inspectorControls } { inspectorControls }
<div className="mailpoet_submit"> <div className="mailpoet_submit">
<input className="button" type="submit" value={attributes.label} /> <input
className="button"
type="submit"
value={attributes.label}
data-automation-id="editor_submit_input"
/>
</div> </div>
</> </>
); );

View File

@@ -0,0 +1,57 @@
<?php
namespace MailPoet\Test\Acceptance;
use MailPoet\Features\FeaturesController;
use MailPoet\Test\DataFactories\Features;
use MailPoet\Test\DataFactories\Form;
use MailPoet\Test\DataFactories\Segment;
class FormEditorUpdateMandatoryFieldsCest {
function updateEmailAndSubmit(\AcceptanceTester $I) {
$features = new Features();
$features->withFeatureEnabled(FeaturesController::NEW_FORM_EDITOR);
$segment_factory = new Segment();
$form_name = 'Mandatory fields test';
$form_factory = new Form();
$form_factory
->withSegments([$segment_factory->withName('Fancy List')->create()])
->withName($form_name)
->create();
$I->wantTo('Update form mandatory fields');
$I->login();
// Open form for editation
$I->amOnMailPoetPage('Forms');
$I->waitForText($form_name);
$I->clickItemRowActionByItemName($form_name, 'Edit');
$I->waitForElement('[data-automation-id="form_title_input"]');
// Change email label
$block_email_input = '[data-automation-id="editor_email_input"]';
$I->click($block_email_input);
$block_settings_email_label_input = '[data-automation-id="settings_email_label_input"]';
$I->waitForElement($block_settings_email_label_input);
$updated_email_label = 'Your email';
$I->fillField($block_settings_email_label_input, $updated_email_label);
$I->see($updated_email_label, '[data-automation-id="editor_email_label"]');
$I->seeNoJSErrors();
// Change submit label
$block_submit_input = '[data-automation-id="editor_submit_input"]';
$I->click($block_submit_input);
$block_settings_submit_label_input = '[data-automation-id="settings_submit_label_input"]';
$updated_submit_label = 'Hey hey subscribe!';
$I->waitForElement($block_settings_submit_label_input);
$I->fillField($block_settings_submit_label_input, $updated_submit_label);
$I->assertAttributeContains($block_submit_input, 'value', $updated_submit_label);
$I->seeNoJSErrors();
// Save changes
$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->assertAttributeContains($block_submit_input, 'value', $updated_submit_label);
$I->see($updated_email_label, '[data-automation-id="editor_email_label"]');
$I->seeNoJSErrors();
}
}