Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit a337032

Browse files
Dmytro Yushkiniivashchenko
authored andcommitted
MAGETWO-63855: Create functional automated for complete Signifyd flow
1 parent 5efaca0 commit a337032

17 files changed

+625
-148
lines changed

Test/Block/Sanbox/CaseInfo.php renamed to Test/Block/Sandbox/CaseInfo.php

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,85 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Signifyd\Test\Block\Sanbox;
6+
namespace Magento\Signifyd\Test\Block\Sandbox;
77

88
use Magento\Mtf\Block\Block;
99
use Magento\Mtf\Client\Locator;
1010

11+
/**
12+
* Block with case information.
13+
*/
1114
class CaseInfo extends Block
1215
{
13-
private $flagGoodButton = 'button.flag-case-good';
16+
/**
17+
* @var string
18+
*/
19+
private $flagGoodButton = '.flag-case-good';
20+
21+
/**
22+
* @var string
23+
*/
24+
private $guaranteeDisposition = '.guarantee-status';
25+
26+
/**
27+
* @var string
28+
*/
1429
private $cvvResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseDescription")]';
30+
31+
/**
32+
* @var string
33+
*/
1534
private $cvvResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseCode")]';
35+
36+
/**
37+
* @var string
38+
*/
1639
private $avsResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseDescription")]';
40+
41+
/**
42+
* @var string
43+
*/
1744
private $avsResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseCode")]';
45+
46+
/**
47+
* @var string
48+
*/
1849
private $orderId = '//span[contains(@ng-bind, "currentCase.caseIdDisplay")]';
50+
51+
/**
52+
* @var string
53+
*/
1954
private $orderAmount = '//span[contains(@ng-bind, "currentCase.orderAmount")]';
55+
56+
/**
57+
* @var string
58+
*/
2059
private $cardHolder = '//a[contains(@data-dropdown, "peopleLinks0")]//span';
60+
61+
/**
62+
* @var string
63+
*/
2164
private $billingAddress = '//a[contains(@data-dropdown, "streetLinks0")]';
2265

66+
/**
67+
* @return void
68+
*/
2369
public function flagCaseGood()
2470
{
2571
$this->_rootElement->find($this->flagGoodButton)->click();
2672
}
2773

74+
/**
75+
* @return array|string
76+
*/
77+
public function getGuaranteeDisposition()
78+
{
79+
return $this->_rootElement->find($this->guaranteeDisposition)->getText();
80+
}
81+
82+
/**
83+
* @return string
84+
*/
2885
public function getCvvResponse()
2986
{
3087
return sprintf(
@@ -34,6 +91,9 @@ public function getCvvResponse()
3491
);
3592
}
3693

94+
/**
95+
* @return string
96+
*/
3797
public function getAvsResponse()
3898
{
3999
return sprintf(
@@ -43,21 +103,33 @@ public function getAvsResponse()
43103
);
44104
}
45105

106+
/**
107+
* @return array|string
108+
*/
46109
public function getOrderId()
47110
{
48111
return $this->_rootElement->find($this->orderId, Locator::SELECTOR_XPATH)->getText();
49112
}
50113

114+
/**
115+
* @return array|string
116+
*/
51117
public function getOrderAmount()
52118
{
53119
return $this->_rootElement->find($this->orderAmount, Locator::SELECTOR_XPATH)->getText();
54120
}
55121

122+
/**
123+
* @return array|string
124+
*/
56125
public function getCardHolder()
57126
{
58127
return $this->_rootElement->find($this->cardHolder, Locator::SELECTOR_XPATH)->getText();
59128
}
60129

130+
/**
131+
* @return array|string
132+
*/
61133
public function getBillingAddress()
62134
{
63135
return $this->_rootElement->find($this->billingAddress, Locator::SELECTOR_XPATH)->getText();

Test/Block/Sanbox/CaseSearch.php renamed to Test/Block/Sandbox/CaseSearch.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,51 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Signifyd\Test\Block\Sanbox;
6+
namespace Magento\Signifyd\Test\Block\Sandbox;
77

88
use Magento\Mtf\Block\Form;
99
use Magento\Mtf\Client\Locator;
1010

11+
/**
12+
* Side block with case search and cases list.
13+
*/
1114
class CaseSearch extends Form
1215
{
1316
/**
14-
* Submit button for Signifyd case search.
15-
*
1617
* @var string
1718
*/
1819
private $searchInput = '#queueSearchBar';
20+
21+
/**
22+
* @var string
23+
*/
1924
private $buttonSubmit = '[type=submit]';
25+
26+
/**
27+
* @var string
28+
*/
2029
private $buttonCase = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
2130

31+
/**
32+
* @param $searchCriteria
33+
*/
2234
public function fillSearchCriteria($searchCriteria)
2335
{
2436
$this->waitForElementVisible($this->searchInput);
2537
$this->_rootElement->find($this->searchInput)->setValue($searchCriteria);
2638
}
2739

2840
/**
29-
* Search Signifyd case.
30-
*
3141
* @return void
3242
*/
3343
public function searchCase()
3444
{
3545
$this->_rootElement->find($this->buttonSubmit)->click();
3646
}
3747

48+
/**
49+
* @return void
50+
*/
3851
public function selectCase()
3952
{
4053
$this->_rootElement->find($this->buttonCase, Locator::SELECTOR_XPATH)->click();

Test/Block/Sanbox/Login.php renamed to Test/Block/Sandbox/SignifydLogin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Signifyd\Test\Block\Sanbox;
6+
namespace Magento\Signifyd\Test\Block\Sandbox;
77

88
use Magento\Mtf\Block\Form;
99

10-
class Login extends Form
10+
/**
11+
* Signifyd login block.
12+
*/
13+
class SignifydLogin extends Form
1114
{
1215
/**
1316
* Login button on Signifyd side.
1417
*
1518
* @var string
1619
*/
17-
protected $loginButton = '[type=submit]';
20+
private $loginButton = '[type=submit]';
1821

1922
/**
2023
* Login to Signifyd Sandbox.

Test/Block/Sandbox/WebhookAdd.php

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Signifyd\Test\Block\Sandbox;
7+
8+
use Magento\Mtf\Block\Form;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Signifyd webhook addition block.
13+
*/
14+
class WebhookAdd extends Form
15+
{
16+
/**
17+
* @var string
18+
*/
19+
private $webhookUrl = '#webhookUrl';
20+
21+
/**
22+
* @var string
23+
*/
24+
private $webhookTestTeamOption = './/select[@id="webhookTeams"]//option[text()="test"]';
25+
26+
/**
27+
* @var string
28+
*/
29+
private $webhookEventOption = './/select[@id="webhookEvent"]//option[@value="%s"]';
30+
31+
/**
32+
* @var string
33+
*/
34+
private $webhookAddedElement = '//tr[./td/span/text()="%s" and ./td/span/text()="%s"]';
35+
36+
/**
37+
* Add webhook button.
38+
*
39+
* @var string
40+
*/
41+
private $webhookAddButton = '[type=submit]';
42+
43+
/**
44+
* List of option values of webhook event select.
45+
*
46+
* @var array
47+
*/
48+
private $webhookEventOptionsList = [
49+
'CASE_CREATION' => 'Case Creation',
50+
'CASE_RESCORE' => 'Case Rescore',
51+
'CASE_REVIEW' => 'Case Review',
52+
'GUARANTEE_COMPLETION' => 'Guarantee Completion',
53+
'CLAIM_REVIEWED' => 'Claim Review'
54+
];
55+
56+
public function createWebhooks()
57+
{
58+
foreach ($this->webhookEventOptionsList as $webhookEventCode => $webhookEventName) {
59+
$this->setEvent($webhookEventCode);
60+
$this->setTeam();
61+
$this->setWebhookUrl();
62+
$this->addWebhook($webhookEventName);
63+
}
64+
}
65+
66+
/**
67+
* @param $webhookEventCode
68+
* @return void
69+
*/
70+
private function setEvent($webhookEventCode)
71+
{
72+
$this->_rootElement->find(sprintf($this->webhookEventOption, $webhookEventCode), Locator::SELECTOR_XPATH)
73+
->click();
74+
}
75+
76+
/**
77+
* @return void
78+
*/
79+
private function setTeam()
80+
{
81+
$this->_rootElement->find($this->webhookTestTeamOption, Locator::SELECTOR_XPATH)->click();
82+
}
83+
84+
/**
85+
* @return void
86+
*/
87+
private function setWebhookUrl()
88+
{
89+
$this->_rootElement->find($this->webhookUrl)->setValue($this->getWebhookUrl());
90+
}
91+
92+
/**
93+
* @param $webhookEventName
94+
* @return void
95+
*/
96+
private function addWebhook($webhookEventName)
97+
{
98+
$this->_rootElement->find($this->webhookAddButton)->click();
99+
100+
// We need to wait until webhook will be added to grid
101+
// before proceed to next step
102+
$this->_rootElement->waitUntil(
103+
function () use ($webhookEventName) {
104+
return $this->_rootElement->find(
105+
sprintf($this->webhookAddedElement, $this->getWebhookUrl(), $webhookEventName),
106+
Locator::SELECTOR_XPATH
107+
)->isVisible() ? true : null;
108+
}
109+
);
110+
}
111+
112+
/**
113+
* @return string
114+
*/
115+
private function getWebhookUrl()
116+
{
117+
return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler';
118+
}
119+
}

0 commit comments

Comments
 (0)