Skip to content

Commit 63c4d59

Browse files
committed
Merge branch 'B2B-2094' of https://github.com/magento-arcticfoxes/magento2ce into B2B-2102
2 parents 4dd5acf + 5289250 commit 63c4d59

File tree

6 files changed

+198
-65
lines changed

6 files changed

+198
-65
lines changed

app/code/Magento/AwsS3/Test/Mftf/Test/AwsS3StorefrontPrintOrderGuestTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<description value="Print Order from Guest on Frontend"/>
1616
<severity value="BLOCKER"/>
1717
<testCaseId value="MC-38689"/>
18-
<skip>
19-
<issueId value="MQE-2834" />
20-
</skip>
2118
<group value="remote_storage_aws_s3"/>
2219
<group value="pr_exclude"/>
2320
</annotations>

app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<description value="To be sure that other elements of Success page are shown for placed order as registered Customer."/>
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-16488"/>
18-
<skip>
19-
<issueId value="MQE-2834" />
20-
</skip>
2118
<group value="checkout"/>
2219
<group value="pr_exclude"/>
2320
</annotations>
@@ -30,7 +27,7 @@
3027
</before>
3128

3229
<after>
33-
<!--Cancel orders-->
30+
<!-- Cancel orders -->
3431
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
3532
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="goToOrdersPage"/>
3633
<actionGroup ref="AdminGridColumnShowActionGroup" stepKey="showCustomerEmailColumn">
@@ -46,35 +43,35 @@
4643
</actionGroup>
4744
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
4845

49-
<!--Logout from customer account-->
46+
<!-- Logout from customer account -->
5047
<amOnPage url="{{StorefrontCustomerLogoutPage.url}}" stepKey="logoutCustomerOne"/>
5148
<waitForPageLoad stepKey="waitLogoutCustomerOne"/>
5249
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
5350
<deleteData createDataKey="createSimpleUsCustomer" stepKey="deleteCustomer"/>
5451
</after>
5552

56-
<!--Log in to Storefront as Customer-->
53+
<!-- Log in to Storefront as Customer -->
5754
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="signUpNewUser">
5855
<argument name="Customer" value="$$createSimpleUsCustomer$$"/>
5956
</actionGroup>
6057

61-
<!--Go to product page-->
58+
<!-- Go to product page -->
6259
<amOnPage url="$$createSimpleProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage"/>
6360
<waitForPageLoad stepKey="waitForCatalogPageLoad"/>
6461

65-
<!--Add Product to Shopping Cart-->
62+
<!-- Add Product to Shopping Cart -->
6663
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage">
6764
<argument name="productName" value="$$createSimpleProduct.name$$"/>
6865
</actionGroup>
6966

70-
<!--Go to Checkout-->
67+
<!-- Go to Checkout -->
7168
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
7269
<actionGroup ref="StorefrontSelectFirstShippingMethodActionGroup" stepKey="selectFirstShippingMethod"/>
7370
<comment userInput="Adding the comment to replace waitForLoadingMask2 action for preserving Backward Compatibility" stepKey="waitForLoadingMask2"/>
7471
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="clickNext"/>
7572
<!-- Checkout select Check/Money Order payment -->
7673
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
77-
<!--Click Place Order button-->
74+
<!-- Click Place Order button -->
7875
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickPlaceOrder"/>
7976
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeSuccessTitle"/>
8077
<see selector="{{CheckoutSuccessMainSection.orderNumberText}}" userInput="Your order number is: " stepKey="seeOrderNumber"/>
@@ -83,40 +80,40 @@
8380
<click selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="clickOrderLink"/>
8481
<seeInCurrentUrl url="{{StorefrontCustomerOrderPage.url}}" stepKey="seeMyOrderPage"/>
8582

86-
<!--Go to product page-->
83+
<!-- Go to product page -->
8784
<amOnPage url="$$createSimpleProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage2"/>
8885
<waitForPageLoad stepKey="waitForCatalogPageLoad2"/>
8986

90-
<!--Add Product to Shopping Cart-->
87+
<!-- Add Product to Shopping Cart -->
9188
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage2">
9289
<argument name="productName" value="$$createSimpleProduct.name$$"/>
9390
</actionGroup>
9491

