Skip to content

Commit

Permalink
Merge pull request #5029 from magento-borg/MC-23123
Browse files Browse the repository at this point in the history
[cia] 2.2 bugfixes
  • Loading branch information
nathanjosiah authored Nov 15, 2019
2 parents e98eff7 + 60ccf94 commit 7b5b332
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/code/Magento/Email/Block/Adminhtml/Template/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ protected function _toHtml()
$template->setTemplateType($this->getRequest()->getParam('type'));
$template->setTemplateText($this->getRequest()->getParam('text'));
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
// Emulate DB-loaded template to invoke strict mode
$template->setTemplateId(123);
}

$template->setTemplateText($this->_maliciousCode->filter($template->getTemplateText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@

<see userInput="{{expectedContent}}" stepKey="checkTemplateContainText"/>
</actionGroup>

<actionGroup name="AdminPrepareDraftCustomTemplate" extends="AdminCreateNewEmailTemplate">
<remove keyForRemoval="selectValueFromTemplateDropDown"/>
<remove keyForRemoval="clickLoadTemplateButton"/>
<remove keyForRemoval="clickSaveTemplateButton"/>
<remove keyForRemoval="waitForSuccessMessage"/>
<remove keyForRemoval="seeSuccessMessage"/>

<fillField selector="{{AdminEmailTemplateEditSection.templateSubject}}" userInput="{{template.templateSubject}}" after="fillTemplateNameField" stepKey="fillTemplateSubject"/>
<fillField selector="{{AdminEmailTemplateEditSection.templateText}}" userInput="{{template.templateText}}" after="fillTemplateSubject" stepKey="fillTemplateText"/>
</actionGroup>
</actionGroups>
7 changes: 7 additions & 0 deletions app/code/Magento/Email/Test/Mftf/Data/EmailTemplateData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
<data key="templateSubject" unique="suffix">Template Subject_</data>
<data key="templateText" unique="suffix">Template Text_</data>
</entity>

<entity name="EmailTemplateWithDirectives" type="template">
<data key="templateName" unique="suffix">Template</data>
<data key="templateSubject" unique="suffix">Template Subject_</data>
<data key="templateText">Template {{var this.template_id}}{{var this.getData(template_id)}} Text</data>
<data key="expectedTemplate">Template 123 Text</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<testCaseId value="MC-15925"/>
<useCaseId value="MAGETWO-97672"/>
<group value="email"/>
<group value="WYSIWYGDisabled"/>
</annotations>

<before>
Expand All @@ -37,4 +38,76 @@
<actionGroup ref="AdminPreviewEmailTemplate" stepKey="previewTemplate"/>
<actionGroup ref="AdminAssertEmailTemplateContent" stepKey="assertContent"/>
</test>

<test name="AdminEmailTemplatePreviewWithDirectivesTest">
<annotations>
<features value="Email"/>
<stories value="Create email template with directives"/>
<title value="Check email template preview with directives"/>
<description value="Check if email template preview works correctly with directives"/>
<severity value="CRITICAL"/>
<useCaseId value="MC-23058"/>
<group value="email"/>
<group value="WYSIWYGDisabled"/>
<stories value="Email Template Preview"/>
</annotations>

<before>
<!--Login to Admin Area-->
<actionGroup ref="LoginAsAdmin" stepKey="loginToAdminArea"/>
</before>

<after>
<!--Delete created Template-->
<actionGroup ref="AdminDeleteEmailTemplate" stepKey="deleteTemplate"/>
<click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clearFilters"/>
<!--Logout from Admin Area-->
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
</after>

<actionGroup ref="AdminCreateCustomTemplate" stepKey="createTemplate">
<argument name="template" value="EmailTemplateWithDirectives"/>
</actionGroup>
<actionGroup ref="AdminPreviewEmailTemplate" stepKey="previewTemplate"/>
<actionGroup ref="AdminAssertEmailTemplateContent" stepKey="assertContent">
<argument name="expectedContent" value="{{EmailTemplateWithDirectives.expectedTemplate}}"/>
</actionGroup>
</test>

<test name="AdminEmailTemplatePreviewAsDraftWithDirectivesTest">
<annotations>
<features value="Email"/>
<stories value="Create email template with directives and preview as draft"/>
<title value="Check email template preview with directives and preview as draft"/>
<description value="Check if email template preview works correctly with directives in draft mode"/>
<severity value="CRITICAL"/>
<useCaseId value="MC-23058"/>
<group value="email"/>
<group value="WYSIWYGDisabled"/>
<stories value="Email Template Preview"/>
</annotations>

<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginToAdminArea"/>
</before>

<after>
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
</after>

<actionGroup ref="AdminPrepareDraftCustomTemplate" stepKey="createDraftTemplate">
<argument name="template" value="EmailTemplateWithDirectives"/>
</actionGroup>

<click selector="{{AdminEmailTemplateEditSection.previewTemplateButton}}" stepKey="clickPreviewTemplate"/>
<switchToNextTab stepKey="switchToPreviewTab"/>
<seeInCurrentUrl url="{{AdminEmailTemplatePreviewPage.url}}" stepKey="seePreviewInUrl"/>
<seeElement selector="{{AdminEmailTemplatePreviewSection.iframe}}" stepKey="seeIframeOnPage"/>
<switchToIFrame userInput="preview_iframe" stepKey="switchToIframe"/>
<waitForPageLoad stepKey="waitForPreviewLoaded"/>

<actionGroup ref="AdminAssertEmailTemplateContent" stepKey="assertContent">
<argument name="expectedContent" value="{{EmailTemplateWithDirectives.expectedTemplate}}"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected function _toHtml()
$template->setTemplateType($previewData['type']);
$template->setTemplateText($previewData['text']);
$template->setTemplateStyles($previewData['styles']);
// Emulate DB-loaded template to invoke strict mode
$template->setTemplateId(123);
}

\Magento\Framework\Profiler::start($this->profilerName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminAdminSwitchToPreviewIframeActionGroup">
<executeJS function="document.getElementById('preview_iframe').sandbox.add('allow-scripts')" stepKey="addSandboxValue"/>
<wait time="10" stepKey="waitBeforeSwitchToIframe"/>
<switchToIFrame userInput="preview_iframe" stepKey="switchToIframe" />
<waitForPageLoad stepKey="waitForPageLoad"/>
</actionGroup>
<actionGroup name="AdminNavigateToNewsletterGrid">
<amOnPage url="{{NewsletterTemplateForm.url}}" stepKey="amOnNewsletterTemplatePage"/>
<waitForPageLoad stepKey="waitForNewNewsletterPageLoad"/>
</actionGroup>

<actionGroup name="AdminFillNewsletterForm">
<arguments>
<argument name="Newsletter" defaultValue="BasicFieldNewsletterSection"/>
</arguments>
<waitForElementVisible selector="{{BasicFieldNewsletterSection.templateName}}" stepKey="waitForTemplateNameField"/>
<fillField selector="{{BasicFieldNewsletterSection.templateName}}" userInput="{{Newsletter.name}}" stepKey="fillTemplateName" />
<fillField selector="{{BasicFieldNewsletterSection.templateSubject}}" userInput="{{Newsletter.subject}}" stepKey="fillTemplateSubject" />
<fillField selector="{{BasicFieldNewsletterSection.senderName}}" userInput="{{Newsletter.senderName}}" stepKey="fillSenderName" />
<fillField selector="{{BasicFieldNewsletterSection.senderEmail}}" userInput="{{Newsletter.senderEmail}}" stepKey="fillSenderEmail" />
<fillField selector="{{BasicFieldNewsletterSection.templateText}}" userInput="{{Newsletter.templateText}}" stepKey="fillTemplateText" />
</actionGroup>

<actionGroup name="AdminOpenNewsletterPreviewTab">
<waitForElementVisible selector="{{BasicFieldNewsletterSection.templateName}}" stepKey="waitForPreviewButton"/>
<click selector="{{BasicFieldNewsletterSection.preview}}" stepKey="clickPreview"/>
<switchToNextTab stepKey="switchToPreviewTab"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
<waitForElementVisible selector="{{BasicFieldNewsletterSection.previewIframe}}" stepKey="waitForIframeVisible"/>
<executeJS function="document.getElementById('preview_iframe').sandbox.add('allow-scripts')" stepKey="addSandboxValue"/>
<switchToIFrame userInput="preview_iframe" stepKey="switchToIframe"/>
<waitForElementVisible selector="body" stepKey="waitForIframeLoad"/>
</actionGroup>

<actionGroup name="AdminAssertNewsletterContent">
<arguments>
<argument name="Newsletter" defaultValue="BasicFieldNewsletterSection"/>
</arguments>
<waitForText userInput="{{Newsletter.expectedTemplate}}" stepKey="checkTemplateContainsText" time="30"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="NewsletterWithDirectives" type="template">
<data key="name" unique="suffix">Test Newsletter Template</data>
<data key="subject">Test Newsletter Subject</data>
<data key="senderName">Admin</data>
<data key="senderEmail">[email protected]</data>
<data key="templateText">Template {{var this.template_id}}{{var this.getData(template_id)}} Text</data>
<data key="expectedTemplate">Template 123 Text</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="NewsletterTemplateForm" url="/newsletter/template/new/" area="admin" module="Magento_Cms">
<section name="StorefrontNewsletterSection"/>
<section name="StorefrontNewsletterSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="BasicFieldNewsletterSection">
<element name="templateName" type="input" selector="#code"/>
<element name="templateSubject" type="input" selector="#subject"/>
<element name="templateText" type="input" selector="#text"/>
<element name="senderName" type="input" selector="#sender_name"/>
<element name="senderEmail" type="input" selector="#sender_email"/>
<element name="preview" type="button" selector="button[data-role='template-preview']"/>
<element name="previewIframe" type="iframe" selector="#preview_iframe"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminNewsletterDraftPreviewTest">
<annotations>
<features value="Newsletter"/>
<group value="Newsletter"/>
<group value="WYSIWYGDisabled"/>
<title value="Admin should be able to preview Newsletter content in draft mode"/>
<description value="Admin should be able to preview newsletter content in draft mode"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-23058"/>
<stories value="Newsletter Preview"/>
</annotations>

<before>
<actionGroup ref="LoginActionGroup" stepKey="login"/>
</before>

<after>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<actionGroup ref="AdminNavigateToNewsletterGrid" stepKey="navigateToGrid"/>

<actionGroup ref="AdminFillNewsletterForm" stepKey="fillForm">
<argument name="Newsletter" value="NewsletterWithDirectives"/>
</actionGroup>

<actionGroup ref="AdminOpenNewsletterPreviewTab" stepKey="openPreviewTab"/>

<actionGroup ref="AdminAssertNewsletterContent" stepKey="assertTemplateContent">
<argument name="Newsletter" value="NewsletterWithDirectives"/>
</actionGroup>

<closeTab stepKey="closeTab"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public function getName(): string
public function process(
$value,
array $parameters,
?string $html
$html = null
): string {
return $value . $parameters['param1'] . $html;
}

/**
* @inheritDoc
*/
public function getDefaultFilters(): ?array
public function getDefaultFilters()
{
return ['foofilter'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public function getName(): string;
public function process(
$value,
array $parameters,
?string $html
$html = null
): string;

/**
* Default filters to apply if none provided in a template.
*
* @return string[]|null
*/
public function getDefaultFilters(): ?array;
public function getDefaultFilters();
}

0 comments on commit 7b5b332

Please sign in to comment.