From 8333d790180dfc25b07e1f0efde7fbc0f40f532c Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Wed, 24 Jun 2020 12:04:50 +0200 Subject: [PATCH] Add empty trash tests [MAILPOET-2982] --- assets/js/src/listing/filters.jsx | 1 + tests/acceptance/DeleteNewsletterCest.php | 23 +++++++++ tests/acceptance/DeleteTrashedSegmentCest.php | 39 ++++++++++++++- tests/acceptance/FormsDeletingCest.php | 25 ++++++++++ tests/acceptance/ManageListsCest.php | 50 +++++++++++++++---- 5 files changed, 127 insertions(+), 11 deletions(-) diff --git a/assets/js/src/listing/filters.jsx b/assets/js/src/listing/filters.jsx index cc5e8226c5..e847eaf10a 100644 --- a/assets/js/src/listing/filters.jsx +++ b/assets/js/src/listing/filters.jsx @@ -82,6 +82,7 @@ class ListingFilters extends React.Component { onClick={this.handleEmptyTrash} type="submit" value={MailPoet.I18n.t('emptyTrash')} + data-automation-id="empty_trash" className="button" /> ); diff --git a/tests/acceptance/DeleteNewsletterCest.php b/tests/acceptance/DeleteNewsletterCest.php index 3d3db84e99..3e47740743 100644 --- a/tests/acceptance/DeleteNewsletterCest.php +++ b/tests/acceptance/DeleteNewsletterCest.php @@ -55,4 +55,27 @@ class DeleteNewsletterCest { $i->waitForText($newsletterName . '2'); } + + public function emptyTrash(\AcceptanceTester $i) { + $newsletterName = 'Goodbye Forever Newsletter'; + $i->wantTo('Empty a trash on Newsletters page'); + $newsletter = new Newsletter(); + $newsletter->withSubject($newsletterName)->withDeleted()->create(); + $newsletter = new Newsletter(); + $newsletter->withSubject($newsletterName . '2')->create(); + + $i->login(); + $i->amOnMailpoetPage('Emails'); + $i->waitForElement('[data-automation-id="filters_trash"]'); + $i->click('[data-automation-id="filters_trash"]'); + $i->waitForText($newsletterName); + + $i->click('[data-automation-id="empty_trash"]'); + + $i->waitForText('1 email was permanently deleted.'); + $i->waitForElementNotVisible($newsletterName); + $i->click('[data-automation-id="filters_all"]'); + + $i->waitForText($newsletterName . '2'); + } } diff --git a/tests/acceptance/DeleteTrashedSegmentCest.php b/tests/acceptance/DeleteTrashedSegmentCest.php index 0962a1a99f..0350a5ecd4 100644 --- a/tests/acceptance/DeleteTrashedSegmentCest.php +++ b/tests/acceptance/DeleteTrashedSegmentCest.php @@ -27,13 +27,48 @@ class DeleteTrashedSegmentCest { $i->amOnMailpoetPage('Lists'); $i->waitForElement('[data-automation-id="dynamic-segments-tab"]'); $i->click('[data-automation-id="dynamic-segments-tab"]'); - $i->waitForElement('[data-automation-id="filters_trash"]', 10); + $i->waitForElement('[data-automation-id="filters_trash"]'); $i->click('[data-automation-id="filters_trash"]'); $i->waitForText($segmentTitle, 10, $listingAutomationSelector); $i->clickItemRowActionByItemName($segmentTitle, 'Delete permanently'); - $i->waitForText('1 segment was permanently deleted.', 10); + $i->waitForText('1 segment was permanently deleted.'); $i->dontSeeElement($listingAutomationSelector); $i->seeNoJSErrors(); $i->waitForText($segmentTitle . '2'); } + + public function emptyTrash(\AcceptanceTester $i) { + $i->wantTo('Empty a trash on Segment page'); + + $segmentTitle = 'Empty Trash'; + + $segmentFactory = new DynamicSegment(); + $segment = $segmentFactory + ->withName($segmentTitle) + ->withUserRoleFilter('Administrator') + ->withDeleted() + ->create(); + $segmentFactory = new DynamicSegment(); + $segmentFactory + ->withName($segmentTitle . '2') + ->withUserRoleFilter('Administrator') + ->create(); + $listingAutomationSelector = '[data-automation-id="listing_item_' . $segment->id . '"]'; + + $i->login(); + $i->amOnMailpoetPage('Lists'); + $i->waitForElement('[data-automation-id="dynamic-segments-tab"]'); + $i->click('[data-automation-id="dynamic-segments-tab"]'); + $i->waitForElement('[data-automation-id="filters_trash"]'); + $i->click('[data-automation-id="filters_trash"]'); + $i->waitForText($segmentTitle, 10, $listingAutomationSelector); + + $i->click('[data-automation-id="empty_trash"]'); + $i->waitForText('1 segment was permanently deleted.'); + $i->dontSeeElement($listingAutomationSelector); + $i->seeNoJSErrors(); + + $i->click('[data-automation-id="filters_all"]'); + $i->waitForText($segmentTitle . '2'); + } } diff --git a/tests/acceptance/FormsDeletingCest.php b/tests/acceptance/FormsDeletingCest.php index 30b6edbacf..dc84b09390 100644 --- a/tests/acceptance/FormsDeletingCest.php +++ b/tests/acceptance/FormsDeletingCest.php @@ -66,4 +66,29 @@ class FormsDeletingCest { $i->waitForElementNotVisible($formName); $i->waitForText($formName . '2'); } + + public function emptyTrash(\AcceptanceTester $i) { + $formName = 'Delete form permanently'; + $form = new Form(); + $form->withName($formName)->withDeleted()->create(); + $form = new Form(); + $form->withName($formName . '2')->create(); + + $i->wantTo('Empty a trash on Forms page'); + + $i->login(); + $i->amOnMailpoetPage('Forms'); + + $i->waitForElement('[data-automation-id="filters_trash"]'); + $i->click('[data-automation-id="filters_trash"]'); + $i->waitForText($formName); + + $i->click('[data-automation-id="empty_trash"]'); + + $i->waitForText('1 form was permanently deleted.'); + $i->waitForElementNotVisible($formName); + $i->click('[data-automation-id="filters_all"]'); + + $i->waitForText($formName . '2'); + } } diff --git a/tests/acceptance/ManageListsCest.php b/tests/acceptance/ManageListsCest.php index 5a4a55ac02..ee3fa424d5 100644 --- a/tests/acceptance/ManageListsCest.php +++ b/tests/acceptance/ManageListsCest.php @@ -61,34 +61,66 @@ class ManageListsCest { // Trash existing list $i->clickItemRowActionByItemName($editedListTitle, 'Move to trash'); - $i->waitForText('1 list was moved to the trash. Note that deleting a list does not delete its subscribers.', 10); - $i->waitForElementVisible('[data-automation-id="filters_trash"]', 10); + $i->waitForText('1 list was moved to the trash. Note that deleting a list does not delete its subscribers.'); + $i->waitForElementVisible('[data-automation-id="filters_trash"]'); $i->click('[data-automation-id="filters_trash"]'); - $i->waitForElementVisible('[data-automation-id="filters_trash"]', 10); - $i->waitForText($editedListTitle, 10); + $i->waitForElementVisible('[data-automation-id="filters_trash"]'); + $i->waitForText($editedListTitle); $i->seeNoJSErrors(); // Restore trashed list $i->clickItemRowActionByItemName($editedListTitle, 'Restore'); - $i->waitForText('1 list has been restored from the Trash.', 10); + $i->waitForText('1 list has been restored from the Trash.'); $i->seeInCurrentURL(urlencode('group[all]')); - $i->waitForText($editedListTitle, 10); + $i->waitForText($editedListTitle); $i->seeNoJSErrors(); // Trash and delete existing list + $segmentFactory = new Segment(); $segmentFactory ->withName($newListTitle . '2') ->withDescription($newListDesc) ->create(); $i->clickItemRowActionByItemName($editedListTitle, 'Move to trash'); - $i->waitForElementVisible('[data-automation-id="filters_trash"]', 10); + $i->waitForElementVisible('[data-automation-id="filters_trash"]'); $i->click('[data-automation-id="filters_trash"]'); - $i->waitForElementVisible('[data-automation-id="filters_trash"]', 10); + $i->waitForElementVisible('[data-automation-id="filters_trash"]'); $i->clickItemRowActionByItemName($editedListTitle, 'Delete permanently'); - $i->waitForText('1 list was permanently deleted. Note that deleting a list does not delete its subscribers.', 10); + $i->waitForText('1 list was permanently deleted. Note that deleting a list does not delete its subscribers.'); $i->seeNoJSErrors(); $i->seeInCurrentURL(urlencode('group[all]')); $i->dontSee($editedListTitle, '[data-automation-id="listing_item_4"]'); $i->see($newListTitle . '2'); } + + public function emptyTrash(\AcceptanceTester $i) { + // Trash and delete existing list + $newListTitle = 'Empty Trash List'; + $newListDesc = 'Description'; + $segmentFactory = new Segment(); + $segmentFactory + ->withName($newListTitle) + ->withDescription($newListDesc) + ->withDeleted() + ->create(); + $segmentFactory = new Segment(); + $segmentFactory + ->withName('List to keep') + ->withDescription($newListDesc) + ->create(); + + $i->login(); + $i->amOnMailpoetPage('Lists'); + $i->waitForElementVisible('[data-automation-id="filters_trash"]'); + $i->click('[data-automation-id="filters_trash"]'); + $i->waitForElementVisible('[data-automation-id="empty_trash"]'); + + $i->click('[data-automation-id="empty_trash"]'); + + $i->waitForText('1 list was permanently deleted. Note that deleting a list does not delete its subscribers.'); + $i->dontSee($newListTitle); + $i->seeNoJSErrors(); + $i->click('[data-automation-id="filters_all"]'); + $i->see('List to keep'); + } }