Skip to content

Commit cbdfcc3

Browse files
committed
Refactoring
1 parent 2302d11 commit cbdfcc3

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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="StorefrontCustomerResetPasswordActionGroup">
12+
<arguments>
13+
<argument name="email" type="string" />
14+
<argument name="message" type="string" defaultValue="" />
15+
<argument name="messageType" type="string" defaultValue="success" />
16+
</arguments>
17+
18+
<amOnPage stepKey="amOnSignInPage" url="{{StorefrontCustomerSignInPage.url}}"/>
19+
<click stepKey="clickForgotPasswordLink" selector="{{StorefrontCustomerSignInFormSection.forgotPasswordLink}}"/>
20+
<see stepKey="seePageTitle" userInput="Forgot Your Password" selector="{{StorefrontForgotPasswordSection.pageTitle}}"/>
21+
<!-- Enter email and submit the forgot password form -->
22+
<fillField stepKey="fillEmailField" userInput="{{email}}" selector="{{StorefrontForgotPasswordSection.email}}"/>
23+
<click stepKey="clickResetPassword" selector="{{StorefrontForgotPasswordSection.resetMyPasswordButton}}"/>
24+
<waitForPageLoad stepKey="waitForPageLoaded" />
25+
<waitForElementVisible selector="{{StorefrontCustomerLoginMessagesSection.messageByType(messageType)}}" stepKey="waitForMessage" />
26+
<see stepKey="seeMessage" userInput="{{message}}" selector="{{StorefrontCustomerLoginMessagesSection.messageByType(messageType)}}"/>
27+
</actionGroup>
28+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerLoginMessagesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="StorefrontCustomerLoginMessagesSection">
1212
<element name="successMessage" type="text" selector=".message-success"/>
1313
<element name="errorMessage" type="text" selector=".message-error"/>
14+
<element name="messageByType" type="block" selector="#maincontent .message-{{messageType}}" parameterized="true"/>
1415
</section>
1516
</sections>

app/code/Magento/Customer/Test/Mftf/Test/StorefrontResetCustomerPasswordFailedTest.xml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,18 @@
2222
<createData stepKey="customer" entity="Simple_US_Customer"/>
2323
</before>
2424
<after>
25+
<magentoCLI command="config:set customer/captcha/enable 1" stepKey="enableCaptcha"/>
2526
<deleteData stepKey="deleteCustomer" createDataKey="customer" />
2627
</after>
27-
<!-- Go to login page, and click on the forgot password link -->
28-
<amOnPage stepKey="amOnSignInPage1" url="{{StorefrontCustomerSignInPage.url}}"/>
29-
<click stepKey="clickForgotPasswordLink1" selector="{{StorefrontCustomerSignInFormSection.forgotPasswordLink}}"/>
30-
<see stepKey="seePageTitle1" userInput="Forgot Your Password" selector="{{StorefrontForgotPasswordSection.pageTitle}}"/>
31-
<!-- Enter email and submit the forgot password form -->
32-
<fillField stepKey="enterEmail1" userInput="$$customer.email$$" selector="{{StorefrontForgotPasswordSection.email}}"/>
33-
<click stepKey="clickResetPassword1" selector="{{StorefrontForgotPasswordSection.resetMyPasswordButton}}"/>
34-
<seeInCurrentUrl stepKey="seeInSignInPage" url="account/login"/>
35-
<waitForElementVisible selector="{{StorefrontCustomerLoginMessagesSection.successMessage}}" stepKey="waitForSuccessMessage" />
36-
<see stepKey="seeSuccessMessage" userInput="If there is an account associated with $$customer.email$$ you will receive an email with a link to reset your password." selector="{{StorefrontCustomerLoginMessagesSection.successMessage}}"/>
37-
<!-- Repeat the procedure once again and ensure that on a second attempt customer sees an error -->
38-
<amOnPage stepKey="amOnSignInPage2" url="{{StorefrontCustomerSignInPage.url}}"/>
39-
<click stepKey="clickForgotPasswordLink2" selector="{{StorefrontCustomerSignInFormSection.forgotPasswordLink}}"/>
40-
<see stepKey="seePageTitle2" userInput="Forgot Your Password" selector="{{StorefrontForgotPasswordSection.pageTitle}}"/>
41-
<fillField stepKey="enterEmail2" userInput="$$customer.email$$" selector="{{StorefrontForgotPasswordSection.email}}"/>
42-
<click stepKey="clickResetPassword2" selector="{{StorefrontForgotPasswordSection.resetMyPasswordButton}}"/>
43-
<seeInCurrentUrl stepKey="seeInForgotPasswordPage" url="account/forgotpassword"/>
44-
<waitForElementVisible selector="{{StorefrontCustomerLoginMessagesSection.errorMessage}}" stepKey="waitForFailMessage" />
45-
<see stepKey="seeFailMessage" userInput="We received too many requests for password resets. Please wait and try again later or contact [email protected]." selector="{{StorefrontCustomerLoginMessagesSection.errorMessage}}"/>
28+
29+
<actionGroup ref="StorefrontCustomerResetPasswordActionGroup" stepKey="resetPasswordFirstAttempt">
30+
<argument name="email" value="$$customer.email$$" />
31+
<argument name="message" value="If there is an account associated with $$customer.email$$ you will receive an email with a link to reset your password."/>
32+
</actionGroup>
33+
<actionGroup ref="StorefrontCustomerResetPasswordActionGroup" stepKey="resetPasswordSecondAttempt">
34+
<argument name="email" value="$$customer.email$$" />
35+
<argument name="message" value="We received too many requests for password resets. Please wait and try again later or contact [email protected]."/>
36+
<argument name="messageType" value="error" />
37+
</actionGroup>
4638
</test>
4739
</tests>

0 commit comments

Comments
 (0)