Skip to content

Commit

Permalink
Merge pull request #6849 from magento-l3/TANGO_PR-05-11-2021_24
Browse files Browse the repository at this point in the history
TANGO PR 05-11-2021 v24
  • Loading branch information
joanhe authored May 19, 2021
2 parents 5ba21f0 + 17fca68 commit 212d69a
Show file tree
Hide file tree
Showing 15 changed files with 537 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">

<actionGroup name="StorefrontCartPageCheckMapMessagePresentAndClickableActionGroup">
<annotations>
<description>
Assert that the MAP message is present on the product listing in the cart, and What's this? link is clickable and bring up the info popup.
</description>
</annotations>
<!-- Confirm that the MAP message and help link are visible -->
<see selector="{{StorefrontCartMapSection.mapNotice}}" userInput="See price before order confirmation." stepKey="seeMsrpNotice"/>
<see selector="{{StorefrontCartMapSection.mapWhatsThis}}" userInput="What's this?" stepKey="seeMsrpNoticeHelpLink"/>
<!-- Confirm that clicking on the 'What's this?' link shows the help popup -->
<click selector="{{StorefrontCartMapSection.mapWhatsThis}}" stepKey="clickOnWhatsThisLink"/>
<waitForElementVisible selector="{{StorefrontCartMapSection.mapWhatsThisPopup}}" stepKey="waitForTheInfoMessage"/>
<!-- Confirm that clicking on X button closes the popup -->
<click selector="{{StorefrontCartMapSection.mapWhatsThisPopupClose}}" stepKey="clickOnCloseInfoMessage"/>
<waitForElementNotVisible selector="{{StorefrontCartMapSection.mapWhatsThisPopup}}" stepKey="waitForTheInfoMessageToClose"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontCartMapSection">
<element name="mapNotice" type="text" selector=".msrp.notice"/>
<element name="mapWhatsThis" type="text" selector=".msrp .action.help.map"/>
<element name="mapWhatsThisPopup" type="text" selector="//div[@id='map-popup-text-what-this']"/>
<element name="mapWhatsThisPopupClose" type="text" selector=".popup button.action.close"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontVerifyMapMessagePopupOnCartViewPageTest">
<annotations>
<stories value="Shopping Cart"/>
<features value="Checkout"/>
<title value="Minimum Advertised Price 'What's this?' popup does not displays in cart"/>
<description value="When Minimum Advertised Price (MAP) is enabled and the product has MAP set in Advanced Pricing, click on 'What's this?' at the product listing in the shopping cart must display the popup with the info message."/>
<testCaseId value="MC-41596"/>
<useCaseId value="MC-41494"/>
<severity value="MAJOR"/>
<group value="shoppingCart"/>
<group value="checkout"/>
</annotations>
<before>
<!-- Enable MAP functionality in Magento Instance -->
<createData entity="MsrpEnableMAP" stepKey="enableMAP"/>
<!-- Create product and category -->
<createData entity="_defaultCategory" stepKey="category"/>
<createData entity="SimpleProduct" stepKey="product">
<requiredEntity createDataKey="category"/>
</createData>
</before>
<after>
<!-- Disable MAP functionality in Magento Instance -->
<createData entity="MsrpDisableMAP" stepKey="disableMAP"/>
<!-- Delete product and category -->
<deleteData createDataKey="product" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="category" stepKey="deleteCategory"/>
</after>

<!-- Add MAP to the newly created product Advanced Pricing -->
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAdminProductEditPage">
<argument name="productId" value="$$product.id$$"/>
</actionGroup>
<actionGroup ref="AdminAddMinimumAdvertisedPriceActionGroup" stepKey="setMapToCreatedProduct">
<argument name="msrpData" value="MsrpBeforeOrderConfirmation"/>
</actionGroup>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/>

<!--Adding the newly created product to shopping cart.-->
<actionGroup ref="StorefrontNavigateToCategoryUrlActionGroup" stepKey="goToCategoryPageOnFrontEnd">
<argument name="categoryUrl" value="$category.custom_attributes[url_key]$"/>
</actionGroup>
<actionGroup ref="StorefrontAddSimpleProductToCartActionGroup" stepKey="addProductToCart">
<argument name="product" value="$product$"/>
</actionGroup>

<!-- Navigate to the cart edit page -->
<actionGroup ref="clickViewAndEditCartFromMiniCartActionGroup" stepKey="goToCartViewAndEditPage"/>

