Skip to content

Commit

Permalink
Merge branch '5.x' into 5.1.1-to-5.x-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
escopecz authored Oct 2, 2024
2 parents 5a4150e + 679f033 commit 5b86ecb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,21 @@ public function testCloneWorkflow(): void
$this->assertNotEquals($eventId, $responseData['eventId']);
$this->assertNotEmpty($responseData['eventHtml']);
}

public function testEmailSendTypeDefaultSetting(): void
{
// Fetch the campaign action form.
$uri = '/s/campaigns/events/new?type=email.send&eventType=action&campaignId=mautic_89f7f52426c1dff3daa3beaea708a6b39fe7a775&anchor=leadsource&anchorEventType=source';
$this->client->request('GET', $uri, [], [], $this->createAjaxHeaders());
$response = $this->client->getResponse();
Assert::assertTrue($response->isOk(), $response->getContent());

// Get the form HTML element out of the response
$responseData = json_decode($response->getContent(), true);
$crawler = new Crawler($responseData['newContent'], $this->client->getInternalRequest()->getUri());
$form = $crawler->filterXPath('//form[@name="campaignevent"]')->form();

// Assert the field email_type === "marketing"
Assert::assertEquals('marketing', $form['campaignevent[properties][email_type]']->getValue(), 'The default email type should be "marketing"');
}
}
2 changes: 1 addition & 1 deletion app/bundles/EmailBundle/Form/Type/EmailSendType.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'class' => 'form-control email-type',
'tooltip' => 'mautic.email.send.emailtype.tooltip',
],
'data' => (!isset($options['data']['email_type'])) ? MailHelper::EMAIL_TYPE_TRANSACTIONAL : $options['data']['email_type'],
'data' => (!isset($options['data']['email_type'])) ? MailHelper::EMAIL_TYPE_MARKETING : $options['data']['email_type'],
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_support/Page/Acceptance/CategoriesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class CategoriesPage
public const BUNDLE_DROPDOWN = '#category_form_bundle_chosen > a > span';
public const BUNDLE_EMAIL_OPTION = "#category_form_bundle_chosen > div > ul > li[data-option-array-index='3']";
public const TITLE_FIELD = 'category_form[title]';
public const SAVE_AND_CLOSE = '#MauticSharedModal > div > div > div.modal-footer > div > button.btn.btn-default.btn-save.btn-copy';
public const SAVE_AND_CLOSE = 'div.modal-form-buttons button.btn.btn-primary.btn-save.btn-copy';
}
2 changes: 1 addition & 1 deletion tests/_support/Page/Acceptance/EmailsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EmailsPage
public const NEW_CATEGORY_DROPDOWN = '#email_batch_newCategory_chosen';
public const CHANGE_CATEGORY_ACTION = "a[href='/s/emails/batch/categories/view']";
public const SELECTED_ACTIONS_DROPDOWN = '#page-list-wrapper > div.page-list > div.table-responsive > table > thead > tr > th.col-actions > div > div > button > i';
public const SAVE_BUTTON = '#MauticSharedModal > div > div > div.modal-footer > div > button.btn.btn-default.btn-save.btn-copy';
public const SAVE_BUTTON = 'div.modal-form-buttons > button.btn.btn-primary.btn-save.btn-copy';
public const SELECT_ALL_CHECKBOX = '#customcheckbox-one0';
public const SELECT_SEGMENT_EMAIL = '#app-content > div > div.modal.fade.in.email-type-modal > div > div > div.modal-body.form-select-modal > div > div:nth-child(2) > div > div.hidden-xs.panel-footer.text-center > button';
public const CONTACT_SEGMENT_DROPDOWN = '#emailform_lists_chosen';
Expand Down
32 changes: 11 additions & 21 deletions tests/acceptance/EmailManagementCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

class EmailManagementCest
{
private AcceptanceTester $I;
public const ADMIN_PASSWORD = 'Maut1cR0cks!';
public const ADMIN_USER = 'admin';
public const DATE_FORMAT = 'Y:m:d H:i:s';
public const ADMIN_PASSWORD = 'Maut1cR0cks!';
public const ADMIN_USER = 'admin';
public const DATE_FORMAT = 'Y:m:d H:i:s';

public function _before(AcceptanceTester $I): void
{
Expand All @@ -18,8 +17,6 @@ public function _before(AcceptanceTester $I): void

public function tryToBatchChangeEmailCategory(AcceptanceTester $I): void
{
$this->I = $I;

$now = date(self::DATE_FORMAT);

// Arrange
Expand All @@ -29,46 +26,39 @@ public function tryToBatchChangeEmailCategory(AcceptanceTester $I): void

// Act
$I->amOnPage(EmailsPage::URL);
$I->wait(1);
$this->selectAllEmails();
$this->selectChangeCategoryAction();
$newCategoryName = $this->doChangeCategory();
$this->selectAllEmails($I);
$this->selectChangeCategoryAction($I);
$newCategoryName = $this->doChangeCategory($I);
$I->reloadPage();

// Assert
$this->verifyAllEmailsBelongTo($newCategoryName);
$this->verifyAllEmailsBelongTo($I, $newCategoryName);
}

public function selectAllEmails(): void
public function selectAllEmails(AcceptanceTester $I): void
{
$I = $this->I;
$I->waitForElementClickable(EmailsPage::SELECT_ALL_CHECKBOX);
$I->click(EmailsPage::SELECT_ALL_CHECKBOX);
}

private function selectChangeCategoryAction(): void
private function selectChangeCategoryAction(AcceptanceTester $I): void
{
$I = $this->I;
$I->waitForElementClickable(EmailsPage::SELECTED_ACTIONS_DROPDOWN);
$I->click(EmailsPage::SELECTED_ACTIONS_DROPDOWN);
$I->waitForElementClickable(EmailsPage::CHANGE_CATEGORY_ACTION);
$I->click(EmailsPage::CHANGE_CATEGORY_ACTION);
}

protected function verifyAllEmailsBelongTo(string $firstCategoryName): void
protected function verifyAllEmailsBelongTo(AcceptanceTester $I, string $firstCategoryName): void
{
$I = $this->I;

$categories = $I->grabMultiple('span.label-category');
for ($i = 1; $i <= count($categories); ++$i) {
$I->see($firstCategoryName, '//*[@id="app-content"]/div/div[2]/div[2]/div[1]/table/tbody/tr['.$i.']/td[3]/div');
}
}

private function doChangeCategory(): string
private function doChangeCategory(AcceptanceTester $I): string
{
$I = $this->I;

$I->waitForElementClickable(EmailsPage::NEW_CATEGORY_DROPDOWN);
$I->click(EmailsPage::NEW_CATEGORY_DROPDOWN);
$I->waitForElementVisible(EmailsPage::NEW_CATEGORY_OPTION);
Expand Down

0 comments on commit 5b86ecb

Please sign in to comment.