Add test for import page form behavior
[MAILPOET-1732]
This commit is contained in:
committed by
M. Shull
parent
2d3e2715fa
commit
d67c1a1ed3
@@ -45,6 +45,7 @@ class WizardWooCommerceImportListStep extends React.Component {
|
|||||||
checked={this.state.importType === 'subscribed'}
|
checked={this.state.importType === 'subscribed'}
|
||||||
onChange={this.handleOptionChange}
|
onChange={this.handleOptionChange}
|
||||||
value="subscribed"
|
value="subscribed"
|
||||||
|
data-automation-id="import_as_subscribed"
|
||||||
/>
|
/>
|
||||||
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxSubscribed'))}
|
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxSubscribed'))}
|
||||||
</label>
|
</label>
|
||||||
@@ -56,6 +57,7 @@ class WizardWooCommerceImportListStep extends React.Component {
|
|||||||
checked={this.state.importType === 'unsubscribed'}
|
checked={this.state.importType === 'unsubscribed'}
|
||||||
onChange={this.handleOptionChange}
|
onChange={this.handleOptionChange}
|
||||||
value="unsubscribed"
|
value="unsubscribed"
|
||||||
|
data-automation-id="import_as_unsubscribed"
|
||||||
/>
|
/>
|
||||||
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxUnsubscribed'))}
|
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxUnsubscribed'))}
|
||||||
</label>
|
</label>
|
||||||
@@ -65,6 +67,7 @@ class WizardWooCommerceImportListStep extends React.Component {
|
|||||||
type="submit"
|
type="submit"
|
||||||
value={MailPoet.I18n.t('wooCommerceListImportSubmit')}
|
value={MailPoet.I18n.t('wooCommerceListImportSubmit')}
|
||||||
disabled={!this.state.importType || this.props.loading}
|
disabled={!this.state.importType || this.props.loading}
|
||||||
|
data-automation-id="submit_woo_commerce_list_import"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
53
tests/acceptance/WooCommerceListImportPageCest.php
Normal file
53
tests/acceptance/WooCommerceListImportPageCest.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Test\Acceptance;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../DataFactories/WooCommerceProduct.php';
|
||||||
|
require_once __DIR__ . '/../DataFactories/WooCommerceCustomer.php';
|
||||||
|
require_once __DIR__ . '/../DataFactories/WooCommerceOrder.php';
|
||||||
|
|
||||||
|
use MailPoet\Test\DataFactories\WooCommerceCustomer;
|
||||||
|
use MailPoet\Test\DataFactories\WooCommerceOrder;
|
||||||
|
use MailPoet\Test\DataFactories\WooCommerceProduct;
|
||||||
|
|
||||||
|
class WooCommerceListImportPageCest {
|
||||||
|
|
||||||
|
/** @var WooCommerceProduct */
|
||||||
|
private $product_factory;
|
||||||
|
|
||||||
|
/** @var WooCommerceCustomer */
|
||||||
|
private $customer_factory;
|
||||||
|
|
||||||
|
/** @var WooCommerceOrder*/
|
||||||
|
private $order_factory;
|
||||||
|
|
||||||
|
function _before(\AcceptanceTester $I) {
|
||||||
|
$I->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');
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user