Skip to content

Commit 0dbd073

Browse files
MTO-136: [Test] Captcha on Contact Us form
- Stabilization.
1 parent 99c443c commit 0dbd073

29 files changed

+164
-124
lines changed

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Messages.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ class Messages extends Block
5656
*/
5757
protected $warningMessage = '[data-ui-id$=message-warning]';
5858

59+
/**
60+
* Selector for "This is a required field." validation error message.
61+
*
62+
* @var string
63+
*/
64+
private $validationErrorMessage = '.mage-error';
65+
5966
/**
6067
* Wait for success message.
6168
*
@@ -66,6 +73,16 @@ public function waitSuccessMessage()
6673
return $this->waitForElementVisible($this->successMessage, Locator::SELECTOR_CSS);
6774
}
6875

76+
/**
77+
* Wait for error message.
78+
*
79+
* @return bool
80+
*/
81+
public function waitValidationErrorMessage()
82+
{
83+
return $this->waitForElementVisible($this->validationErrorMessage, Locator::SELECTOR_CSS);
84+
}
85+
6986
/**
7087
* Get all success messages which are present on the page.
7188
*
Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,14 @@
66

77
namespace Magento\Captcha\Test\Block\Form;
88

9-
use Magento\Mtf\Block\Form;
109
use Magento\Mtf\Client\Locator;
11-
use Magento\Mtf\Fixture\FixtureInterface;
12-
use Magento\Mtf\Client\Element\SimpleElement;
10+
use Magento\Contact\Test\Block\Form\ContactUs as ContactForm;
1311

1412
/**
1513
* Form for "Contact Us" page with captcha.
1614
*/
17-
class ContactUsFormWithCaptcha extends Form
15+
class ContactUs extends ContactForm
1816
{
19-
/**
20-
* Submit form button.
21-
*
22-
* @var string
23-
*/
24-
private $submit = '.action.submit';
25-
2617
/**
2718
* Captcha image selector.
2819
*
@@ -66,32 +57,4 @@ public function reloadCaptcha()
6657
{
6758
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
6859
}
69-
70-
/**
71-
* Click submit button.
72-
*
73-
* @return void
74-
*/
75-
public function sendComment()
76-
{
77-
$this->_rootElement->find($this->submit, Locator::SELECTOR_CSS)->click();
78-
}
79-
80-
/**
81-
* Fill the contact us form.
82-
*
83-
* @param FixtureInterface $fixture
84-
* @param SimpleElement|null $element
85-
* @return $this
86-
*/
87-
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
88-
{
89-
$data = $fixture->getData();
90-
$data['firstname'] = $data['customer']['firstname'];
91-
$data['email'] = $data['customer']['email'];
92-
unset($data['customer']);
93-
$this->_fill($this->dataMapping($data), $element);
94-
95-
return $this;
96-
}
9760
}
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
-->
88
<mapping strict="0">
99
<fields>
10-
<firstname>
11-
<selector>input[name*=name]</selector>
12-
</firstname>
13-
<email />
14-
<telephone />
15-
<comment>
16-
<selector>#comment</selector>
17-
</comment>
1810
<captcha>
1911
<selector>[name='captcha[contact_us]']</selector>
2012
</captcha>

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

Lines changed: 0 additions & 1 deletion
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.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace Magento\Captcha\Test\Block\Form;
88

99
use Magento\Mtf\Client\Locator;
10-
use Magento\Customer\Test\Block\Form\Register;
10+
use Magento\Customer\Test\Block\Form\Register as CustomerRegister;
1111

1212
/**
1313
* Form for storefront register customer with captcha.
1414
*/
15-
class RegisterFormWithCaptcha extends Register
15+
class Register extends CustomerRegister
1616
{
1717
/**
1818
* Captcha image selector.
Lines changed: 14 additions & 0 deletions
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>

dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/RegisterFormWithCaptcha.xml

Lines changed: 0 additions & 39 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/Captcha/Test/Constraint/AssertCaptchaFieldOnContactUsForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class AssertCaptchaFieldOnContactUsForm extends AbstractConstraint
2323
public function processAssertRegisterForm(ContactIndex $contactIndex)
2424
{
2525
\PHPUnit_Framework_Assert::assertTrue(
26-
$contactIndex->getFormWithCaptcha()->isVisibleCaptcha(),
26+
$contactIndex->getContactUs()->isVisibleCaptcha(),
2727
'Captcha image is not displayed on the Contact Us page.'
2828
);
2929

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

dev/tests/functional/tests/app/Magento/Captcha/Test/Constraint/AssertCaptchaFieldOnRegisterForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class AssertCaptchaFieldOnRegisterForm extends AbstractConstraint
2323
public function processAssertRegisterForm(CustomerAccountCreate $createAccountPage)
2424
{
2525
\PHPUnit_Framework_Assert::assertTrue(
26-
$createAccountPage->getRegisterFormWithCaptcha()->isVisibleCaptcha(),
26+
$createAccountPage->getRegisterForm()->isVisibleCaptcha(),
2727
'Captcha image is not displayed on the storefront account register page.'
2828
);
2929

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
99
<page name="ContactIndex" mca="contact/index/index" module="Magento_Contact">
10-
<block name="formWithCaptcha" class="Magento\Captcha\Test\Block\Form\ContactUsFormWithCaptcha" locator="#contact-form" strategy="css selector"/>
10+
<block name="contactUs" class="Magento\Captcha\Test\Block\Form\ContactUs" locator="#contact-form" strategy="css selector" />
1111
</page>
1212
</config>

0 commit comments

Comments
 (0)