<!-- Check if MAP message and link are present and functioning -->
<actionGroup ref="StorefrontCartPageCheckMapMessagePresentAndClickableActionGroup" stepKey="checkFormMapFunctioning"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
<a href="#" class="action help map"
id="<?= ($block->escapeHtmlAttr($helpLinkId)) ?>"
data-mage-init='{"addToCart":{
"origin": "info",
"helpLinkId": "#<?= $block->escapeJs($block->escapeHtml($helpLinkId)) ?>",
"productName": "<?= $block->escapeJs($block->escapeHtml($product->getName())) ?>",
"showAddToCart": false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontCheckoutMiniCartSubtotalMatchesAfterRemoveProductFromCartTest">
<annotations>
<features value="Multishipping"/>
<stories value="Multiple Shipping"/>
<title value="Check mini shopping cart Subtotal Price matches with the View Cart subtotal price after remove product from cart"/>
<description value="Verify mini shopping cart Subtotal Price matches with the View Cart subtotal price after remove product from cart"/>
<severity value="MAJOR"/>
<testCaseId value="MC-42067"/>
<useCaseId value="MC-41924"/>
<group value="Multishipment"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createdSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Customer_US_UK_DE" stepKey="createCustomerWithMultipleAddresses"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
<deleteData createDataKey="createdSimpleProduct" stepKey="deleteCreatedSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/>
</after>
<!-- Login to the Storefront as created customer -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
<argument name="Customer" value="$$createCustomerWithMultipleAddresses$$"/>
</actionGroup>
<!-- Open the simple product page -->
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToProductPage">
<argument name="product" value="$$createdSimpleProduct$$"/>
</actionGroup>
<!-- Add to Cart three times of the product -->
<waitForPageLoad stepKey="waitForProductPageLoad"/>
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPageActionGroup" stepKey="addProductToCart">
<argument name="productName" value="$$createdSimpleProduct.name$$"/>
<argument name="productQty" value="3"/>
</actionGroup>
<waitForPageLoad time="120" stepKey="waitForAddToCart"/>
<!-- Go to Cart Summary Section -->
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
<!-- Check Out with Multiple Addresses -->
<actionGroup ref="StorefrontCheckoutWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/>
<!-- Remove first simple product from cart -->
<actionGroup ref="StorefrontRemoveProductOnCheckoutActionGroup" stepKey="removeFirstProductFromCart"/>
<!-- Go back to the cart -->
<click selector="{{MultishippingSection.back}}" stepKey="backToCart"/>
<!-- Check and verify subtotals at mini cart summary section-->
<waitForPageLoad time="120" stepKey="waitForCartSummaryPageToLoad"/>
<grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createdSimpleProduct.name$$)}}" stepKey="grabTextFromProductsSubtotalField"/>
<grabTextFrom selector="{{CheckoutCartSummarySection.subTotal}}" stepKey="grabTextFromCartSubtotalField"/>
<assertEquals message="Subtotals should be equal" stepKey="assertSubtotalsFields">
<expectedResult type="variable">$grabTextFromProductsSubtotalField</expectedResult>
<actualResult type="variable">$grabTextFromCartSubtotalField</actualResult>
</assertEquals>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator;
use Magento\Paypal\Model\Payflow\Transparent;
use Magento\Sales\Api\PaymentFailuresInterface;
use Magento\Framework\Session\Generic as Session;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\HttpPostActionInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="StorefrontCheckoutSelectPaypalPaymentMethodActionGroup">
<annotations>
<description>Select Paypal payment method on onepage checkout</description>
</annotations>
<arguments>
<argument name="paymentMethod" defaultValue="{{StorefrontPaypalCheckoutSection.creditCard}}" type="string"/>
</arguments>
<click selector="{{paymentMethod}}" stepKey="selectPaypalPaymentMethod"/>
<waitForPageLoad stepKey="waitForPaypalFormLoad"/>
<scrollTo selector="{{paymentMethod}}" stepKey="scrollToCreditCardSection"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
use Magento\Framework\Session\Generic as Session;
use Magento\Checkout\Model\Session;
use Magento\Framework\View\Layout\ProcessorInterface;
use Magento\Framework\View\Result\Layout;
use Magento\Framework\View\Result\LayoutFactory;
Expand Down
86 changes: 86 additions & 0 deletions app/code/Magento/Sales/Model/Grid/LastUpdateTimeCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Sales\Model\Grid;

