Skip to content

Commit 4d40985

Browse files
MTO-136: [Test] Captcha on Contact Us form
- Defects fixed
1 parent 7b5bb1f commit 4d40985

File tree

9 files changed

+51
-36
lines changed

9 files changed

+51
-36
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
use Magento\Mtf\Block\Form;
1010
use Magento\Mtf\Client\Locator;
11-
use Magento\Mtf\Client\ElementInterface;
12-
use Magento\Mtf\Fixture\FixtureInterface;
1311

1412
/**
1513
* Form for "Contact Us" page with captcha.
@@ -68,14 +66,12 @@ public function reloadCaptcha()
6866
}
6967

7068
/**
71-
* Send comment.
69+
* Click submit button.
7270
*
73-
* @param FixtureInterface $fixture
7471
* @return void
7572
*/
76-
public function sendComment(FixtureInterface $fixture)
73+
public function sendComment()
7774
{
78-
$this->fill($fixture);
7975
$this->_rootElement->find($this->submit, Locator::SELECTOR_CSS)->click();
8076
}
8177
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Magento\Captcha\Test\Constraint;
88

9-
use Magento\Captcha\Test\Page\ContactUs;
9+
use Magento\Contact\Test\Page\ContactIndex;
1010
use Magento\Mtf\Constraint\AbstractConstraint;
1111