95-
<!--Go to Checkout-->
92+
<!-- Go to Checkout -->
9693
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart2"/>
9794
<actionGroup ref="StorefrontSelectFirstShippingMethodActionGroup" stepKey="selectFirstShippingMethod2"/>
9895
<comment userInput="Adding the comment to replace waitForLoadingMask3 action for preserving Backward Compatibility" stepKey="waitForLoadingMask3"/>
9996
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="clickNext2"/>
10097
<!-- Checkout select Check/Money Order payment -->
10198
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment2"/>
10299

103-
<!--Click Place Order button-->
100+
<!-- Click Place Order button -->
104101
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder2"/>
105102
<see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage2"/>
106103
<click selector="{{CheckoutSuccessMainSection.continueShoppingButton}}" stepKey="clickContinueShoppingButton"/>
107104
<see userInput="Home Page" selector="{{StorefrontCMSPageSection.mainTitle}}" stepKey="seeHomePageTitle"/>
108105
<seeCurrentUrlEquals url="{{_ENV.MAGENTO_BASE_URL}}" stepKey="seeHomePageUrl"/>
109106

110-
<!--Go to product page-->
107+
<!-- Go to product page -->
111108
<amOnPage url="$$createSimpleProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage3"/>
112109
<waitForPageLoad stepKey="waitForCatalogPageLoad3"/>
113110

114-
<!--Add Product to Shopping Cart-->
111+
<!-- Add Product to Shopping Cart -->
115112
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage3">
116113
<argument name="productName" value="$$createSimpleProduct.name$$"/>
117114
</actionGroup>
118115

119-
<!--Go to Checkout-->
116+
<!-- Go to Checkout -->
120117
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart3"/>
121118
<actionGroup ref="StorefrontSelectFirstShippingMethodActionGroup" stepKey="selectFirstShippingMethod3"/>
122119
<comment userInput="Adding the comment to replace waitForLoadingMask4 action for preserving Backward Compatibility" stepKey="waitForLoadingMask4"/>
@@ -125,11 +122,11 @@
125122
<!-- Checkout select Check/Money Order payment -->
126123
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment3"/>
127124

128-
<!--Click Place Order button-->
125+
<!-- Click Place Order button -->
129126
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder3"/>
130127
<see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage3"/>
131128

132-
<!--Check "Print Receipt" button is presented (desktop only)-->
129+
<!-- Check "Print Receipt" button is presented (desktop only) -->
133130
<seeElement selector="{{CheckoutSuccessMainSection.printLink}}" stepKey="seeVisiblePrint"/>
134131
<resizeWindow width="600" height="800" stepKey="resizeWindow"/>
135132
<waitForElementNotVisible selector="{{CheckoutSuccessMainSection.printLink}}" stepKey="waitInvisiblePrint"/>
@@ -138,11 +135,16 @@
138135
<waitForElementVisible selector="{{CheckoutSuccessMainSection.printLink}}" stepKey="waitVisiblePrint"/>
139136
<seeElement selector="{{CheckoutSuccessMainSection.printLink}}" stepKey="seeVisiblePrint2"/>
140137

