Skip to content

Commit d3196b0

Browse files
author
Joan He
committed
Merge remote-tracking branch 'origin/MAGETWO-95906' into BugFixPR
2 parents c66e21d + 7163aee commit d3196b0

File tree

5 files changed

+160
-2
lines changed

5 files changed

+160
-2
lines changed

app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<page name="WebConfigurationPage" url="admin/system_config/edit/section/web/" area="admin" module="Backend">
1515
<section name="WYSIWYGOptionsSection"/>
1616
</page>
17+
<page name="GeneralConfigurationPage" url="admin/system_config/edit/section/general/" area="admin" module="Backend">
18+
<section name="LocaleOptionsSection"/>
19+
</page>
1720
</pages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="LocaleOptionsSection">
12+
<element name="sectionHeader" type="text" selector="#general_locale-head"/>
13+
<element name="timezone" type="select" selector="#general_locale_timezone"/>
14+
</section>
15+
</sections>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
8989
<waitForText userInput="${{total}}" selector="{{CheckoutCartSummarySection.total}}" time="30" stepKey="waitForTotal"/>
9090
<see userInput="${{subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/>
91-
<see userInput="${{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" stepKey="assertShipping"/>
9291
<see userInput="({{shippingMethod}})" selector="{{CheckoutCartSummarySection.shippingMethod}}" stepKey="assertShippingMethod"/>
92+
<waitForText userInput="${{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" time="30" stepKey="assertShipping"/>
9393
<see userInput="${{total}}" selector="{{CheckoutCartSummarySection.total}}" stepKey="assertTotal"/>
9494
</actionGroup>
9595

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,41 @@
66
*/
77
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
88

9-
class Save extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
9+
use Magento\Framework\App\Action\HttpPostActionInterface;
10+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
11+
12+
/**
13+
* SalesRule save controller
14+
*
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16+
*/
17+
class Save extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote implements HttpPostActionInterface
1018
{
19+
/**
20+
* @var TimezoneInterface
21+
*/
22+
private $timezone;
23+
24+
/**
25+
* @param \Magento\Backend\App\Action\Context $context
26+
* @param \Magento\Framework\Registry $coreRegistry
27+
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
28+
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
29+
* @param TimezoneInterface $timezone
30+
*/
31+
public function __construct(
32+
\Magento\Backend\App\Action\Context $context,
33+
\Magento\Framework\Registry $coreRegistry,
34+
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
35+
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
36+
TimezoneInterface $timezone = null
37+
) {
38+
parent::__construct($context, $coreRegistry, $fileFactory, $dateFilter);
39+
$this->timezone = $timezone ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
40+
TimezoneInterface::class
41+
);
42+
}
43+
1144
/**
1245
* Promo quote save action
1346
*
@@ -26,6 +59,9 @@ public function execute()
2659
['request' => $this->getRequest()]
2760
);
2861
$data = $this->getRequest()->getPostValue();
62+
if (empty($data['from_date'])) {
63+
$data['from_date'] = $this->timezone->formatDate();
64+
}
2965

3066
$filterValues = ['from_date' => $this->_dateFilter];
3167
if ($this->getRequest()->getParam('to_date')) {
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCreateCartPriceRuleEmptyFromDateTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule"/>
15+
<title value="Admin should be able to create a cart price rule with no starting date"/>
16+
<description value="Admin should be able to create a cart price rule without specifying the from_date and it should be set with the current date"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-5299"/>
19+
<group value="SalesRule"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="category"/>
24+
<createData entity="SimpleProduct" stepKey="product">
25+
<requiredEntity createDataKey="category"/>
26+
</createData>
27+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
28+
</before>
29+
30+
<after>
31+
<!-- Delete the cart price rule we made during the test -->
32+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="cleanUpRule">
33+
<argument name="ruleName" value="{{_defaultCoupon.code}}"/>
34+
</actionGroup>
35+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
36+
<deleteData createDataKey="product" stepKey="deleteProduct"/>
37+
<actionGroup ref="logout" stepKey="logout"/>
38+
</after>
39+
40+
<!--Set timezone-->
41+
<!--Set timezone so we need compare with the same timezone used in "generateDate" action-->
42+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfig"/>
43+
<waitForPageLoad stepKey="waitForConfigPage"/>
44+
<wait stepKey="wait" time="10"/>
45+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSection"/>
46+
<grabValueFrom selector="{{LocaleOptionsSection.timezone}}" stepKey="originalTimezone"/>
47+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="America/Los_Angeles" stepKey="setTimezone"/>
48+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
49+
50+
<!-- Create a cart price rule based on a coupon code -->
51+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
52+
<waitForPageLoad stepKey="waitForPriceList"/>
53+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
54+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="fillRuleName"/>
55+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
56+
<actionGroup ref="selectNotLoggedInCustomerGroup" stepKey="selectCustomerGroup"/>
57+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="selectCouponType"/>
58+
<fillField selector="{{AdminCartPriceRulesFormSection.couponCode}}" userInput="{{_defaultCoupon.code}}" stepKey="fillCouponCode"/>
59+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
60+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount for whole cart" stepKey="selectActionType"/>
61+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="5" stepKey="fillDiscountAmount"/>
62+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
63+
64+
<!-- Verify initial successful save -->
65+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
66+
<fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="{{_defaultCoupon.code}}" stepKey="filterByName"/>
67+
<click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="doFilter"/>
68+
<see selector="{{AdminCartPriceRulesSection.nameColumns}}" userInput="{{_defaultCoupon.code}}" stepKey="seeRuleInResults"/>
69+
70+
<!-- Verify further on the Rule's edit page -->
71+
<click selector="{{AdminCartPriceRulesSection.rowContainingText(_defaultCoupon.code)}}" stepKey="goToEditRule"/>
72+
<seeInField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="seeRuleName"/>
73+
<seeOptionIsSelected selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="seeWebsites"/>
74+
<seeOptionIsSelected selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="seeCouponType"/>
75+
<seeInField selector="{{AdminCartPriceRulesFormSection.couponCode}}" userInput="{{_defaultCoupon.code}}" stepKey="seeCouponCode"/>
76+
<generateDate date="now" format="m/j/Y" timezone="America/Los_Angeles" stepKey="today"/>
77+
<seeInField selector="{{AdminCartPriceRulesFormSection.fromDate}}" userInput="$today" stepKey="seeCorrectFromDate"/>
78+
<seeInField selector="{{AdminCartPriceRulesFormSection.toDate}}" userInput="" stepKey="seeEmptyToDate"/>
79+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions2"/>
80+
<seeOptionIsSelected selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount for whole cart" stepKey="seeActionType"/>
81+
<seeInField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="5" stepKey="seeDiscountAmount"/>
82+
83+
<!-- Spot check the storefront -->
84+
<amOnPage url="$$product.custom_attributes[url_key]$$.html" stepKey="goToProductPage"/>
85+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
86+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
87+
<waitForPageLoad stepKey="waitForAddToCart"/>
88+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
89+
<waitForPageLoad stepKey="waitForCartPage"/>
90+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon">
91+
<argument name="coupon" value="_defaultCoupon"/>
92+
</actionGroup>
93+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
94+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>
95+
<see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$5.00" stepKey="seeDiscountTotal"/>
96+
97+
<!--Reset timezone-->
98+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfigReset"/>
99+
<waitForPageLoad stepKey="waitForConfigPageReset"/>
100+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSectionReset"/>
101+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="$originalTimezone" stepKey="resetTimezone"/>
102+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset"/>
103+
</test>
104+
</tests>

0 commit comments

Comments
 (0)