diff --git a/tests/acceptance/ReinstallFromScratchCest.php b/tests/acceptance/ReinstallFromScratchCest.php new file mode 100644 index 0000000000..50ce7cf627 --- /dev/null +++ b/tests/acceptance/ReinstallFromScratchCest.php @@ -0,0 +1,72 @@ +wantTo('Reinstall from scratch'); + $I->login(); + + // Step 1 - create email, form, list and subscribers + $newsletter = new Newsletter(); + $newsletter->create(); + $form = new Form(); + $form->create(); + $segment = new Segment(); + $segment->create(); + $subscriber = new Subscriber(); + $subscriber->create(); + // Create few WP users, which should be imported after reinstall + for($i = 0; $i <= 5; $i++) { + wp_create_user('test' . $i, 'password', 'imported' . $i . '@from.wordpress'); + } + + // Step 2 - reinstall from scratch + $I->amOnPage('/wp-admin/admin.php?page=mailpoet-settings#advanced'); + $I->waitForElement('#mailpoet_reinstall', 5); + $I->click('Reinstall now...'); + $I->acceptPopup(); + $I->waitForElement('#mailpoet_loading', 5); + $I->waitForElementNotVisible('#mailpoet_loading', 10); + + // Step 3 - skip all tutorials, which could interfere with other tests + Setting::setValue('show_intro', 0); + Setting::setValue('user_seen_editor_tutorial1', 1); + Setting::setValue('show_congratulate_after_first_newsletter', 0); + + // Step 4 - check if data are emptied and repopulated + // Check emails + $I->amOnMailpoetPage('Emails'); + $I->waitForText('Nothing here yet!', 5); + $I->seeNumberOfElements('[data-automation-id^=listing_item_]', 0); + // Check forms + $I->amOnMailpoetPage('Forms'); + $I->waitForText('A GDPR friendly form', 5, '[data-automation-id="listing_item_1"]'); + $I->seeNumberOfElements('[data-automation-id^=listing_item_]', 1); + // Check lists + $I->amOnMailpoetPage('Lists'); + $I->waitForText('WordPress Users', 5, '[data-automation-id="listing_item_1"]'); + $I->see('My First List', '[data-automation-id="listing_item_2"]'); + $I->seeNumberOfElements('[data-automation-id^=listing_item_]', 2); + // Check subscribers + $I->amOnMailPoetPage('Subscribers'); + $I->waitForText('admin', 5, '[data-automation-id="listing_item_1"]'); + $wp_users_count = count_users(); + $subscribers_count = (int)$I->grabTextFrom('.displaying-num'); + Asserts::assertEquals($wp_users_count['total_users'], $subscribers_count); + } +}