Skip to content

Commit 3c34e1d

Browse files
authored
Merge pull request #903 from magento-epam/pr3
[Epam] Extend functional test sprint 3 - MTO-102: [Test] Captcha on register customer - MTO-136: [Test] [Test] Captcha on Contact Us form - MTO-144: [Test] Captcha and lockout for Storefront login page - MTO-121: [Variation] Move Anchored Category with Products (cron is ON, "Update on Save") - MTO-134: [Variation] Add Simple Product with required Custom Options to Cart
2 parents 378ac7a + bf57a52 commit 3c34e1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1800
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Block\Form;
8+
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Contact\Test\Block\Form\ContactUs as ContactForm;
11+
12+
/**
13+
* Form for "Contact Us" page with captcha.
14+
*/
15+
class ContactUs extends ContactForm
16+
{
17+
/**
18+
* Captcha image selector.
19+
*
20+
* @var string
21+
*/
22+
private $captchaImage = '.captcha-img';
23+
24+
/**
25+
* Captcha reload button selector.
26+
*
27+
* @var string
28+
*/
29+
private $captchaReload = '.captcha-reload';
30+
31+
/**
32+
* Get captcha element visibility.
33+
*
34+
* @return bool
35+
*/
36+
public function isVisibleCaptcha()
37+
{
38+
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
39+
}
40+
41+
/**
42+
* Get captcha reload button element visibility.
43+
*
44+
* @return bool
45+
*/
46+
public function isVisibleCaptchaReloadButton()
47+
{
48+
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
49+
}
50+
51+
/**
52+
* Click captcha reload button element.
53+
*
54+
* @return void
55+
*/
56+
public function reloadCaptcha()
57+
{
58+
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="0">
9+
<fields>
10+
<captcha>
11+
<selector>[name='captcha[contact_us]']</selector>
12+
</captcha>
13+
</fields>
14+
</mapping>

dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/LoginWithCaptcha.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Magento\Mtf\Client\Locator;
1010
use Magento\Customer\Test\Block\Form\Login;
11-
use Magento\Mtf\Client\ElementInterface;
1211

1312
/**
1413
* Form for storefront login with captcha.
@@ -54,7 +53,7 @@ public function isVisibleCaptchaReloadButton()
5453
*
5554
* @return void
5655
*/
57-
public function clickReloadCaptchaButton()
56+
public function reloadCaptcha()
5857
{
5958
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
6059
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Block\Form;
8+
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Customer\Test\Block\Form\Register as CustomerRegister;
11+
12+
/**
13+
* Form for storefront register customer with captcha.
14+
*/
15+
class Register extends CustomerRegister
16+
{
17+
/**
18+
* Captcha image selector.
19+
*
20+
* @var string
21+
*/
22+
private $captchaImage = '.captcha-img';
23+
24+
/**
25+
* Captcha reload button selector.
26+
*
27+
* @var string
28+
*/
29+
private $captchaReload = '.captcha-reload';
30+
31+
/**
32+
* Get captcha element visibility.
33+
*
34+
* @return bool
35+
*/
36+
public function isVisibleCaptcha()
37+
{
38+
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
39+
}
40+
41+
/**
42+
* Get captcha reload button element visibility.
43+
*
44+
* @return bool
45+
*/
46+
public function isVisibleCaptchaReloadButton()
47+
{
48+
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
49+
}
50+
51+
/**
52+
* Click on captcha reload button.
53+
*
54+
* @return void
55+
*/
56+
public function reloadCaptcha()
57+
{
58+
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="0">
9+
<fields>
10+
<captcha>
11+
<selector>[name='captcha[user_create]']</selector>
12+
</captcha>
13+
</fields>
14+
</mapping>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Constraint;
8+
9+
use Magento\Contact\Test\Page\ContactIndex;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert captcha on the Contact Us page.
14+
*/
15+
class AssertCaptchaFieldOnContactUsForm extends AbstractConstraint
16+
{
17+
/**
18+
* Assert captcha on the Contact Us page.
19+
*
20+
* @param ContactIndex $contactIndex
21+
* @return void
22+
*/
23+
public function processAssertRegisterForm(ContactIndex $contactIndex)
24+
{
25+
\PHPUnit_Framework_Assert::assertTrue(
26+
$contactIndex->getContactUs()->isVisibleCaptcha(),
27+
'Captcha image is not displayed on the Contact Us page.'
28+
);
29+
30+
\PHPUnit_Framework_Assert::assertTrue(
31+
$contactIndex->getContactUs()->isVisibleCaptchaReloadButton(),
32+
'Captcha reload button is not displayed on the Contact Us page.'
33+
);
34+
}
35+
36+
/**
37+
* Returns a string representation of the object.
38+
*
39+
* @return string
40+
*/
41+
public function toString()
42+
{
43+
return 'Captcha and reload button are present on the Contact Us page.';
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Constraint;
8+
9+
use Magento\Customer\Test\Page\CustomerAccountCreate;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert captcha on storefront account register page.
14+
*/
15+
class AssertCaptchaFieldOnRegisterForm extends AbstractConstraint
16+
{
17+
/**
18+
* Assert captcha and reload button are visible on storefront account register page.
19+
*
20+
* @param CustomerAccountCreate $createAccountPage
21+
* @return void
22+
*/
23+
public function processAssertRegisterForm(CustomerAccountCreate $createAccountPage)
24+
{
25+
\PHPUnit_Framework_Assert::assertTrue(
26+
$createAccountPage->getRegisterForm()->isVisibleCaptcha(),
27+
'Captcha image is not displayed on the storefront account register page.'
28+
);
29+
30+
\PHPUnit_Framework_Assert::assertTrue(
31+
$createAccountPage->getRegisterForm()->isVisibleCaptchaReloadButton(),
32+
'Captcha reload button is not displayed on the storefront account register page.'
33+
);
34+
}
35+
36+
/**
37+
* Returns a string representation of the object.
38+
*
39+
* @return string
40+
*/
41+
public function toString()
42+
{
43+
return 'Captcha and reload button are displayed on the storefront account register page.';
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
9+
<fixture name="comment">
10+
<field name="captcha" is_required="0" />
11+
</fixture>
12+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="ContactIndex" mca="contact/index/index" module="Magento_Contact">
10+
<block name="contactUs" class="Magento\Captcha\Test\Block\Form\ContactUs" locator="#contact-form" strategy="css selector" />
11+
</page>
12+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="CustomerAccountCreate" mca="customer/account/create">
10+
<block name="registerForm" class="Magento\Captcha\Test\Block\Form\Register" locator="#form-validate[novalidate='novalidate']" strategy="css selector" />
11+
</page>
12+
</config>

dev/tests/functional/tests/app/Magento/Captcha/Test/Page/CustomerAccountLogin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9-
<page name="CustomerAccountLogin">
9+
<page name="CustomerAccountLogin" mca="customer/account/login">
1010
<block name="loginBlockWithCaptcha" class="Magento\Captcha\Test\Block\Form\LoginWithCaptcha" locator="#login-form" strategy="css selector"/>
1111
</page>
1212
</config>

0 commit comments

Comments
 (0)