Add acceptance tests for blocking trashing active segments

[MAILPOET-3463]
This commit is contained in:
Rostislav Wolny
2021-03-25 14:49:12 +01:00
committed by Veljko V
parent 51e5206ed8
commit 3f434aae76
4 changed files with 57 additions and 2 deletions

View File

@@ -160,7 +160,7 @@ class DynamicSegments extends APIEndpoint {
Error::BAD_REQUEST => str_replace(
'%$1s',
"'" . join("', '", $activelyUsedNewslettersSubjects[$segment->getId()] ) . "'",
_x('List cannot be deleted because its used for %$1s email', 'Alert shown when trying to delete segment, which is assigned to any automatic emails.', 'mailpoet')
_x('Segment cannot be deleted because its used for %$1s email', 'Alert shown when trying to delete segment, which is assigned to any automatic emails.', 'mailpoet')
),
]);
}

View File

@@ -185,6 +185,32 @@ class ManageListsCest {
$i->waitForText('test-editor@example.com', 5);
}
public function cantTrashOrBulkTrashActivelyUsedList(\AcceptanceTester $i) {
$listTitle = 'Active List';
$subject = 'Post notification';
$segmentFactory = new Segment();
$segment = $segmentFactory
->withName($listTitle)
->create();
$newsletterFactory = new Newsletter();
$newsletterFactory->withPostNotificationsType()
->withSegments([$segment])
->withSubject($subject)
->create();
$i->wantTo('Check that user cant delete actively used list');
$i->login();
$i->amOnMailpoetPage('Lists');
$i->waitForText($listTitle, 5, '[data-automation-id="listing_item_' . $segment->getId() . '"]');
$i->clickItemRowActionByItemName($listTitle, 'Move to trash');
$i->waitForText("List cannot be deleted because its used for '{$subject}' email");
$i->seeNoJSErrors();
$i->checkOption('[data-automation-id="listing-row-checkbox-' . $segment->getId() . '"]');
$i->waitForText('Move to trash');
$i->click('Move to trash');
$i->waitForText('0 lists were moved to the trash.');
}
public function cannotDisableWPUserList(\AcceptanceTester $i) {
$listName = 'WordPress Users';
$subject = 'Blocking Post Notification';

View File

@@ -224,6 +224,35 @@ class ManageSegmentsCest {
$i->waitForText('No segments found');
}
public function cantTrashOrBulkTrashActivelyUsedSegment(\AcceptanceTester $i) {
$segmentTitle = 'Active Segment';
$subject = 'Post notification';
$segmentFactory = new DynamicSegment();
$segment = $segmentFactory
->withName($segmentTitle)
->create();
$newsletterFactory = new Newsletter();
$newsletterFactory->withPostNotificationsType()
->withSegments([$segment])
->withSubject($subject)
->create();
$i->wantTo('Check that user cant delete actively used list');
$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_all"]');
$i->waitForText($segmentTitle, 5, '[data-automation-id="listing_item_' . $segment->getId() . '"]');
$i->clickItemRowActionByItemName($segmentTitle, 'Move to trash');
$i->waitForText("Segment cannot be deleted because its used for '{$subject}' email");
$i->seeNoJSErrors();
$i->checkOption('[data-automation-id="listing-row-checkbox-' . $segment->getId() . '"]');
$i->waitForText('Move to trash');
$i->click('Move to trash');
$i->waitForText('0 segments were moved to the trash.');
}
public function createUserSegmentAndCheckCount(\AcceptanceTester $i) {
$userFactory = new User();
$userFactory->createUser('Test User 1', 'editor', 'test-editor' . rand(1, 100000) . '@example.com');

View File

@@ -99,7 +99,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
$response = $this->endpoint->trash(['id' => $dynamicSegment->getId()]);
$this->entityManager->refresh($dynamicSegment);
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals("List cannot be deleted because its used for 'Subject' email");
expect($response->errors[0]['message'])->equals("Segment cannot be deleted because its used for 'Subject' email");
}
public function testItCanRestoreASegment() {