1212
/**
@@ -17,18 +17,18 @@ class AssertCaptchaFieldOnContactUsForm extends AbstractConstraint
1717
/**
1818
* Assert captcha on the Contact Us page.
1919
*
20-
* @param ContactUs $contactUsPage
20+
* @param ContactIndex $contactIndex
2121
* @return void
2222
*/
23-
public function processAssertRegisterForm(ContactUs $contactUsPage)
23+
public function processAssertRegisterForm(ContactIndex $contactIndex)
2424
{
2525
\PHPUnit_Framework_Assert::assertTrue(
26-
$contactUsPage->getFormWithCaptcha()->isVisibleCaptcha(),
26+
$contactIndex->getFormWithCaptcha()->isVisibleCaptcha(),
2727
'Captcha image is not displayed on the Contact Us page.'
2828
);
2929

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

dev/tests/functional/tests/app/Magento/Captcha/Test/Fixture/Customer.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
99
<fixture name="customer">
1010
<field name="captcha" is_required="0" />
11-
<field name="comment" is_required="0" />
1211
</fixture>
1312
</config>

dev/tests/functional/tests/app/Magento/Captcha/Test/Page/ContactUs.xml renamed to 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
@@ -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="ContactUs" mca="contact/index/index" module="Magento_Captcha">
9+
<page name="ContactIndex" mca="contact/index/index" module="Magento_Contact">
1010
<block name="formWithCaptcha" class="Magento\Captcha\Test\Block\Form\ContactUsFormWithCaptcha" locator="#contact-form" strategy="css selector"/>
1111
</page>
1212
</config>

dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaOnContactUsTest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
use Magento\Mtf\TestStep\TestStepFactory;
1111
use Magento\Captcha\Test\Constraint\AssertCaptchaFieldOnContactUsForm;
1212
use Magento\Customer\Test\Fixture\Customer;
13-
use Magento\Captcha\Test\Page\ContactUs;
13+
use Magento\Contact\Test\Page\ContactIndex;
1414

1515
/**
1616
* Preconditions:
17-
* 1. Enable CAPTCHA for customer.
17+
* 1. Enable captcha for customer.
1818
*
1919
* Test Flow:
2020
* 1. Open contact us page.
@@ -33,18 +33,18 @@ class CaptchaOnContactUsTest extends Injectable
3333
private $stepFactory;
3434

3535
/**
36-
* Assert Captcha.
36+
* Assert captcha on "Contact Us" page.
3737
*
3838
* @var AssertCaptchaFieldOnContactUsForm
3939
*/
4040
private $assertCaptcha;
4141

4242
/**
43-
* ContactUs page.
43+
* ContactIndex page.
4444
*
45-
* @var ContactUs
45+
* @var ContactIndex
4646
*/
47-
private $contactUs;
47+
private $contactIndex;
4848

4949
/**
5050
* Configuration setting.
@@ -58,17 +58,17 @@ class CaptchaOnContactUsTest extends Injectable
5858
*
5959
* @param TestStepFactory $stepFactory
6060
* @param AssertCaptchaFieldOnContactUsForm $assertCaptcha
61-
* @param ContactUs $contactUs
61+
* @param ContactIndex $contactIndex
6262
* @return void
6363
*/
6464
public function __inject(
6565
TestStepFactory $stepFactory,
6666
AssertCaptchaFieldOnContactUsForm $assertCaptcha,
67-
ContactUs $contactUs
67+
ContactIndex $contactIndex
6868
) {
6969
$this->stepFactory = $stepFactory;
7070
$this->assertCaptcha = $assertCaptcha;
71-
$this->contactUs = $contactUs;
71+
$this->contactIndex = $contactIndex;
7272
}
7373

7474
/**
@@ -90,10 +90,11 @@ public function test(
9090
['configData' => $this->configData]
9191
)->run();
9292

93-
$this->contactUs->open();
94-
$this->assertCaptcha->processAssertRegisterForm($this->contactUs);
95-
$this->contactUs->getFormWithCaptcha()->reloadCaptcha();
96-
$this->contactUs->getFormWithCaptcha()->sendComment($customer);
93+
$this->contactIndex->open();
94+
$this->assertCaptcha->processAssertRegisterForm($this->contactIndex);
95+
$this->contactIndex->getFormWithCaptcha()->fill($customer);
96+
$this->contactIndex->getFormWithCaptcha()->reloadCaptcha();
97+
$this->contactIndex->getFormWithCaptcha()->sendComment();
9798
}
9899

99100
/**

dev/tests/functional/tests/app/Magento/Contact/Test/Block/Form/Messages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

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

9-
use Magento\Mtf\Block\Form;
9+
use Magento\Mtf\Block\Block;
1010

1111
/**
1212
* Message block on "Contact Us" page.
1313
*/
14-
class Messages extends Form
14+
class Messages extends Block
1515
{
1616
/**
1717
* Message selector.

dev/tests/functional/tests/app/Magento/Contact/Test/Constraint/AssertContactUsSuccessMessage.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,34 @@
77
namespace Magento\Contact\Test\Constraint;
88

99
use Magento\Mtf\Constraint\AbstractConstraint;
10-
use Magento\Captcha\Test\Page\ContactUs;
10+
use Magento\Contact\Test\Page\ContactIndex;
1111

1212
/**
1313
* Assert that success message is present on "Contact Us" page.
1414
*/
1515
class AssertContactUsSuccessMessage extends AbstractConstraint
1616
{
17-
const SUCCESS_MESSAGE =
18-
"Thanks for contacting us with your comments and questions. We'll respond to you very soon.";
17+
/**
18+
* Success sent comment message(the first part).
19+
*/
20+
const SUCCESS_MESSAGE_PART_1 = "Thanks for contacting us with your comments and questions. ";
21+
22+
/**
23+
* Success sent comment message(the second part).
24+
*/
25+
const SUCCESS_MESSAGE_PART_2 = "We'll respond to you very soon.";
1926

2027
/**
2128
* Assert that success message is present on "Contact Us" page.
2229
*
23-
* @param ContactUs $contactUsPage
30+
* @param ContactIndex $contactIndex
2431
* @return void
2532
*/
26-
public function processAssert(ContactUs $contactUsPage)
33+
public function processAssert(ContactIndex $contactIndex)
2734
{
2835
\PHPUnit_Framework_Assert::assertEquals(
29-
self::SUCCESS_MESSAGE,
30-
$contactUsPage->getMessagesBlock()->getMessage(),
36+
self::SUCCESS_MESSAGE_PART_1 . self::SUCCESS_MESSAGE_PART_2,
37+
$contactIndex->getMessagesBlock()->getMessage(),
3138
'Wrong message is displayed.'
3239
);
3340
}
Lines changed: 12 additions & 0 deletions
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="customer">
10+
<field name="comment" is_required="0" />
11+
</fixture>
12+
</config>

dev/tests/functional/tests/app/Magento/Contact/Test/Page/ContactUs.xml renamed to dev/tests/functional/tests/app/Magento/Contact/Test/Page/ContactIndex.xml

Lines changed: 1 addition & 1 deletion
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="ContactUs" mca="contact/index/index" module="Magento_Contact">
9+
<page name="ContactIndex" mca="contact/index/index" module="Magento_Contact">
1010
<block name="messagesBlock" class="Magento\Contact\Test\Block\Form\Messages" locator=".messages" strategy="css selector"/>
1111
</page>
1212
</config>

0 commit comments

Comments
 (0)