Skip to content

Commit

Permalink
Merge pull request #903 from magento-epam/pr3
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
okolesnyk authored Mar 14, 2017
2 parents 378ac7a + bf57a52 commit 3c34e1d
Show file tree
Hide file tree
Showing 43 changed files with 1,800 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Block\Form;

use Magento\Mtf\Client\Locator;
use Magento\Contact\Test\Block\Form\ContactUs as ContactForm;

/**
* Form for "Contact Us" page with captcha.
*/
class ContactUs extends ContactForm
{
/**
* Captcha image selector.
*
* @var string
*/
private $captchaImage = '.captcha-img';

/**
* Captcha reload button selector.
*
* @var string
*/
private $captchaReload = '.captcha-reload';

/**
* Get captcha element visibility.
*
* @return bool
*/
public function isVisibleCaptcha()
{
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Get captcha reload button element visibility.
*
* @return bool
*/
public function isVisibleCaptchaReloadButton()
{
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Click captcha reload button element.
*
* @return void
*/
public function reloadCaptcha()
{
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="0">
<fields>
<captcha>
<selector>[name='captcha[contact_us]']</selector>
</captcha>
</fields>
</mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use Magento\Mtf\Client\Locator;
use Magento\Customer\Test\Block\Form\Login;
use Magento\Mtf\Client\ElementInterface;

/**
* Form for storefront login with captcha.
Expand Down Expand Up @@ -54,7 +53,7 @@ public function isVisibleCaptchaReloadButton()
*
* @return void
*/
public function clickReloadCaptchaButton()
public function reloadCaptcha()
{
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Block\Form;

use Magento\Mtf\Client\Locator;
use Magento\Customer\Test\Block\Form\Register as CustomerRegister;

/**
* Form for storefront register customer with captcha.
*/
class Register extends CustomerRegister
{
/**
* Captcha image selector.
*
* @var string
*/
private $captchaImage = '.captcha-img';

/**
* Captcha reload button selector.
*
* @var string
*/
private $captchaReload = '.captcha-reload';

/**
* Get captcha element visibility.
*
* @return bool
*/
public function isVisibleCaptcha()
{
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Get captcha reload button element visibility.
*
* @return bool
*/
public function isVisibleCaptchaReloadButton()
{
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Click on captcha reload button.
*
* @return void
*/
public function reloadCaptcha()
{
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="0">
<fields>
<captcha>
<selector>[name='captcha[user_create]']</selector>
</captcha>
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Constraint;

use Magento\Contact\Test\Page\ContactIndex;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assert captcha on the Contact Us page.
*/
class AssertCaptchaFieldOnContactUsForm extends AbstractConstraint
{
/**
* Assert captcha on the Contact Us page.
*
* @param ContactIndex $contactIndex
* @return void
*/
public function processAssertRegisterForm(ContactIndex $contactIndex)
{
\PHPUnit_Framework_Assert::assertTrue(
$contactIndex->getContactUs()->isVisibleCaptcha(),
'Captcha image is not displayed on the Contact Us page.'
);

\PHPUnit_Framework_Assert::assertTrue(
$contactIndex->getContactUs()->isVisibleCaptchaReloadButton(),
'Captcha reload button is not displayed on the Contact Us page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Captcha and reload button are present on the Contact Us page.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Constraint;

use Magento\Customer\Test\Page\CustomerAccountCreate;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assert captcha on storefront account register page.
*/
class AssertCaptchaFieldOnRegisterForm extends AbstractConstraint
{
/**
* Assert captcha and reload button are visible on storefront account register page.
*
* @param CustomerAccountCreate $createAccountPage
* @return void
*/
public function processAssertRegisterForm(CustomerAccountCreate $createAccountPage)
{
\PHPUnit_Framework_Assert::assertTrue(
$createAccountPage->getRegisterForm()->isVisibleCaptcha(),
'Captcha image is not displayed on the storefront account register page.'
);

\PHPUnit_Framework_Assert::assertTrue(
$createAccountPage->getRegisterForm()->isVisibleCaptchaReloadButton(),
'Captcha reload button is not displayed on the storefront account register page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Captcha and reload button are displayed on the storefront account register page.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
<fixture name="comment">
<field name="captcha" is_required="0" />
</fixture>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
<page name="ContactIndex" mca="contact/index/index" module="Magento_Contact">
<block name="contactUs" class="Magento\Captcha\Test\Block\Form\ContactUs" locator="#contact-form" strategy="css selector" />
</page>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
<page name="CustomerAccountCreate" mca="customer/account/create">
<block name="registerForm" class="Magento\Captcha\Test\Block\Form\Register" locator="#form-validate[novalidate='novalidate']" strategy="css selector" />
</page>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
<page name="CustomerAccountLogin">
<page name="CustomerAccountLogin" mca="customer/account/login">
<block name="loginBlockWithCaptcha" class="Magento\Captcha\Test\Block\Form\LoginWithCaptcha" locator="#login-form" strategy="css selector"/>
</page>
</config>
Loading

0 comments on commit 3c34e1d

Please sign in to comment.