Skip to content

Commit 6e8eb6e

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MC-18013
2 parents ed82741 + aed8a0b commit 6e8eb6e

File tree

58 files changed

+1836
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1836
-201
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminClickSaveAndContinueButtonActionGroup">
12+
<annotations>
13+
<description>Click "Save and Continue" button and assert message</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="message" type="string"/>
17+
</arguments>
18+
<scrollToTopOfPage stepKey="scrollToPageTop"/>
19+
<click selector="{{AdminMainActionsSection.saveAndContinue}}" stepKey="clickSaveAndContinue"/>
20+
<waitForElementVisible time="30" selector="{{AdminMessagesSection.success}}" stepKey="waitMessage"/>
21+
<see selector="{{AdminMessagesSection.success}}" userInput="{{message}}" stepKey="verifyMessage"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Braintree/Observer/AddPaypalShortcuts.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,27 @@
1515
class AddPaypalShortcuts implements ObserverInterface
1616
{
1717
/**
18-
* Block class
18+
* Alias for mini-cart block.
1919
*/
20-
const PAYPAL_SHORTCUT_BLOCK = \Magento\Braintree\Block\Paypal\Button::class;
20+
private static $paypalMinicartAlias = 'mini_cart';
21+
22+
/**
23+
* Alias for shopping cart page.
24+
*/
25+
private static $paypalShoppingcartAlias = 'shopping_cart';
26+
27+
/**
28+
* @var string[]
29+
*/
30+
private $buttonBlocks;
31+
32+
/**
33+
* @param string[] $buttonBlocks
34+
*/
35+
public function __construct(array $buttonBlocks = [])
36+
{
37+
$this->buttonBlocks = $buttonBlocks;
38+
}
2139

2240
/**
2341
* Add Braintree PayPal shortcut buttons
@@ -35,7 +53,13 @@ public function execute(Observer $observer)
3553
/** @var ShortcutButtons $shortcutButtons */
3654
$shortcutButtons = $observer->getEvent()->getContainer();
3755

38-
$shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK);
56+
if ($observer->getData('is_shopping_cart')) {
57+
$shortcut = $shortcutButtons->getLayout()
58+
->createBlock($this->buttonBlocks[self::$paypalShoppingcartAlias]);
59+
} else {
60+
$shortcut = $shortcutButtons->getLayout()
61+
->createBlock($this->buttonBlocks[self::$paypalMinicartAlias]);
62+
}
3963

4064
$shortcutButtons->addShortcut($shortcut);
4165
}