141-
<!--See print page-->
138+
<!-- See print page -->
142139
<click selector="{{CheckoutSuccessMainSection.printLink}}" stepKey="clickPrintLink"/>
143-
<switchToWindow stepKey="switchToWindow"/>
144-
<switchToNextTab stepKey="switchToTab"/>
145-
<seeInCurrentUrl url="sales/order/print/order_id" stepKey="seePrintPage"/>
140+
<helper class="Magento\Sales\Test\Mftf\Helper\SalesHelper" method="switchToWindowWithUrlAndClosePrintDialogIfEncountered" stepKey="switchToWindowWithUrlAndClosePrintDialogIfEncountered">
141+
<argument name="expectedUrl">sales/order/print/order_id/</argument>
142+
<argument name="expectedUrlComparisonType">COMPARISON_PATH_SUBSET_MATCH</argument>
143+
</helper>
144+
145+
<comment userInput="Step key preserved for backwards compatibility" stepKey="switchToWindow"/>
146+
<comment userInput="Step key preserved for backwards compatibility" stepKey="switchToTab"/>
147+
<comment userInput="Step key preserved for backwards compatibility" stepKey="seePrintPage"/>
146148
<seeElement selector="{{StorefrontCustomerOrderViewSection.orderTitle}}" stepKey="seeOrderTitleOnPrint"/>
147149
<switchToWindow stepKey="switchToWindow2"/>
148150
</test>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Test\Mftf\Helper;
9+
10+
use Facebook\WebDriver\Remote\RemoteWebDriver;
11+
use Magento\FunctionalTestingFramework\Helper\Helper;
12+
use Facebook\WebDriver\Exception\NoSuchWindowException;
13+
14+
/**
15+
* Class for MFTF helpers for Sales module.
16+
*/
17+
class SalesHelper extends Helper
18+
{
19+
private const COMPARISON_PATH_EXACT_MATCH = 'COMPARISON_PATH_EXACT_MATCH';
20+
private const COMPARISON_PATH_SUBSET_MATCH = 'COMPARISON_PATH_SUBSET_MATCH';
21+
22+
private const COMPARISON_MATCH_TYPES = [
23+
self::COMPARISON_PATH_EXACT_MATCH,
24+
self::COMPARISON_PATH_SUBSET_MATCH
25+
];
26+
27+
/**
28+
* Iterate through all available window handles and attach webdriver to window matching $expectedUrl.
29+
* If print dialog is found, close it to prevent selenium from hanging and becoming unresponsive.
30+
*
31+
* @param string $expectedUrl
32+
* @param string $expectedUrlComparisonType
33+
* @throws \Codeception\Exception\ModuleException
34+
*/
35+
public function switchToWindowWithUrlAndClosePrintDialogIfEncountered(
36+
string $expectedUrl,
37+
string $expectedUrlComparisonType
38+
) {
39+
if (!in_array($expectedUrlComparisonType, self::COMPARISON_MATCH_TYPES)) {
40+
$this->fail('Expected URL comparison match type is not valid');
41+
}
42+
43+
$magentoWebDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
44+
45+
$webDriver = $magentoWebDriver->webDriver;
46+
47+
// Pressing escape blurs the window and "unfreezes" chromedriver when it switches context back to chrome://print
48+
try {
49+
$magentoWebDriver->pressKey('body', [\Facebook\WebDriver\WebDriverKeys::ESCAPE]);
50+
} catch (NoSuchWindowException $e) {
51+
// This caught exception cannot be explained; no windows are closed as a result of this action; proceed
52+
}
53+
54+
$targetWindowHandle = null;
55+
$availableWindowHandles = $webDriver->getWindowHandles();
56+
57+
foreach ($availableWindowHandles as $availableWindowHandle) {
58+
$webDriver->switchTo()->window($availableWindowHandle);
59+
60+
if ($webDriver->getCurrentURL() === 'chrome://print/') {
61+
try {
62+
// this escape press actually closes the print dialog
63+
// the previous escape press is necessary for this press to close the dialog
64+
$magentoWebDriver->pressKey('body', [\Facebook\WebDriver\WebDriverKeys::ESCAPE]);
65+
} catch (NoSuchWindowException $e) {
66+
// Print dialog successfully closes when requested in selenium,
67+
// yet missing window message is sent back in the response
68+
// when it evaluates the value on the element after the press; proceed
69+
}
70+
71+
// selenium is now effectively detached from any window; attach to an available window handle in case
72+
// "fail" method is called and MFTF "after"/teardown steps need to be executed
73+
$webDriver->switchTo()->window($webDriver->getWindowHandles()[0]);
74+
75+
continue;
76+
}
77+
78+
$isWebDriverOnExpectedUrl = $this->evaluateIsWebDriverOnExpectedUrl(
79+
$webDriver,
80+
$expectedUrl,
81+
$expectedUrlComparisonType
82+
);
83+
84+
if ($isWebDriverOnExpectedUrl) {
85+
$targetWindowHandle = $webDriver->getWindowHandle();
86+
}
87+
}
88+
89+
if (!$targetWindowHandle) {
90+
$this->fail('Could not find window handle with requested expected url');
91+
}
92+
93+
// switch to target window handle
94+
$webDriver->switchTo()->window($targetWindowHandle);
95+
}
96+
97+
/**
98+
* Is $webDriver currently attached to a window that matches $expectedUrl?
99+
*
100+
* @param RemoteWebDriver $webDriver
101+
* @param string $expectedUrl
102+
* @param string $expectedUrlComparisonType
103+
* @return bool
104+
*/
105+
private function evaluateIsWebDriverOnExpectedUrl(
106+
RemoteWebDriver $webDriver,
107+
string $expectedUrl,
108+
string $expectedUrlComparisonType
109+
): bool {
110+
$currentWebDriverUrlPath = parse_url($webDriver->getCurrentURL(), PHP_URL_PATH);
111+
112+
switch ($expectedUrlComparisonType) {
113+
case self::COMPARISON_PATH_EXACT_MATCH:
114+
$isWebDriverOnExpectedUrl = $currentWebDriverUrlPath === $expectedUrl;
115+
break;
116+
case self::COMPARISON_PATH_SUBSET_MATCH:
117+
default:
118+
$isWebDriverOnExpectedUrl = strpos($currentWebDriverUrlPath, $expectedUrl) !== false;
119+
break;
120+
}
121+
122+
return $isWebDriverOnExpectedUrl;
123+
}
124+
}

