Skip to content

Commit 3798dfa

Browse files
committed
MAGETWO-60958: [Backport] Incorrect province code sent on Checkout to UPS #6564 - for 2.1
- MAGETWO-70727: [GitHub] Shipping method randomly dissapear when page refreshed for 2.1 #7497
1 parent e97a673 commit 3798dfa

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\Constraint;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Checkout\Test\TestStep\FillShippingAddressStep;
11+
use Magento\Mtf\Client\BrowserInterface;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\Mtf\Fixture\FixtureFactory;
14+
use Magento\Mtf\TestStep\TestStepFactory;
15+
16+
/**
17+
* Asserts that shipping methods are present on checkout page.
18+
*/
19+
class AssertShippingMethodsSuccessEstimate extends AbstractConstraint
20+
{
21+
/**
22+
* Asserts that shipping methods are present on checkout page.
23+
*
24+
* @param CheckoutOnepage $checkoutOnepage
25+
* @param BrowserInterface $browser
26+
* @return void
27+
*/
28+
public function processAssert(
29+
CheckoutOnepage $checkoutOnepage,
30+
BrowserInterface $browser
31+
) {
32+
if ($this->shouldOpenCheckout($checkoutOnepage, $browser)) {
33+
$checkoutOnepage->open();
34+
}
35+
36+
\PHPUnit_Framework_Assert::assertFalse(
37+
$checkoutOnepage->getShippingMethodBlock()->isErrorPresent(),
38+
'Shipping estimation error is present.'
39+
);
40+
41+
$methods = $checkoutOnepage->getShippingMethodBlock()->getAvailableMethods();
42+
\PHPUnit_Framework_Assert::assertNotEmpty(
43+
$methods,
44+
'No shipping methods are present.'
45+
);
46+
}
47+
48+
/**
49+
* Should open checkout page or not.
50+
*
51+
* @param CheckoutOnepage $checkoutOnepage
52+
* @param BrowserInterface $browser
53+
* @return bool
54+
*/
55+
private function shouldOpenCheckout(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser)
56+
{
57+
$result = true;
58+
59+
foreach (['checkout/', $checkoutOnepage::MCA] as $path) {
60+
$length = strlen($path);
61+
if (substr($browser->getUrl(), -$length) === $path) {
62+
$result = false;
63+
break;
64+
}
65+
}
66+
67+
return $result;
68+
}
69+
70+
/**
71+
* Returns a string representation of the object.
72+
*
73+
* @return string
74+
*/
75+
public function toString()
76+
{
77+
return "Shipping methods are present on checkout page.";
78+
}
79+
}

dev/tests/functional/tests/app/Magento/Checkout/Test/etc/testcase.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
<step name="setupConfiguration" module="Magento_Config" next="createProducts" />
3333
<step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" />
3434
<step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" />
35-
<step name="proceedToCheckout" module="Magento_Checkout" next="fillShippingAddress" />
35+
<step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" />
36+
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/>
37+
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/>
3638
<step name="fillShippingAddress" module="Magento_Checkout" next="resolveShippingMethods" />
3739
<step name="resolveShippingMethods" module="Magento_Checkout" />
3840
</scenario>

dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageEstimateShippingMethodsTest.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
99
<testCase name="Magento\Checkout\Test\TestCase\OnePageEstimateShippingMethodsTest" summary="Estimate shipping methods at checkout" ticketId="MAGETWO-71002">
10-
<variation name="OnePageEstimateShippingMethodsTestUpsVariation" ticketId="MAGETWO-71003">
10+
<variation name="OnePageEstimateShippingMethodsTestUpsVariation1" ticketId="MAGETWO-71003">
1111
<data name="products" xsi:type="string">catalogProductSimple::default</data>
1212
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
1313
<data name="editAddressData" xsi:type="array">
1414
<item name="city" xsi:type="string">Birmingham</item>
1515
<item name="region_id" xsi:type="string">Alabama</item>
1616
<item name="postcode" xsi:type="string">35201</item>
1717
</data>
18+
<data name="checkoutMethod" xsi:type="string">guest</data>
1819
<data name="configData" xsi:type="string">ups, shipping_origin_US_CA</data>
1920
<constraint name="Magento\Checkout\Test\Constraint\AssertShippingMethodsSuccessEstimateAfterAddressEdit" />
2021
</variation>
22+
<variation name="OnePageEstimateShippingMethodsTestUpsVariation2" ticketId="MAGETWO-71044">
23+
<data name="products" xsi:type="string">catalogProductSimple::default</data>
24+
<data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data>
25+
<data name="checkoutMethod" xsi:type="string">login</data>
26+
<data name="configData" xsi:type="string">ups, shipping_origin_US_CA</data>
27+
<constraint name="Magento\Checkout\Test\Constraint\AssertShippingMethodsSuccessEstimate" />
28+
</variation>
2129
</testCase>
2230
</config>

0 commit comments

Comments
 (0)