use Magento\Framework\App\CacheInterface;

/**
* Cache for last grid update time.
*/
class LastUpdateTimeCache
{
/**
* Prefix for cache key.
*/
private const CACHE_PREFIX = 'LAST_GRID_UPDATE_TIME';

/**
* @var CacheInterface
*/
private $cache;

/**
* @param CacheInterface $cache
*/
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
}

/**
* Save last grid update time.
*
* @param string $gridTableName
* @param string $lastUpdatedAt
* @return void
*/
public function save(string $gridTableName, string $lastUpdatedAt): void
{
$this->cache->save(
$lastUpdatedAt,
$this->getCacheKey($gridTableName),
[],
3600
);
}

/**
* Get last grid update time.
*
* @param string $gridTableName
* @return string|null
*/
public function get(string $gridTableName): ?string
{
$lastUpdatedAt = $this->cache->load($this->getCacheKey($gridTableName));

return $lastUpdatedAt ?: null;
}

/**
* Remove last grid update time.
*
* @param string $gridTableName
* @return void
*/
public function remove(string $gridTableName): void
{
$this->cache->remove($this->getCacheKey($gridTableName));
}

/**
* Generate cache key.
*
* @param string $gridTableName
* @return string
*/
private function getCacheKey(string $gridTableName): string
{
return self::CACHE_PREFIX . ':' . $gridTableName;
}
}
31 changes: 26 additions & 5 deletions app/code/Magento/Sales/Model/ResourceModel/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Sales\Model\Grid\LastUpdateTimeCache;
use Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;

/**
* Class Grid
* Sales order grid resource model.
*/
class Grid extends AbstractGrid
{
Expand Down Expand Up @@ -45,6 +46,11 @@ class Grid extends AbstractGrid
*/
private $notSyncedDataProvider;

/**
* @var LastUpdateTimeCache
*/
private $lastUpdateTimeCache;

/**
* Order grid rows batch size
*/
Expand All @@ -58,7 +64,8 @@ class Grid extends AbstractGrid
* @param array $joins
* @param array $columns
* @param string $connectionName
* @param NotSyncedDataProviderInterface $notSyncedDataProvider
* @param NotSyncedDataProviderInterface|null $notSyncedDataProvider
* @param LastUpdateTimeCache|null $lastUpdateTimeCache
*/
public function __construct(
Context $context,
Expand All @@ -68,15 +75,19 @@ public function __construct(
array $joins = [],
array $columns = [],
$connectionName = null,
NotSyncedDataProviderInterface $notSyncedDataProvider = null
NotSyncedDataProviderInterface $notSyncedDataProvider = null,
LastUpdateTimeCache $lastUpdateTimeCache = null
) {
$this->mainTableName = $mainTableName;
$this->gridTableName = $gridTableName;
$this->orderIdField = $orderIdField;
$this->joins = $joins;
$this->columns = $columns;
$this->notSyncedDataProvider =
$notSyncedDataProvider ?: ObjectManager::getInstance()->get(NotSyncedDataProviderInterface::class);
$this->notSyncedDataProvider = $notSyncedDataProvider ??
ObjectManager::getInstance()->get(NotSyncedDataProviderInterface::class);
$this->lastUpdateTimeCache = $lastUpdateTimeCache ??
ObjectManager::getInstance()->get(LastUpdateTimeCache::class);

parent::__construct($context, $connectionName);
}

Expand Down Expand Up @@ -118,6 +129,7 @@ public function refresh($value, $field = null)
*/
public function refreshBySchedule()
{
$lastUpdatedAt = null;
$notSyncedIds = $this->notSyncedDataProvider->getIds($this->mainTableName, $this->gridTableName);
foreach (array_chunk($notSyncedIds, self::BATCH_SIZE) as $bunch) {
$select = $this->getGridOriginSelect()->where($this->mainTableName . '.entity_id IN (?)', $bunch);
Expand All @@ -127,6 +139,15 @@ public function refreshBySchedule()
$fetchResult,
array_keys($this->columns)
);

$timestamps = array_column($fetchResult, 'updated_at');
if ($timestamps) {
$lastUpdatedAt = max(max($timestamps), $lastUpdatedAt);
}
}

if ($lastUpdatedAt) {
$this->lastUpdateTimeCache->save($this->gridTableName, $lastUpdatedAt);
}
}

Expand Down
Loading

0 comments on commit 212d69a

Please sign in to comment.