app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderFindByZipGuestTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<!-- Fill the form with correspondent Order data using search by Zip -->
2525
<actionGroup ref="StorefrontFillOrdersAndReturnsFormTypeZipActionGroup" stepKey="fillOrderZip" before="clickContinue">
26-
<argument name="orderNumber" value="{$getOrderId}"/>
26+
<argument name="orderNumber" value="{$orderNumber}"/>
2727
<argument name="customer" value="$$createCustomer$$"/>
2828
<argument name="address" value="US_Address_TX"/>
2929
</actionGroup>

app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<description value="Print Order from Guest on Frontend"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MC-28494"/>
19-
<skip>
20-
<issueId value="MQE-2834" />
21-
</skip>
2219
<group value="sales"/>
2320
<group value="mtf_migrated"/>
2421
<group value="pr_exclude"/>
@@ -122,7 +119,7 @@
122119
</actionGroup>
123120
<grabTextFrom selector="{{AdminConfigurableProductFormSection.currentAttribute}}" stepKey="grabAttribute"/>
124121
<assertNotEmpty stepKey="assertNotEmpty">
125-
<actualResult type="const">$grabAttribute</actualResult>
122+
<actualResult type="const">$grabAttribute</actualResult>
126123
</assertNotEmpty>
127124

128125
<!-- Create bundle Product -->
@@ -157,7 +154,7 @@
157154
</actionGroup>
158155
<grabTextFrom selector="{{AdminProductFormBundleSection.currentBundleOption}}" stepKey="grabBundleOption"/>
159156
<assertNotEmpty stepKey="assertBundleOptionNotEmpty">
160-
<actualResult type="const">$grabBundleOption</actualResult>
157+
<actualResult type="const">$grabBundleOption</actualResult>
161158
</assertNotEmpty>
162159

163160
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductGridFilters"/>
@@ -270,12 +267,17 @@
270267

271268
<!-- Click on the "Print Order" button -->
272269
<click selector="{{StorefrontGuestOrderViewSection.printOrder}}" stepKey="printOrder"/>
273-
<waitForPageLoad stepKey="waitForPrintWindowToOpen" />
274-
<switchToWindow stepKey="switchToWindow"/>
275-
<waitForElement selector="{{SalesOrderPrintSection.isOrderPrintPage}}" stepKey="waitForPrintTabToOpen"/>
276-
<switchToNextTab stepKey="switchToTab"/>
277-
<waitForPageLoad stepKey="waitForPrintPreviewToLoad"/>
278-
<seeInCurrentUrl url="sales/guest/print/order_id/" stepKey="seePrintPage"/>
270+
<helper class="Magento\Sales\Test\Mftf\Helper\SalesHelper" method="switchToWindowWithUrlAndClosePrintDialogIfEncountered" stepKey="switchToWindowWithUrlAndClosePrintDialogIfEncountered">
271+
<argument name="expectedUrl">sales/guest/print/order_id/</argument>
272+
<argument name="expectedUrlComparisonType">COMPARISON_PATH_SUBSET_MATCH</argument>
273+
</helper>
274+
275+
<comment userInput="Step key preserved for backwards compatibility" stepKey="waitForPrintWindowToOpen" />
276+
<comment userInput="Step key preserved for backwards compatibility" stepKey="switchToWindow"/>
277+
<comment userInput="Step key preserved for backwards compatibility" stepKey="waitForPrintTabToOpen"/>
278+
<comment userInput="Step key preserved for backwards compatibility" stepKey="switchToTab"/>
279+
<comment userInput="Step key preserved for backwards compatibility" stepKey="waitForPrintPreviewToLoad"/>
280+
<comment userInput="Step key preserved for backwards compatibility" stepKey="seePrintPage"/>
279281

280282
<!-- AssertSalesPrintOrderProducts -->
281283
<see userInput="$createBundleProduct.name$" selector="{{StorefrontOrderDetailsSection.productNameCell}}" stepKey="seeBundleProduct"/>

0 commit comments

Comments
 (0)