Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #29799: Add elasticsearch params to integration tests config (by @ihor-sviziev)
 - #29634: [MFTF] Added some ActionGroups to Analytics module (by @Usik2203)
 - #29348: [MFTF] Test scenario for "Apply shopping cart rule to a single bundle item" (#28921) (by @zhartaunik)
 - #28413: Fix Downloadable product after refund (by @ProkopovVitaliy)
 - #27609: Test coverage for PR #27357 (E-mail templates) (by @lbajsarowicz)
 - #27579: Fix #27523: throw informative errors in setup:db:generate-patch (by @korostii)


Fixed GitHub Issues:
 - #29648: [Issue] [MFTF] Added some ActionGroups to Analytics module (reported by @m2-assistant[bot]) has been fixed in #29634 by @Usik2203 in 2.4-develop branch
   Related commits:
     1. f54fd86
     2. 1492668
     3. 59d5d32
     4. 8c2291f
     5. e25fc55

 - #28921: Apply shopping cart rule to a single bundle item (reported by @MilanFrajt) has been fixed in #29348 by @zhartaunik in 2.4-develop branch
   Related commits:
     1. e6aca3b
     2. 7abc82f

 - #28388: Downloadable product is available in My Download Products tab after it has been partially refunded  (reported by @YaninaPrudnikova) has been fixed in #28413 by @ProkopovVitaliy in 2.4-develop branch
   Related commits:
     1. a6f460d
     2. 9a83830
     3. 96c9d54
     4. 59cf9f7
     5. c6c3231
     6. eafdb17
     7. 92fd06b
     8. 1f7eace
     9. db84d3a
     10. d0a0962
     11. aea9276
     12. 1be2cd7
     13. dee9b16
     14. a49709f
     15. 8023f42
     16. 9e31246
     17. d91b305
     18. 62e4866
     19. 97df424
     20. 2d58988
     21. 87d8984

 - #27523: CLI Patch Generator: Lack of information what path cannot be created (reported by @lbajsarowicz) has been fixed in #27579 by @korostii in 2.4-develop branch
   Related commits:
     1. 1e8e825
     2. 1dd5290
     3. c1d8fef
     4. a74f8fe
     5. f48cd50
     6. 2bc691a
     7. 8991733
     8. 347602f
     9. 75bb2c3
     10. 7d316d4
  • Loading branch information
magento-engcom-team committed Sep 2, 2020
2 parents edc018c + bcfe08f commit b87f1df
Show file tree
Hide file tree
Showing 21 changed files with 701 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminOpenConfigGeneralAnalyticsPageActionGroup">
<annotations>
<description>Open Config General Analytics Page.</description>
</annotations>

<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<waitForPageLoad stepKey="waitPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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="AssertAdminAdvancedReportingPageUrlActionGroup">
<annotations>
<description>Assert admin advanced reporting page url.</description>
</annotations>

<switchToNextTab stepKey="switchToNewTab"/>
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<amOnPage url="{{AdminDashboardPage.url}}" stepKey="amOnDashboardPage"/>
<waitForPageLoad stepKey="waitForDashboardPageLoad"/>
<click selector="{{AdminAdvancedReportingSection.goToAdvancedReporting}}" stepKey="clickGoToAdvancedReporting"/>
<switchToNextTab stepKey="switchToNewTab"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
<actionGroup ref="AssertAdminAdvancedReportingPageUrlActionGroup" stepKey="assertAdvancedReportingPageUrl"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<argument name="menuUiId" value="{{AdminMenuReports.dataUiId}}"/>
<argument name="submenuUiId" value="{{AdminMenuReportsBusinessIntelligenceAdvancedReporting.dataUiId}}"/>
</actionGroup>
<switchToNextTab stepKey="switchToNewTab"/>
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
<actionGroup ref="AssertAdminAdvancedReportingPageUrlActionGroup" stepKey="assertAdvancedReportingPageUrl"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<testCaseId value="MAGETWO-63981"/>
<group value="analytics"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
</after>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="--Please Select--" stepKey="selectAdvancedReportingIndustry"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<testCaseId value="MAGETWO-66465"/>
<group value="analytics"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
</after>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingServiceLabel}}" userInput="Advanced Reporting Service" stepKey="seeAdvancedReportingServiceLabelEnabled"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
<testCaseId value="MAGETWO-63898"/>
<group value="analytics"/>
</annotations>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
</after>
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
<testCaseId value="MAGETWO-66464"/>
<group value="analytics"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
</after>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="23" stepKey="selectAdvancedReportingHour"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
<argument name="categoryName" value="$$categoryN.name$$, $$categoryM.name$$"/>
</actionGroup>

