Add acceptance tests for blocking trashing active segments
[MAILPOET-3463]
This commit is contained in:
committed by
Veljko V
parent
51e5206ed8
commit
3f434aae76
@@ -160,7 +160,7 @@ class DynamicSegments extends APIEndpoint {
|
||||
Error::BAD_REQUEST => str_replace(
|
||||
'%$1s',
|
||||
"'" . join("', '", $activelyUsedNewslettersSubjects[$segment->getId()] ) . "'",
|
||||
_x('List cannot be deleted because it’s 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 it’s used for %$1s email', 'Alert shown when trying to delete segment, which is assigned to any automatic emails.', 'mailpoet')
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
@@ -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 can’t 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 it’s 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';
|
||||
|
@@ -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 can’t 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 it’s 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');
|
||||
|
@@ -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 it’s used for 'Subject' email");
|
||||
expect($response->errors[0]['message'])->equals("Segment cannot be deleted because it’s used for 'Subject' email");
|
||||
}
|
||||
|
||||
public function testItCanRestoreASegment() {
|
||||
|
Reference in New Issue
Block a user