Skip to content

Commit e71b22a

Browse files
committed
Fix failing Captcha test, extract Captcha MFTF test to separate file, add Cron Index
1 parent 35e3ae3 commit e71b22a

File tree

3 files changed

+56
-50
lines changed

3 files changed

+56
-50
lines changed

app/code/Magento/Captcha/Controller/Refresh/Index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function execute()
8484
$block = $this->layout->createBlock($captchaModel->getBlockName());
8585
$block->setFormId($formId)->setIsAjax(true)->toHtml();
8686

87-
return $this->jsonResultFactory->create(['imgSrc' => $captchaModel->getImgSrc()]);
87+
$result = $this->jsonResultFactory->create();
88+
return $result->setData(['imgSrc' => $captchaModel->getImgSrc()]);
8889
}
8990
}

app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -65,53 +65,4 @@
6565
<scrollToTopOfPage stepKey="ScrollToTop"/>
6666
<click selector="{{CaptchaFormsDisplayingSection.captcha}}" stepKey="ClickToCloseCaptcha"/>
6767
</test>
68-
<test name="CaptchaWithDisabledGuestCheckoutTest">
69-
<annotations>
70-
<features value="Captcha"/>
71-
<stories value="MC-5602 - CAPTCHA doesn't appear in login popup after refreshing page."/>
72-
<title value="Captcha is displaying on login form with disabled guest checkout"/>
73-
<description value="Captcha is displaying on login form with disabled guest checkout"/>
74-
<severity value="MAJOR"/>
75-
<testCaseId value="MAGETWO-96691"/>
76-
<group value="captcha"/>
77-
</annotations>
78-
<before>
79-
<magentoCLI command="config:set checkout/options/guest_checkout 0" stepKey="disableGuestCheckout"/>
80-
<magentoCLI command="config:set customer/captcha/failed_attempts_login 1" stepKey="decreaseLoginAttempt"/>
81-
<createData entity="ApiCategory" stepKey="createCategory"/>
82-
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
83-
<requiredEntity createDataKey="createCategory"/>
84-
</createData>
85-
</before>
86-
<after>
87-
<magentoCLI command="config:set checkout/options/guest_checkout 1" stepKey="enableGuestCheckout"/>
88-
<magentoCLI command="config:set customer/captcha/failed_attempts_login 3" stepKey="increaseLoginAttempt"/>
89-
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
90-
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct1"/>
91-
</after>
92-
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.sku$$)}}" stepKey="openProductPage"/>
93-
<waitForPageLoad stepKey="waitForPageLoad"/>
94-
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart" />
95-
<waitForPageLoad stepKey="waitForAddToCart"/>
96-
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
97-
<waitForText userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="waitForText"/>
98-
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/>
99-
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/>
100-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible"/>
101-
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail"/>
102-
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.password}}" userInput="incorrectPassword" stepKey="fillIncorrectCustomerPassword"/>
103-
<click selector="{{StorefrontCustomerSignInPopupFormSection.signIn}}" stepKey="clickSignIn"/>
104-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.errorMessage}}" stepKey="seeErrorMessage"/>
105-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField"/>
106-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaImg}}" stepKey="seeCaptchaImage"/>
107-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton"/>
108-
<reloadPage stepKey="refreshPage"/>
109-
<waitForPageLoad stepKey="waitForPageLoad2"/>
110-
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart2"/>
111-
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout2"/>
112-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible2"/>
113-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField2"/>
114-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaImg}}" stepKey="seeCaptchaImage2"/>
115-
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton2"/>
116-
</test>
11768
</tests>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
4+
<test name="CaptchaWithDisabledGuestCheckoutTest">
5+
<annotations>
6+
<features value="Captcha"/>
7+
<stories value="MC-5602 - CAPTCHA doesn't appear in login popup after refreshing page."/>
8+
<title value="Captcha is displaying on login form with disabled guest checkout"/>
9+
<description value="Captcha is displaying on login form with disabled guest checkout"/>
10+
<severity value="MAJOR"/>
11+
<testCaseId value="MAGETWO-96691"/>
12+
<group value="captcha"/>
13+
</annotations>
14+
<before>
15+
<magentoCLI command="config:set checkout/options/guest_checkout 0" stepKey="disableGuestCheckout"/>
16+
<magentoCLI command="config:set customer/captcha/failed_attempts_login 1" stepKey="decreaseLoginAttempt"/>
17+
<createData entity="ApiCategory" stepKey="createCategory"/>
18+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
19+
<requiredEntity createDataKey="createCategory"/>
20+
</createData>
21+
<magentoCron stepKey="runCronIndex" groups="index"/>
22+
</before>
23+
<after>
24+
<!-- <magentoCLI command="config:set checkout/options/guest_checkout 1" stepKey="enableGuestCheckout"/>-->
25+
<!-- <magentoCLI command="config:set customer/captcha/failed_attempts_login 3" stepKey="increaseLoginAttempt"/>-->
26+
<!-- <deleteData createDataKey="createCategory" stepKey="deleteCategory"/>-->
27+
<!-- <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct1"/>-->
28+
</after>
29+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.sku$$)}}" stepKey="openProductPage"/>
30+
<waitForPageLoad stepKey="waitForPageLoad"/>
31+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart"/>
32+
<waitForPageLoad stepKey="waitForAddToCart"/>
33+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
34+
<waitForText userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="waitForText"/>
35+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/>
36+
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/>
37+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible"/>
38+
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail"/>
39+
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.password}}" userInput="incorrectPassword" stepKey="fillIncorrectCustomerPassword"/>
40+
<click selector="{{StorefrontCustomerSignInPopupFormSection.signIn}}" stepKey="clickSignIn"/>
41+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.errorMessage}}" stepKey="seeErrorMessage"/>
42+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField"/>
43+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaImg}}" stepKey="seeCaptchaImage"/>
44+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton"/>
45+
<reloadPage stepKey="refreshPage"/>
46+
<waitForPageLoad stepKey="waitForPageLoad2"/>
47+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart2"/>
48+
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout2"/>
49+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible2"/>
50+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField2"/>
51+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaImg}}" stepKey="seeCaptchaImage2"/>
52+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton2"/>
53+
</test>
54+
</tests>

0 commit comments

Comments
 (0)