<wait stepKey="waitBeforeRunCronIndex" time="30"/>
<wait stepKey="waitBeforeRunCronIndex" time="60"/>
<magentoCLI stepKey="runCronIndex" command="cron:run --group=index"/>
<wait stepKey="waitAfterRunCronIndex" time="60"/>
<wait stepKey="waitAfterRunCronIndex" time="120"/>
</before>
<after>
<!-- Change "Category Products" and "Product Categories" indexers to "Update on Save" mode -->
Expand Down Expand Up @@ -108,6 +108,8 @@
<argument name="categoryName" value="$$categoryK.name$$"/>
</actionGroup>

<wait stepKey="waitAfterAssignCategoryK" time="60"/>

<!-- Unassign category M from Product B -->
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="amOnEditCategoryPageB">
<argument name="productId" value="$$productB.id$$"/>
Expand Down Expand Up @@ -147,8 +149,9 @@
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductInCategoryN"/>

<!-- Run cron -->
<wait stepKey="waitBeforeRunMagentoCron" time="30"/>
<wait stepKey="waitBeforeRunMagentoCron" time="60"/>
<magentoCLI stepKey="runMagentoCron" command="cron:run --group=index"/>

<wait stepKey="waitAfterRunMagentoCron" time="90"/>

<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->
Expand Down Expand Up @@ -213,8 +216,9 @@
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="productCOnCategoryN"/>

<!-- Run Cron once to reindex product changes -->
<wait stepKey="waitBeforeRunCronIndexAfterProductAssignToCategory" time="30"/>
<wait stepKey="waitBeforeRunCronIndexAfterProductAssignToCategory" time="60"/>
<magentoCLI stepKey="runCronIndexAfterProductAssignToCategory" command="cron:run --group=index"/>

<wait stepKey="waitAfterRunCronIndexAfterProductAssignToCategory" time="90"/>

<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
</arguments>
<fillField userInput="{{productName}}" selector="{{AdminCustomerWishlistSection.productName}}" stepKey="fillProductNameField"/>
<click selector="{{AdminCustomerWishlistSection.searchButton}}" stepKey="clickSearchButton"/>
<waitForPageLoad stepKey="waitForGridLoading"/>
<waitForAjaxLoad time="60" stepKey="waitForLoading"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$type = $input->getOption(self::INPUT_KEY_PATCH_TYPE);
$modulePath = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
if (null === $modulePath) {
throw new \InvalidArgumentException(sprintf('Cannot find a registered module with name "%s"', $moduleName));
}
$preparedModuleName = str_replace('_', '\\', $moduleName);
$preparedType = ucfirst($type);
$patchInterface = sprintf('%sPatchInterface', $preparedType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Developer\Test\Unit\Console\Command;

use Magento\Developer\Console\Command\GeneratePatchCommand;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Filesystem\Directory\Read;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Filesystem\Directory\Write;
use Magento\Framework\Filesystem\Directory\WriteFactory;
use Magento\Framework\Filesystem\DirectoryList;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\CommandTester;

class GeneratePatchCommandTest extends TestCase
{
/**
* @var ComponentRegistrar|MockObject
*/
private $componentRegistrarMock;

/**
* @var DirectoryList|MockObject
*/
private $directoryListMock;

/**
* @var ReadFactory|MockObject
*/
private $readFactoryMock;

/**
* @var WriteFactory|MockObject
*/
private $writeFactoryMock;

/**
* @var GeneratePatchCommand|MockObject
*/
private $command;

protected function setUp(): void
{
$this->componentRegistrarMock = $this->createMock(ComponentRegistrar::class);
$this->directoryListMock = $this->createMock(DirectoryList::class);
$this->readFactoryMock = $this->createMock(ReadFactory::class);
$this->writeFactoryMock = $this->createMock(WriteFactory::class);

$this->command = new GeneratePatchCommand(
$this->componentRegistrarMock,
$this->directoryListMock,
$this->readFactoryMock,
$this->writeFactoryMock
);
}

public function testExecute()
{
$this->componentRegistrarMock->expects($this->once())
->method('getPath')
->with('module', 'Vendor_Module')
->willReturn('/long/path/to/Vendor/Module');

$read = $this->createMock(Read::class);
$read->expects($this->at(0))
->method('readFile')
->with('patch_template.php.dist')
->willReturn('something');
$this->readFactoryMock->method('create')->willReturn($read);

$write = $this->createMock(Write::class);
$write->expects($this->once())->method('writeFile');
$this->writeFactoryMock->method('create')->willReturn($write);

$this->directoryListMock->expects($this->once())->method('getRoot')->willReturn('/some/path');

$commandTester = new CommandTester($this->command);
$commandTester->execute(
[
GeneratePatchCommand::MODULE_NAME => 'Vendor_Module',
GeneratePatchCommand::INPUT_KEY_PATCH_NAME => 'SomePatch'
]
);
$this->assertStringContainsString('successfully generated', $commandTester->getDisplay());
}

public function testWrongParameter()
{
$this->expectExceptionMessage('Not enough arguments');
$this->expectException(\RuntimeException::class);

$commandTester = new CommandTester($this->command);
$commandTester->execute([]);
}

public function testBadModule()
{
$this->componentRegistrarMock->expects($this->once())
->method('getPath')
->with('module', 'Fake_Module')
->willReturn(null);

$this->expectExceptionMessage('Cannot find a registered module with name "Fake_Module"');
$this->expectException(\InvalidArgumentException::class);

$commandTester = new CommandTester($this->command);
$commandTester->execute(
[
GeneratePatchCommand::MODULE_NAME => 'Fake_Module',
GeneratePatchCommand::INPUT_KEY_PATCH_NAME => 'SomePatch'
]
);
}
}
17 changes: 17 additions & 0 deletions app/code/Magento/Downloadable/Observer/SetLinkStatusObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
'payment_pending' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING_PAYMENT,
'payment_review' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PAYMENT_REVIEW,
];
$expiredOrderItemIds = [];

