From d67c1a1ed37c3577a2c92c8aa42f2d48484816c2 Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Tue, 26 Mar 2019 15:16:13 +0100 Subject: [PATCH] Add test for import page form behavior [MAILPOET-1732] --- .../steps/woo_commerce_import_list_step.jsx | 3 ++ .../WooCommerceListImportPageCest.php | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/acceptance/WooCommerceListImportPageCest.php diff --git a/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx b/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx index 182187fbed..d7f5b10531 100644 --- a/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx +++ b/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx @@ -45,6 +45,7 @@ class WizardWooCommerceImportListStep extends React.Component { checked={this.state.importType === 'subscribed'} onChange={this.handleOptionChange} value="subscribed" + data-automation-id="import_as_subscribed" /> {ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxSubscribed'))} @@ -56,6 +57,7 @@ class WizardWooCommerceImportListStep extends React.Component { checked={this.state.importType === 'unsubscribed'} onChange={this.handleOptionChange} value="unsubscribed" + data-automation-id="import_as_unsubscribed" /> {ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxUnsubscribed'))} @@ -65,6 +67,7 @@ class WizardWooCommerceImportListStep extends React.Component { type="submit" value={MailPoet.I18n.t('wooCommerceListImportSubmit')} disabled={!this.state.importType || this.props.loading} + data-automation-id="submit_woo_commerce_list_import" /> diff --git a/tests/acceptance/WooCommerceListImportPageCest.php b/tests/acceptance/WooCommerceListImportPageCest.php new file mode 100644 index 0000000000..bb21d3ec61 --- /dev/null +++ b/tests/acceptance/WooCommerceListImportPageCest.php @@ -0,0 +1,53 @@ +activateWooCommerce(); + $this->product_factory = new WooCommerceProduct($I); + $this->customer_factory = new WooCommerceCustomer($I); + $this->order_factory = new WooCommerceOrder($I); + // Cleanup + $this->customer_factory->deleteAll(); + $this->product_factory->deleteAll(); + $this->order_factory->deleteAll(); + } + + function importPageFormBehaviourTest(\AcceptanceTester $I) { + $I->login(); + $I->amOnPage('wp-admin/admin.php?page=mailpoet-woocommerce-list-import'); + $I->see('WooCommerce customers now have their own list'); + $unsubscribed_radio = '[data-automation-id="import_as_unsubscribed"]'; + $subscribed_radio = '[data-automation-id="import_as_subscribed"]'; + $submit_button = '[data-automation-id="submit_woo_commerce_list_import"]'; + $I->cantSeeCheckboxIsChecked($unsubscribed_radio); + $I->cantSeeCheckboxIsChecked($subscribed_radio); + $I->seeElement("$submit_button:disabled"); + $I->selectOption($unsubscribed_radio, 'unsubscribed'); + $I->canSeeCheckboxIsChecked($unsubscribed_radio); + $I->seeElement("$submit_button:not(:disabled)"); + $I->seeNoJSErrors(); + $I->click($submit_button); + $I->seeNoJSErrors(); + $I->seeInCurrentUrl('wp-admin/admin.php?page=mailpoet-newsletters'); + } +}