From b44e57311356c01ebf0d7dd99dd88eb84da5ca6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 2 Apr 2019 16:22:55 +0200 Subject: [PATCH] Test that products widget is available when WooCommerce active [MAILPOET-1843] --- tests/acceptance/EditorProductsCest.php | 45 ++++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/EditorProductsCest.php b/tests/acceptance/EditorProductsCest.php index 6918dc1bb8..42dd1e06be 100644 --- a/tests/acceptance/EditorProductsCest.php +++ b/tests/acceptance/EditorProductsCest.php @@ -25,7 +25,30 @@ class EditorProductsCest { /** @var WooCommerceProduct */ private $product_factory; - function _before(\AcceptanceTester $I) { + private $newsletterTitle = 'Editor Products Test'; + + private function initializeNewsletter(\AcceptanceTester $I) { + $this->newsletterTitle = 'Newsletter Title'; + (new Newsletter()) + ->withSubject($this->newsletterTitle) + ->loadBodyFrom('newsletterWithText.json') + ->create(); + } + + private function productsWidgetNotVisible(\AcceptanceTester $I) { + $I->wantTo('Not see products widget'); + $I->deactivateWooCommerce(); + + $I->login(); + $I->amOnMailpoetPage('Emails'); + $I->waitForText($this->newsletterTitle); + $I->clickItemRowActionByItemName($this->newsletterTitle, 'Edit'); + + $I->waitForText('Spacer'); + $I->waitForElementVisible('#automation_editor_block_products'); + } + + private function initializeWooCommerce(\AcceptanceTester $I) { $I->activateWooCommerce(); $this->product_factory = new WooCommerceProduct($I); @@ -45,19 +68,18 @@ class EditorProductsCest { } } + /** + * @before initializeNewsletter + * @before productsWidgetNotVisible + * @before initializeWooCommerce + */ function filterProducts(\AcceptanceTester $I) { $I->wantTo('Filter products'); - $newsletterTitle = 'Newsletter Title'; - (new Newsletter()) - ->withSubject($newsletterTitle) - ->loadBodyFrom('newsletterWithText.json') - ->create(); - $I->login(); $I->amOnMailpoetPage('Emails'); - $I->waitForText($newsletterTitle); - $I->clickItemRowActionByItemName($newsletterTitle, 'Edit'); + $I->waitForText($this->newsletterTitle); + $I->clickItemRowActionByItemName($this->newsletterTitle, 'Edit'); // Create products block $I->waitForText('Products'); @@ -101,13 +123,12 @@ class EditorProductsCest { // Searching for existing post should return zero results $I->fillField('.mailpoet_products_search_term', self::POST_TITLE); $I->waitForText('No products available'); + + $I->deactivateWooCommerce(); } private function clearCategories(\AcceptanceTester $I) { $I->click('.select2-selection__clear'); } - function _after(\AcceptanceTester $I) { - $I->deactivateWooCommerce(); - } }