app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ class AddPaypalShortcutsTest extends \PHPUnit\Framework\TestCase
2121
{
2222
public function testExecute()
2323
{
24-
$addPaypalShortcuts = new AddPaypalShortcuts();
24+
$addPaypalShortcuts = new AddPaypalShortcuts(
25+
[
26+
'mini_cart' => 'Minicart-block',
27+
'shopping_cart' => 'Shoppingcart-block'
28+
]
29+
);
2530

2631
/** @var Observer|\PHPUnit_Framework_MockObject_MockObject $observerMock */
2732
$observerMock = $this->getMockBuilder(Observer::class)
@@ -60,7 +65,7 @@ public function testExecute()
6065

6166
$layoutMock->expects(self::once())
6267
->method('createBlock')
63-
->with(AddPaypalShortcuts::PAYPAL_SHORTCUT_BLOCK)
68+
->with('Minicart-block')
6469
->willReturn($blockMock);
6570

6671
$shortcutButtonsMock->expects(self::once())

app/code/Magento/Braintree/etc/frontend/di.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,25 @@
5555
<argument name="payment" xsi:type="object">BraintreePayPalFacade</argument>
5656
</arguments>
5757
</type>
58-
58+
59+
<virtualType name="Magento\Braintree\Block\Paypal\ButtonShoppingCartVirtual" type="Magento\Braintree\Block\Paypal\Button">
60+
<arguments>
61+
<argument name="data" xsi:type="array">
62+
<item name="template" xsi:type="string">Magento_Braintree::paypal/button_shopping_cart.phtml</item>
63+
<item name="alias" xsi:type="string">braintree.paypal.mini-cart</item>
64+
<item name="button_id" xsi:type="string">braintree-paypal-mini-cart</item>
65+
</argument>
66+
</arguments>
67+
</virtualType>
68+
<type name="Magento\Braintree\Observer\AddPaypalShortcuts">
69+
<arguments>
70+
<argument name="buttonBlocks" xsi:type="array">
71+
<item name="mini_cart" xsi:type="string">Magento\Braintree\Block\Paypal\Button</item>
72+
<item name="shopping_cart" xsi:type="string">Magento\Braintree\Block\Paypal\ButtonShoppingCartVirtual</item>
73+
</argument>
74+
</arguments>
75+
</type>
76+
5977
<type name="Magento\Braintree\Model\Ui\PayPal\ConfigProvider">
6078
<arguments>
6179
<argument name="resolver" xsi:type="object">Magento\Braintree\Model\LocaleResolver</argument>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/**
8+
* @var \Magento\Braintree\Block\Paypal\Button $block
9+
*/
10+
11+
$id = $block->getContainerId() . random_int(0, PHP_INT_MAX);
12+
13+
$config = [
14+
'Magento_Braintree/js/paypal/button_shopping_cart' => [
15+
'id' => $id,
16+
'clientToken' => $block->getClientToken(),
17+
'displayName' => $block->getMerchantName(),
18+
'actionSuccess' => $block->getActionSuccess(),
19+
'environment' => $block->getEnvironment()
20+
]
21+
];
22+
23+
?>
24+
<div data-mage-init='<?= /* @noEscape */ json_encode($config); ?>'
25+
class="paypal checkout paypal-logo braintree-paypal-logo<?= /* @noEscape */ $block->getContainerId(); ?>-container">
26+
<div data-currency="<?= /* @noEscape */ $block->getCurrency(); ?>"
27+
data-locale="<?= /* @noEscape */ $block->getLocale(); ?>"
28+
data-amount="<?= /* @noEscape */ $block->getAmount(); ?>"
29+
id="<?= /* @noEscape */ $id; ?>"
30+
class="action-braintree-paypal-logo">
31+
</div>
32+
</div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define(
6+
[
7+
'Magento_Braintree/js/paypal/button',
8+
'Magento_Checkout/js/model/quote',
9+
'domReady!'
10+
],
11+
function (
12+
Component,
13+
quote
14+
) {
15+
'use strict';
16+
17+
return Component.extend({
18+
19+
/**
20+
* Overrides amount with a value from quote.
21+
*
22+
* @returns {Object}
23+
* @private
24+
*/
25+
getClientConfig: function (data) {
26+
var config = this._super(data);
27+
28+
if (config.amount !== quote.totals()['base_grand_total']) {
29+
config.amount = quote.totals()['base_grand_total'];
30+
}
31+
32+
return config;
33+
}
34+
});
35+
}
36+
);

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
-->
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11-
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1211
<!--Create a new category-->
1312
<actionGroup name="CreateCategory">
1413
<arguments>
@@ -122,4 +121,29 @@
122121
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveCategory"/>
123122
<seeElement selector="{{AdminMessagesSection.success}}" stepKey="assertSuccess"/>
124123
</actionGroup>
124+
125+
<actionGroup name="DeleteDefaultCategoryChildren">
126+
<annotations>
127+
<description>Deletes all children categories of Default Root Category.</description>
128+
</annotations>
129+
130+
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToAdminCategoryPage"/>
131+
<executeInSelenium function="function ($webdriver) use ($I) {
132+
$children = $webdriver->findElements(\Facebook\WebDriver\WebDriverBy::xpath('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
133+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a'));
134+
while (!empty($children)) {
135+
$I->click('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
136+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a');
137+
$I->waitForPageLoad(30);
138+
$I->click('#delete');
139+
$I->waitForElementVisible('aside.confirm .modal-footer button.action-accept');
140+
$I->click('aside.confirm .modal-footer button.action-accept');
141+
$I->waitForPageLoad(30);
142+
$I->waitForElementVisible('#messages div.message-success', 30);
143+
$I->see('You deleted the category.', '#messages div.message-success');
144+
$children = $webdriver->findElements(\Facebook\WebDriver\WebDriverBy::xpath('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
145+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a'));
146+
}
147+
}" stepKey="deleteAllChildCategories"/>
148+
</actionGroup>
125149
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@
6060

6161
<!--Save product and see success message-->
6262
<actionGroup name="saveProductForm">
63-
<scrollToTopOfPage stepKey="scrollToTop"/>
63+
<annotations>
64+
<description>Clicks on the Save button. Validates that the Success Message is present and correct.</description>
65+
</annotations>
66+
67+
<scrollToTopOfPage stepKey="scrollTopPageProduct"/>
68+
<waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveProductButton"/>
6469
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/>
65-
<see selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
70+
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitProductSaveSuccessMessage"/>
71+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
6672
</actionGroup>
6773

6874
<!--Upload image for product-->

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
<arguments>
2121
<argument name="useForPromoRule" type="string" defaultValue="Yes"/>
2222
</arguments>
23-
<click selector="{{StorefrontPropertiesSection.storefrontPropertiesTab}}" stepKey="clickStoreFrontPropertiesTab"/>
24-
<selectOption selector="{{StorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="{{useForPromoRule}}" stepKey="changeOption"/>
23+
<click selector="{{AdminEditAttributeStorefrontPropertiesSection.storeFrontPropertiesTab}}" stepKey="clickStoreFrontPropertiesTab"/>
24+
<waitForElementVisible selector="{{AdminEditAttributeStorefrontPropertiesSection.useForPromoRuleConditions}}" stepKey="waitForUseForPromoRuleConditionsVisible"/>
25+
<selectOption selector="{{AdminEditAttributeStorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="{{useForPromoRule}}" stepKey="changeOption"/>
2526
<click selector="{{AttributePropertiesSection.save}}" stepKey="saveAttribute"/>
27+
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/>
2628
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the product attribute." stepKey="successMessage"/>
2729
</actionGroup>
2830
<actionGroup name="navigateToProductAttributeByCode">

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
<seeElement selector="{{StorefrontCategoryProductSection.productTitleByName(product.name)}}" stepKey="assertProductName"/>
3535
<see userInput="${{product.price}}.00" selector="{{StorefrontCategoryProductSection.ProductPriceByName(product.name)}}" stepKey="AssertProductPrice"/>
3636
<moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName(product.name)}}" stepKey="moveMouseOverProduct" />
37-
<executeInSelenium function="function($webdriver) use ($I) {
37+
<!-- @TODO: This causes a parsing error after updating the magento-testing-framework to version 2.4.4 -->
38+
<!--<executeInSelenium function="function($webdriver) use ($I) {
3839
$productName = '//main//li[.//a[contains(text(), \'' . {{product.name}} . '\' )]]//div[@data-container=\'product-grid\']';
3940
$I->assertEquals('2', $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath($productName))->getCSSValue('z-index'));
40-
}" stepKey="assertProductContainerIsOpened"/>
41+
}" stepKey="assertProductContainerIsOpened"/>-->
4142
<seeElement selector="{{StorefrontCategoryProductSection.productAddToCartByName(product.name)}}" stepKey="assertAddToCart" />
4243
</actionGroup>
4344

@@ -60,6 +61,7 @@
6061
</arguments>
6162
<!-- Go to storefront category page -->
6263
<amOnPage url="{{StorefrontCategoryPage.url(category)}}?product_list_mode={{mode}}&amp;product_list_order={{sortBy}}&amp;product_list_dir={{sort}}" stepKey="onCategoryPage"/>
64+
<waitForPageLoad time="30" stepKey="waitCategoryPageLoaded"/>
6365
</actionGroup>
6466

6567
<actionGroup name="VerifyCategoryPageParameters">
@@ -69,7 +71,6 @@
6971
<argument name="numOfProductsPerPage" type="string"/>
7072
<argument name="sortBy" type="string" defaultValue="position"/>
7173
</arguments>
72-
<amOnPage url="{{StorefrontCategoryPage.url(categoryName)}}" stepKey="navigateToCategoryPage"/>
7374
<seeInTitle userInput="{{categoryName}}" stepKey="assertCategoryNameInTitle"/>
7475
<see userInput="{{categoryName}}" selector="{{StorefrontCategoryMainSection.categoryTitle}}" stepKey="assertCategoryName"/>
7576
<see userInput="{{mode}}" selector="{{StorefrontCategoryPagerSection.modeGridIsActive}}" stepKey="assertViewMode"/>

0 commit comments

Comments
 (0)