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

Commit 5efaca0

Browse files
committed
MAGETWO-63855: Create functional automated for complete Signifyd flow
- constraints for processing order
1 parent 53ac028 commit 5efaca0

10 files changed

+446
-15
lines changed

Test/Block/Adminhtml/Order/Grid.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Signifyd\Test\Block\Adminhtml\Order;
8+
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
11+
12+
/**
13+
* Backend Data Grid for managing "Sales Order" entities.
14+
*/
15+
class Grid extends DataGrid
16+
{
17+
/**
18+
* Filters array mapping.
19+
*
20+
* @var array
21+
*/
22+
protected $filters = [
23+
'id' => [
24+
'selector' => '[name="increment_id"]',
25+
],
26+
'status' => [
27+
'selector' => '[name="status"]',
28+
'input' => 'select',
29+
],
30+
'signifyd_guarantee_status' => [
31+
'selector' => '[name="signifyd_guarantee_status"]',
32+
'input' => 'select'
33+
]
34+
];
35+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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\Adminhtml\Order\View;
7+
8+
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Information about fraud protection on order page.
13+
*/
14+
class FraudProtection extends Block
15+
{
16+
/**
17+
* Case Status.
18+
*
19+
* @var string
20+
*/
21+
private $caseStatus = 'td.col-case-status';
22+
23+
/**
24+
* Case Guarantee Disposition.
25+
*
26+
* @var string
27+
*/
28+
private $caseGuaranteeDisposition = 'td.col-guarantee-disposition';
29+
30+
/**
31+
* Case Review Disposition.
32+
*
33+
* @var string
34+
*/
35+
private $caseReviewDisposition = 'td.col-case-review';
36+
37+
/**
38+
* Get Case Status information.
39+
*
40+
* @return string
41+
*/
42+
public function getCaseStatus()
43+
{
44+
return $this->_rootElement->find($this->caseStatus, Locator::SELECTOR_CSS)->getText();
45+
}
46+
47+
/**
48+
* Get Case Guarantee Disposition status.
49+
*
50+
* @return string
51+
*/
52+
public function getCaseGuaranteeDisposition()
53+
{
54+
return $this->_rootElement->find($this->caseGuaranteeDisposition, Locator::SELECTOR_CSS)->getText();
55+
}
56+
57+
/**
58+
* Get Case Review Disposition status.
59+
*
60+
* @return string
61+
*/
62+
public function getCaseReviewDisposition()
63+
{
64+
return $this->_rootElement->find($this->caseReviewDisposition, Locator::SELECTOR_CSS)->getText();
65+
}
66+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Signifyd\Test\Constraint;
8+
9+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
10+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
use Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory as SalesAssert;
13+
14+
/**
15+
* Assert that comment about authorized amount exists in Comments History section on order page in Admin.
16+
*/
17+
class AssertAuthorizationInCommentsHistory extends AbstractConstraint
18+
{
19+
/**
20+
* Assert that comment about authorized amount exists in Comments History section on order page in Admin.
21+
*
22+
* @param SalesOrderView $salesOrderView
23+
* @param OrderIndex $salesOrder
24+
* @param string $orderId
25+
* @param array $prices
26+
* @return void
27+
*/
28+
public function processAssert(
29+
SalesOrderView $salesOrderView,
30+
OrderIndex $salesOrder,
31+
$orderId,
32+
array $prices
33+
) {
34+
$salesOrder->open();
35+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
36+
37+
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
38+
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
39+
$orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
40+
$commentsMessages = array_column($orderComments, 'comment');
41+
42+
\PHPUnit_Framework_Assert::assertRegExp(
43+
sprintf(SalesAssert::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']),
44+
implode('. ', $commentsMessages),
45+
'Incorrect authorized amount value for the order #' . $orderId
46+
);
47+
}
48+
49+
/**
50+
* Returns string representation of successful assertion.
51+
*
52+
* @return string
53+
*/
54+
public function toString()
55+
{
56+
return "Message about authorized amount is available in Comments History section.";
57+
}
58+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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\Constraint;
7+
8+
use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
11+
/**
12+
* Assert that Order Case Entity is correct on order page in backend.
13+
*/
14+
class AssertCaseInfoOnBackend extends AbstractConstraint
15+
{
16+
/**
17+
* @var string
18+
*/
19+
private static $caseStatus = 'Open';
20+
21+
/**
22+
* @var string
23+
*/
24+
private static $guaranteeDisposition = 'Approved';
25+
26+
/**
27+
* @var string
28+
*/
29+
private static $reviewDisposition = 'Good';
30+
31+
/**
32+
* Assert that Signifyd Case information is correct on backend.
33+
*
34+
* @param OrderView $orderView
35+
* @param string $orderId
36+
* @return void
37+
*/
38+
public function processAssert(
39+
OrderView $orderView,
40+
$orderId
41+
) {
42+
$orderView->open(['order_id' => $orderId]);
43+
$fraudBlock = $orderView->getFraudProtectionBlock();
44+
45+
\PHPUnit_Framework_Assert::assertEquals(
46+
self::$caseStatus,
47+
$fraudBlock->getCaseStatus(),
48+
'Case status is wrong for order #'.$orderId
49+
);
50+
51+
\PHPUnit_Framework_Assert::assertEquals(
52+
self::$guaranteeDisposition,
53+
$fraudBlock->getCaseGuaranteeDisposition(),
54+
'Case Guarantee Disposition status is wrong for order #'.$orderId
55+
);
56+
57+
\PHPUnit_Framework_Assert::assertEquals(
58+
self::$reviewDisposition,
59+
$fraudBlock->getCaseReviewDisposition(),
60+
'Case Review Disposition status is wrong for order #'.$orderId
61+
);
62+
}
63+
64+
/**
65+
* Returns a string representation of the object.
66+
*
67+
* @return string
68+
*/
69+
public function toString()
70+
{
71+
return 'Signifyd Case information is correct on backend.';
72+
}
73+
}

Test/Constraint/AssertSignifydCaseInCommentsHistory.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,39 @@
1111
use Magento\Mtf\Constraint\AbstractConstraint;
1212

1313
/**
14-
* Assert that comment about authorized amount exists in Comments History section on order page in Admin.
14+
* Assert that comment about created Signifyd Case exists in Comments History section on order page in Admin.
1515
*/
1616
class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
1717
{
1818
/**
19-
* Pattern of message about authorized amount in order.
19+
* Pattern of message about created Signifyd Case in order.
2020
*/
2121
const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./';
2222

2323
/**
24-
* Assert that comment about authorized amount exists in Comments History section on order page in Admin.
24+
* Assert that comment about Signifyd Case exists in Comments History section on order page in Admin.
2525
*
2626
* @param SalesOrderView $salesOrderView
2727
* @param OrderIndex $salesOrder
2828
* @param string $orderId
29-
* @param array $prices
3029
* @return void
3130
*/
3231
public function processAssert(
3332
SalesOrderView $salesOrderView,
3433
OrderIndex $salesOrder,
35-
$orderId,
36-
array $prices
34+
$orderId
3735
) {
3836
$salesOrder->open();
3937
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
4038

4139
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
4240
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
43-
$latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
41+
$orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
42+
$commentsMessages = array_column($orderComments, 'comment');
4443

4544
\PHPUnit_Framework_Assert::assertRegExp(
46-
sprintf(self::CASE_CREATED_PATTERN, $prices['grandTotal']),
47-
$latestComment['comment'],
45+
self::CASE_CREATED_PATTERN,
46+
implode('. ', $commentsMessages),
4847
'Signifyd case is not created for the order #' . $orderId
4948
);
5049
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Signifyd\Test\Constraint;
8+
9+
use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert that Signifyd Guarantee Status is present in Orders grid.
14+
*/
15+
class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
16+
{
17+
/**
18+
* Assert that order with fixture data is present in Sales -> Orders Grid.
19+
*
20+
* @param string $orderId
21+
* @param string $status
22+
* @param OrderView $orderView
23+
* @return void
24+
*/
25+
public function processAssert(
26+
$orderId,
27+
$status,
28+
OrderView $orderView
29+
) {
30+
$filter = [
31+
'id' => $orderId,
32+
'status' => $status,
33+
'signifyd_guarantee_status' => 'Approved'
34+
];
35+
36+
$errorMessage = implode(', ', $filter);
37+
38+
$orderView->open();
39+
40+
\PHPUnit_Framework_Assert::assertTrue(
41+
$orderView->getSalesOrderGrid()->isRowVisible(array_filter($filter)),
42+
'Order with following data \'' . $errorMessage . '\' is absent in Orders grid.'
43+
);
44+
}
45+
46+
/**
47+
* Returns a string representation of the object.
48+
*
49+
* @return string
50+
*/
51+
public function toString()
52+
{
53+
return 'Signifyd case is present in sales orders grid.';
54+
}
55+
}

Test/Page/Adminhtml/OrderView.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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="OrderView" area="Adminhtml" mca="sales/order/view" module="Magento_Signifyd">
10+
<block name="fraudProtectionBlock" class="Magento\Signifyd\Test\Block\Adminhtml\Order\View\FraudProtection" locator=".admin__page-section.order-case-info" strategy="css selector" />
11+
<block name="salesOrderGrid" class="Magento\Signifyd\Test\Block\Adminhtml\Order\Grid" locator="//div[contains(@data-bind, 'sales_order_grid')]" strategy="xpath"/>
12+
</page>
13+
</config>

Test/TestCase/OnePageCheckoutWithBraintreeTest.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@
2929
<data name="sandboxMerchant/dataset" xsi:type="string">sandbox_default</data>
3030
<data name="status" xsi:type="string">Processing</data>
3131
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
32-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
3332
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
3433
<constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory" />
35-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelSuccessMessage" />
34+
<constraint name="Magento\Signifyd\Test\Constraint\AssertAuthorizationInCommentsHistory" />
3635
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCanceled" />
37-
<constraint name="Magento\Sales\Test\Constraint\AssertCancelInCommentsHistory" />
38-
<constraint name="Magento\Signifyd\Test\Constraint\AssertGuaranteeCancelInCommentsHistory" />
3936
</variation>
4037
</testCase>
4138
</config>

0 commit comments

Comments
 (0)