Skip to content

Commit 0111bac

Browse files
committed
MAGETWO-63215: FedEx Shipment Tracking fails for valid tracking number
- Added functional test
1 parent 2c5b4c5 commit 0111bac

File tree

9 files changed

+321
-0
lines changed

9 files changed

+321
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Fedex\Test\TestCase;
7+
8+
use Magento\Mtf\TestCase\Scenario;
9+
10+
/**
11+
* @group Fedex
12+
* @ZephyrId MAGETWO-58158
13+
*/
14+
class TrackingShipmentForPlacedOrderTest extends Scenario
15+
{
16+
/* tags */
17+
const MVP = 'yes';
18+
const TEST_TYPE = '3rd_party_test';
19+
const SEVERITY = 'S1';
20+
/* end tags */
21+
22+
/**
23+
* Runs one page checkout test.
24+
*
25+
* @return void
26+
*/
27+
public function test()
28+
{
29+
$this->executeScenario();
30+
}
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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/variations.xsd">
9+
<testCase name="Magento\Fedex\Test\TestCase\TrackingShipmentForPlacedOrderTest" summary="Create shipment for order with FedEx shipping method.">
10+
<variation name="TrackingShipmentForPlacedOrderTestVariation1" summary="Creating shipment for order placed within FedEx." ticketId="MAGETWO-58158">
11+
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
12+
<data name="customer/dataset" xsi:type="string">default</data>
13+
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
14+
<data name="checkoutMethod" xsi:type="string">login</data>
15+
<data name="shipping/shipping_service" xsi:type="string">Federal Express</data>
16+
<data name="shipping/shipping_method" xsi:type="string">Ground</data>
17+
<data name="cart/data/shipping_method" xsi:type="string">Ground</data>
18+
<data name="payment/method" xsi:type="string">checkmo</data>
19+
<data name="configData" xsi:type="string">checkmo, fedex, shipping_origin_US_CA</data>
20+
<data name="trackingData" xsi:type="array">
21+
<item name="carrier" xsi:type="string">Federal Express</item>
22+
<item name="carrier_title" xsi:type="string">Federal Express</item>
23+
<item name="tracking_number" xsi:type="string">449044304137821</item>
24+
</data>
25+
<data name="resultTrackingData" xsi:type="array">
26+
<item name="status" xsi:type="string">Shipment information sent to FedEx</item>
27+
<item name="number" xsi:type="string">449044304137821</item>
28+
<item name="service_type" xsi:type="string">FedEx Home Delivery</item>
29+
<item name="events/date" xsi:type="string">Dec 30, 2013</item>
30+
<item name="events/time" xsi:type="string">6:24 PM</item>
31+
</data>
32+
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
33+
<constraint name="Magento\Shipping\Test\Constraint\AssertTrackingDetailsIsPresent" />
34+
</variation>
35+
</testCase>
36+
</config>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
9+
<scenario name="TrackingShipmentForPlacedOrderTest" firstStep="setupConfiguration">
10+
<step name="setupConfiguration" module="Magento_Config" next="createProducts" />
11+
<step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" />
12+
<step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" />
13+
<step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" />
14+
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" />
15+
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" />
16+
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" />
17+
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" />
18+
<step name="selectPaymentMethod" module="Magento_Checkout" next="placeOrder" />
19+
<step name="placeOrder" module="Magento_Checkout" next="createShipment"/>
20+
<step name="createShipment" module="Magento_Sales" next="addTrackingNumber"/>
21+
<step name="addTrackingNumber" module="Magento_Shipping" />
22+
</scenario>
23+
</config>

dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Order/Tracking/Item.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,15 @@
1717
<number>
1818
<selector>[name$='[number]']</selector>
1919
</number>
20+
<carrier>
21+
<selector>[name$='carrier']</selector>
22+
<input>select</input>
23+
</carrier>
24+
<carrier_title>
25+
<selector>[name$='title']</selector>
26+
</carrier_title>
27+
<tracking_number>
28+
<selector>[name$='number']</selector>
29+
</tracking_number>
2030
</fields>
2131
</mapping>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Shipping\Test\Block\Adminhtml\Order;
7+
8+
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Shipping\Test\Block\Adminhtml\Order\Tracking\Item;
11+
12+
/**
13+
* Block for shipment tracking info table.
14+
*/
15+
class TrackingInfoTable extends Block
16+
{
17+
/**
18+
* Selector for tracking number item.
19+
*
20+
* @var string
21+
*/
22+
private $item = './/tfoot/tr[not(contains(@class,"no-display"))]';
23+
24+
/**
25+
* Selector for a button to add new tracking number item.
26+
*
27+
* @var string
28+
*/
29+
private $addButton = '[data-ui-id="shipment-tracking-save-button"]';
30+
31+
/**
32+
* Selector for tracking number popup link.
33+
*
34+
* @var string
35+
*/
36+
private $popup = './/tbody/tr[not(contains(@class,"no-display"))]/td/a[contains(normalize-space(.), "%s")]';
37+
38+
/**
39+
* Creates tracking number.
40+
*
41+
* @param array $data
42+
*/
43+
public function addTrackingNumber(array $data)
44+
{
45+
$trackingItemBlock = $this->getTrackingNumberItem();
46+
$trackingItemBlock->fillRow($data);
47+
48+
$this->_rootElement->find($this->addButton)->click();
49+
}
50+
51+
/**
52+
* Opens a popup with tracking number details.
53+
*
54+
* @param string $trackingNumber
55+
*/
56+
public function openPopup($trackingNumber)
57+
{
58+
$popupLink = $this->_rootElement->find(sprintf($this->popup, $trackingNumber), Locator::SELECTOR_XPATH);
59+
$popupLink->click();
60+
}
61+
62+
/**
63+
* Creates block for tracking number item.
64+
*
65+
* @return Item
66+
*/
67+
private function getTrackingNumberItem()
68+
{
69+
return $this->blockFactory->create(
70+
Item::class,
71+
['element' => $this->_rootElement->find($this->item, Locator::SELECTOR_XPATH)]
72+
);
73+
}
74+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Shipping\Test\Constraint;
7+
8+
use Magento\Mtf\Client\BrowserInterface;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Shipping\Test\Page\Adminhtml\SalesShipmentView;
11+
use Magento\Shipping\Test\Page\Adminhtml\ShipmentIndex;
12+
13+
/**
14+
* Class contains asserts for tracking number popup window.
15+
*/
16+
class AssertTrackingDetailsIsPresent extends AbstractConstraint
17+
{
18+
/**
19+
* Selector for a main container.
20+
*
21+
* @var string
22+
*/
23+
private $mainContainer = '.main';
24+
25+
/**
26+
* Processes the assertions for tracking number data in the popup window.
27+
*
28+
* @param BrowserInterface $browser
29+
* @param ShipmentIndex $shipmentIndex
30+
* @param SalesShipmentView $salesShipmentView
31+
* @param $shipmentIds
32+
* @param $resultTrackingData
33+
*/
34+
public function processAssert(
35+
BrowserInterface $browser,
36+
ShipmentIndex $shipmentIndex,
37+
SalesShipmentView $salesShipmentView,
38+
$shipmentIds,
39+
$resultTrackingData
40+
) {
41+
$shipmentIndex->open();
42+
$shipmentIndex->getShipmentsGrid()
43+
->searchAndOpen(['id' => array_pop($shipmentIds)]);
44+
45+
$mainWindow = $browser->getCurrentWindow();
46+
$trackingInfoTable = $salesShipmentView->getTrackingInfoBlock();
47+
$trackingInfoTable->openPopup($resultTrackingData['number']);
48+
$browser->selectWindow();
49+
50+
$selector = '.close';
51+
$browser->waitUntil(function () use ($browser, $selector) {
52+
$element = $browser->find($selector);
53+
return $element->isVisible() ? true : null;
54+
});
55+
56+
$body = $browser->find($this->mainContainer)->getText();
57+
foreach ($resultTrackingData as $value) {
58+
\PHPUnit_Framework_Assert::assertContains($value, $body);
59+
}
60+
61+
$browser->find($selector)->click();
62+
$browser->selectWindow($mainWindow);
63+
}
64+
65+
/**
66+
* @inheritdoc
67+
*/
68+
public function toString()
69+
{
70+
return 'Shipment tracking data is present in the popup window';
71+
}
72+
}

dev/tests/functional/tests/app/Magento/Shipping/Test/Page/Adminhtml/SalesShipmentView.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<page name="SalesShipmentView" area="Adminhtml" mca="sales/shipment/view" module="Magento_Shipping">
1010
<block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper" strategy="css selector"/>
1111
<block name="itemsBlock" class="Magento\Sales\Test\Block\Adminhtml\Order\Shipment\View\Items" locator="//section[div/table[contains(@class, 'order-shipment-table')]]" strategy="xpath"/>
12+
<block name="trackingInfoBlock" class="Magento\Shipping\Test\Block\Adminhtml\Order\TrackingInfoTable" locator="#shipment_tracking_info" strategy="css selector"/>
1213
</page>
1314
</config>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Shipping\Test\TestStep;
7+
8+
use Magento\Mtf\TestStep\TestStepInterface;
9+
use Magento\Shipping\Test\Page\Adminhtml\SalesShipmentView;
10+
use Magento\Shipping\Test\Page\Adminhtml\ShipmentIndex;
11+
12+
/**
13+
* Step to create shipping tracking number for created order shipment.
14+
*/
15+
class AddTrackingNumberStep implements TestStepInterface
16+
{
17+
/**
18+
* @var ShipmentIndex
19+
*/
20+
private $shipmentIndex;
21+
22+
/**
23+
* @var SalesShipmentView
24+
*/
25+
private $salesShipmentView;
26+
27+
/**
28+
* @var array
29+
*/
30+
private $shipmentIds;
31+
32+
/**
33+
* @var array
34+
*/
35+
private $trackingData;
36+
37+
/**
38+
* @param ShipmentIndex $shipmentIndex
39+
* @param SalesShipmentView $salesShipmentView
40+
* @param array $shipmentIds
41+
* @param array $trackingData
42+
*/
43+
public function __construct(
44+
ShipmentIndex $shipmentIndex,
45+
SalesShipmentView $salesShipmentView,
46+
array $shipmentIds,
47+
array $trackingData
48+
) {
49+
$this->shipmentIndex = $shipmentIndex;
50+
$this->salesShipmentView = $salesShipmentView;
51+
$this->shipmentIds = $shipmentIds;
52+
$this->trackingData = $trackingData;
53+
}
54+
55+
/**
56+
* Creates shipping tracking number.
57+
*
58+
* @return void
59+
*/
60+
public function run()
61+
{
62+
$this->shipmentIndex->open();
63+
$this->shipmentIndex->getShipmentsGrid()
64+
->searchAndOpen(['id' => array_pop($this->shipmentIds)]);
65+
66+
$trackingInfoTable = $this->salesShipmentView->getTrackingInfoBlock();
67+
$trackingInfoTable->addTrackingNumber($this->trackingData);
68+
}
69+
}

dev/tests/functional/tests/app/Magento/Shipping/Test/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
<argument name="severity" xsi:type="string">S1</argument>
1212
</arguments>
1313
</type>
14+
<type name="Magento\Shipping\Test\Constraint\AssertTrackingDetailsIsPresent">
15+
<arguments>
16+
<argument name="severity" xsi:type="string">S1</argument>
17+
</arguments>
18+
</type>
1419
</config>

0 commit comments

Comments
 (0)