Skip to content

Commit 56e7517

Browse files
author
Dmitry Tsymbal
committed
Applying Coupon Codes With Enabled Captcha
1 parent 1d1e97f commit 56e7517

7 files changed

+190
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontCaptchaVisibleOnShoppingCartApplyCouponCodeFormActionGroup">
12+
<waitForElement selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" time="30" stepKey="waitForCouponHeader"/>
13+
<conditionalClick selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" dependentSelector="{{StorefrontSalesRuleCartCouponSection.discountBlockActive}}" visible="false" stepKey="clickCouponHeader"/>
14+
<waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponField"/>
15+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaField}}" stepKey="waitToSeeCaptchaField"/>
16+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaImg}}" stepKey="waitToSeeCaptchaImage"/>
17+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaReload}}" stepKey="waitToSeeCaptchaReloadButton"/>
18+
<reloadPage stepKey="refreshPage"/>
19+
<waitForPageLoad stepKey="waitForPageReloaded"/>
20+
<waitForElement selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" time="30" stepKey="waitForCouponHeaderAfterReload"/>
21+
<conditionalClick selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" dependentSelector="{{StorefrontSalesRuleCartCouponSection.discountBlockActive}}" visible="false" stepKey="clickCouponHeaderAfterReload"/>
22+
<waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponFieldAfterReload"/>
23+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaField}}" stepKey="waitToSeeCaptchaFieldAfterPageReload"/>
24+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaImg}}" stepKey="waitToSeeCaptchaImageAfterPageReload"/>
25+
<waitForElementVisible selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaReload}}" stepKey="waitToSeeCaptchaReloadButtonAfterPageReload"/>
26+
</actionGroup>
27+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontShoppingCartFillCaptchaFieldOnApplyDiscountFormActionGroup">
12+
<arguments>
13+
<argument name="captcha" type="string"/>
14+
</arguments>
15+
16+
<fillField userInput="{{captcha}}" selector="{{StorefrontShoppingCartApplyDiscountCodeSection.captchaField}}" stepKey="fillCaptchaField"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Captcha/Test/Mftf/Data/CaptchaConfigData.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,10 @@
139139
<data key="label">ABCDEFGHJKMnpqrstuvwxyz23456789</data>
140140
<data key="value">ABCDEFGHJKMnpqrstuvwxyz23456789</data>
141141
</entity>
142+
<entity name="StorefrontCaptchaOnApplyingCouponCodeFormsConfigData">
143+
<data key="path">customer/captcha/forms</data>
144+
<data key="scope_id">0</data>
145+
<data key="label">Applying coupon code</data>
146+
<data key="value">sales_rule_coupon_request</data>
147+
</entity>
142148
</entities>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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="StorefrontShoppingCartApplyDiscountCodeSection">
12+
<element name="captchaField" type="input" selector="#discount-coupon-form input[name='captcha[sales_rule_coupon_request]']" />
13+
<element name="captchaImg" type="block" selector="#discount-coupon-form img.captcha-img"/>
14+
<element name="captchaReload" type="block" selector="#discount-coupon-form button.captcha-reload"/>
15+
</section>
16+
</sections>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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="StorefrontCaptchaOnApplyingCouponCodesFormsTest">
12+
<annotations>
13+
<features value="Captcha"/>
14+
<stories value="Applying coupon codes with enabled captcha"/>
15+
<title value="Captcha on applying coupon code forms"/>
16+
<description value="Customer should be able apply coupon codes with enabled captcha"/>
17+
<severity value="MINOR"/>
18+
<group value="captcha"/>
19+
</annotations>
20+
<before>
21+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
26+
<createData entity="SalesRuleSpecificCouponWithFixedDiscount" stepKey="createCartPriceRule"/>
27+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
28+
<requiredEntity createDataKey="createCartPriceRule"/>
29+
</createData>
30+
<magentoCLI command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}" stepKey="enableBankTransferPayment"/>
31+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
32+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaLength3ConfigData.path}} {{StorefrontCustomerCaptchaLength3ConfigData.value}}" stepKey="setCaptchaLength"/>
33+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaSymbols1ConfigData.path}} {{StorefrontCustomerCaptchaSymbols1ConfigData.value}}" stepKey="setCaptchaSymbols"/>
34+
<magentoCLI command="config:set {{StorefrontCaptchaOnApplyingCouponCodeFormsConfigData.path}} {{StorefrontCaptchaOnApplyingCouponCodeFormsConfigData.value}}" stepKey="enableCaptchaOnApplyingCouponsForms"/>
35+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaModeAlwaysConfigData.path}} {{StorefrontCustomerCaptchaModeAlwaysConfigData.value}}" stepKey="setCaptchaAlwaysVisible"/>
36+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
37+
<argument name="tags" value="config full_page"/>
38+
</actionGroup>
39+
</before>
40+
<after>
41+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
42+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
43+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
44+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
45+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
46+
<magentoCLI command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}" stepKey="disableBankTransferPayment"/>
47+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaDefaultLengthConfigData.path}} {{StorefrontCustomerCaptchaDefaultLengthConfigData.value}}" stepKey="setDefaultCaptchaLength"/>
48+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaDefaultSymbolsConfigData.path}} {{StorefrontCustomerCaptchaDefaultSymbolsConfigData.value}}" stepKey="setDefaultCaptchaSymbols"/>
49+
<magentoCLI command="config:set {{StorefrontCustomerCaptchaModeAfterFailConfigData.path}} {{StorefrontCustomerCaptchaModeAfterFailConfigData.value}}" stepKey="setCaptchaDefaultVisibility"/>
50+
<magentoCLI command="config:set {{StorefrontCaptchaOnCustomerLoginConfigData.path}} {{StorefrontCaptchaOnCustomerLoginConfigData.value}},{{StorefrontCaptchaOnCustomerForgotPasswordConfigData.value}}" stepKey="enableCaptchaOnDefaultForms"/>
51+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
52+
<argument name="tags" value="config full_page"/>
53+
</actionGroup>
54+
</after>
55+
56+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount">
57+
<argument name="Customer" value="$createCustomer$"/>
58+
</actionGroup>
59+
<actionGroup ref="OpenProductFromCategoryPageActionGroup" stepKey="openProductFromCategory">
60+
<argument name="category" value="$createCategory$"/>
61+
<argument name="product" value="$createProduct$"/>
62+
</actionGroup>
63+
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addProductToTheCart">
64+
<argument name="productQty" value="1"/>
65+
</actionGroup>
66+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="navigateToShoppingCart"/>
67+
<actionGroup ref="AssertStorefrontCaptchaVisibleOnShoppingCartApplyCouponCodeFormActionGroup" stepKey="assertCaptchaIsPresent"/>
68+
<actionGroup ref="StorefrontShoppingCartFillCouponCodeFieldActionGroup" stepKey="fillDiscountField">
69+
<argument name="discountCode" value="$$createCouponForCartPriceRule.code$$"/>
70+
</actionGroup>
71+
<actionGroup ref="StorefrontShoppingCartFillCaptchaFieldOnApplyDiscountFormActionGroup" stepKey="fillCaptchaWithIncorrectValues">
72+
<argument name="captcha" value="{{WrongCaptcha.value}}"/>
73+
</actionGroup>
74+
<actionGroup ref="StorefrontShoppingCartClickApplyDiscountButtonActionGroup" stepKey="clickApplyButton"/>
75+
<actionGroup ref="AssertMessageCustomerChangeAccountInfoActionGroup" stepKey="assertErrorMessage">
76+
<argument name="message" value="Incorrect CAPTCHA"/>
77+
<argument name="messageType" value="error"/>
78+
</actionGroup>
79+
<actionGroup ref="StorefrontShoppingCartFillCouponCodeFieldActionGroup" stepKey="fillDiscountCodeField">
80+
<argument name="discountCode" value="$$createCouponForCartPriceRule.code$$"/>
81+
</actionGroup>
82+
<actionGroup ref="StorefrontShoppingCartFillCaptchaFieldOnApplyDiscountFormActionGroup" stepKey="fillCaptchaWithCorrectValues">
83+
<argument name="captcha" value="{{PreconfiguredCaptcha.value}}"/>
84+
</actionGroup>
85+
<actionGroup ref="StorefrontShoppingCartClickApplyDiscountButtonActionGroup" stepKey="clickApplyDiscountButton"/>
86+
<actionGroup ref="AssertMessageCustomerChangeAccountInfoActionGroup" stepKey="assertSuccessMessage">
87+
<argument name="message" value='You used coupon code "$$createCouponForCartPriceRule.code$$".'/>
88+
</actionGroup>
89+
</test>
90+
</tests>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontShoppingCartClickApplyDiscountButtonActionGroup">
11+
<conditionalClick selector="{{DiscountSection.DiscountTab}}" dependentSelector="{{DiscountSection.CouponInput}}" visible="false" stepKey="clickToAddDiscount"/>
12+
<click selector="{{DiscountSection.ApplyCodeBtn}}" stepKey="clickToApplyDiscount"/>
13+
<waitForPageLoad stepKey="waitForPageLoad"/>
14+
</actionGroup>
15+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontShoppingCartFillCouponCodeFieldActionGroup">
11+
<arguments>
12+
<argument name="discountCode" type="string"/>
13+
</arguments>
14+
<conditionalClick selector="{{DiscountSection.DiscountTab}}" dependentSelector="{{DiscountSection.CouponInput}}" visible="false" stepKey="clickToAddDiscount"/>
15+
<waitForPageLoad stepKey="waitForPageLoad"/>
16+
<fillField selector="{{DiscountSection.CouponInput}}" userInput="{{discountCode}}" stepKey="fillFieldDiscountCode"/>
17+
</actionGroup>
18+
</actionGroups>

0 commit comments

Comments
 (0)