$downloadableItemsStatuses = [];
$orderItemStatusToEnable = $this->_scopeConfig->getValue(
Expand Down Expand Up @@ -114,6 +115,10 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if (in_array($item->getStatusId(), $availableStatuses)) {
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];
}

if ($item->getQtyOrdered() - $item->getQtyRefunded() == 0) {
$expiredOrderItemIds[] = $item->getId();
}
}
}
}
Expand Down Expand Up @@ -141,10 +146,22 @@ public function execute(\Magento\Framework\Event\Observer $observer)
}
}

if ($expiredOrderItemIds) {
$linkPurchased = $this->_createItemsCollection()->addFieldToFilter(
'order_item_id',
['in' => $expiredOrderItemIds]
);
foreach ($linkPurchased as $link) {
$link->setStatus(\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_EXPIRED)->save();
}
}

return $this;
}

/**
* Returns purchased item collection
*
* @return \Magento\Downloadable\Model\ResourceModel\Link\Purchased\Item\Collection
*/
protected function _createItemsCollection()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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="StorefrontNotAssertDownloadableProductLinkInCustomerAccountActionGroup">
<annotations>
<description>Goes to the Storefront Customer Dashboard page. Clicks on 'My Downloadable Products'. Validates that the provided Downloadable Product is present and Downloadable link not exist.</description>
</annotations>
<arguments>
<argument name="product"/>
</arguments>

<amOnPage url="{{StorefrontCustomerDashboardPage.url}}" stepKey="goToMyAccountPage"/>
<click selector="{{StorefrontCustomerSidebarSection.sidebarTab('My Downloadable Products')}}" stepKey="clickDownloadableProducts"/>
<waitForPageLoad stepKey="waitForDownloadableProductsPageLoad"/>
<seeElement selector="{{StorefrontCustomerDownloadableProductsSection.productName(product.name)}}" stepKey="seeStorefrontDownloadableProductsProductName"/>
<dontSeeElement selector="{{StorefrontCustomerDownloadableProductsSection.downloadableLink}}" stepKey="dontSeeStorefrontMyDownloadableProductsLink"/>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontCustomerDownloadableProductsSection">
<element name="productName" type="text" selector="//table[@id='my-downloadable-products-table']//strong[contains(@class, 'product-name') and normalize-space(.)='{{productName}}']" parameterized="true"/>
<element name="downloadableLink" type="button" selector="//table[@id='my-downloadable-products-table']//a[contains(@class, 'download')]"/>
</section>
</sections>
Loading

0 comments on commit b87f1df

Please sign in to comment.