Skip to content

Commit 1d1e97f

Browse files
authored
Merge pull request #6738 from magento-tsg/2.4-develop-sidecar-pr18
[Sidecar] Tests delivery
2 parents be82efb + 89a19f5 commit 1d1e97f

File tree

8 files changed

+186
-2
lines changed

8 files changed

+186
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="templateTypeHtml">
12+
<data key="templateType">html</data>
13+
</entity>
14+
<entity name="templateTypeOneLine">
15+
<data key="templateType">oneline</data>
16+
</entity>
17+
<entity name="templateTypeText">
18+
<data key="templateType">text</data>
19+
</entity>
20+
</entities>

app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerConfigPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
99
<page name="AdminCustomerConfigPage" url="admin/system_config/edit/section/customer/{{tabLink}}" area="admin" parameterized="true" module="Magento_Customer">
1010
<section name="AdminCustomerConfigSection"/>
11+
<section name="AdminCustomerConfigAddressTemplateSection"/>
1112
</page>
1213
</pages>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAddressesSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<element name="addressesList" type="text" selector=".additional-addresses" />
1919
<element name="deleteAdditionalAddress" type="button" selector="//tbody//tr[{{var}}]//a[@class='action delete']" parameterized="true"/>
2020
<element name="editAdditionalAddress" type="button" selector="//tbody//tr[{{var}}]//a[@class='action edit']" parameterized="true" timeout="30"/>
21-
<element name="addNewAddress" type="button" selector="//span[text()='Add New Address']"/>
21+
<element name="addNewAddress" type="button" selector="//span[text()='Add New Address']" timeout="30"/>
2222
<element name="numberOfAddresses" type="text" selector=".toolbar-number"/>
2323
<element name="shippingAddress" type="text" selector="//div[contains(@class,'box box-shipping-address')]//div/address"/>
2424
<element name="billingAddress" type="text" selector="//div[contains(@class,'box box-billing-address')]//div/address"/>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="AdminCustomerConfigAddressTemplateSection">
10+
<element name="addressTemplatesTab" type="button" selector=".entry-edit-head #customer_address_templates-head" timeout="30"/>
11+
<element name="addressTemplatesTabIsOpen" type="button" selector="//*[@class='entry-edit-head admin__collapsible-block']/a[@id='customer_address_templates-head' and @class='open']" timeout="30"/>
12+
<element name="addressTemplateTypeDefaultCheckbox" type="checkbox" selector="#row_customer_address_templates_{{type_of_template}} #customer_address_templates_{{type_of_template}}_inherit" timeout="30" parameterized="true"/>
13+
<element name="addressTemplateTypeValueInput" type="input" selector="#row_customer_address_templates_{{type_of_template}} #customer_address_templates_{{type_of_template}}" parameterized="true"/>
14+
</section>
15+
</sections>

app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="paymentMethod" type="text" selector=".box-order-billing-method dt.title"/>
2121
<element name="shippingMethod" type="text" selector=".box-order-shipping-method div.box-content"/>
2222
<element name="productNameCell" type="text" selector="//*[contains(@class, 'product-item-name')]"/>
23-
</section>
23+
<element name="shippingAddressBlock" type="block" selector=".block-order-details-view .box-order-shipping-address .box-content"/>
24+
</section>
2425
</sections>
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+
declare(strict_types=1);
7+
8+
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
9+
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
10+
use Magento\MediaGalleryApi\Api\SaveAssetsInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
/** @var AssetInterfaceFactory $mediaAssetFactory */
15+
$mediaAssetFactory = $objectManager->get(AssetInterfaceFactory::class);
16+
/** @var AssetInterface $mediaAsset */
17+
$mediaAsset = $mediaAssetFactory->create(
18+
[
19+
'path' => 'testDirectory/year_ago_loaded_img.jpg',
20+
'description' => 'Description of an image',
21+
'contentType' => 'image',
22+
'title' => 'Img',
23+
'source' => 'Local',
24+
'width' => 420,
25+
'height' => 240,
26+
'size' => 12877,
27+
'createdAt' => (new \DateTime('-1 year'))->format('Y-m-d H:i:s'),
28+
]
29+
);
30+
/** @var SaveAssetsInterface $mediaSave */
31+
$mediaSave = $objectManager->get(SaveAssetsInterface::class);
32+
$mediaId = $mediaSave->execute([$mediaAsset]);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
11+
$objectManager = Bootstrap::getObjectManager();
12+
13+
/** @var DeleteAssetsByPathsInterface $mediaSave */
14+
$mediaAssetDelete = $objectManager->get(DeleteAssetsByPathsInterface::class);
15+
16+
try {
17+
$mediaAssetDelete->execute(['testDirectory/year_ago_loaded_img.jpg']);
18+
} catch (\Exception $exception) {
19+
// already deleted
20+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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\MediaGalleryUi\Model\Listing;
9+
10+
use Magento\Framework\App\RequestInterface;
11+
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\Framework\View\Element\UiComponentFactory;
13+
use Magento\Framework\View\Element\UiComponentInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Checks standalone media gallery listing data provider behavior
19+
*
20+
* @magentoAppArea adminhtml
21+
*/
22+
class DataProviderTest extends TestCase
23+
{
24+
/** @var ObjectManagerInterface */
25+
private $objectManager;
26+
27+
/** @var UiComponentFactory */
28+
private $componentFactory;
29+
30+
/** @var RequestInterface */
31+
private $request;
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
protected function setUp(): void
37+
{
38+
parent::setUp();
39+
40+
$this->objectManager = Bootstrap::getObjectManager();
41+
$this->request = $this->objectManager->get(RequestInterface::class);
42+
$this->componentFactory = $this->objectManager->get(UiComponentFactory::class);
43+
}
44+
45+
/**
46+
* @magentoDataFixture Magento/MediaGallery/_files/media_asset.php
47+
* @magentoDataFixture Magento/MediaGallery/_files/media_asset_loaded_year_ago.php
48+
*
49+
* @return void
50+
*/
51+
public function testFilterByDate(): void
52+
{
53+
$filter = [
54+
'created_at' => [
55+
'from' => (new \DateTime('-1 day'))->format('m/d/Y'),
56+
'to' => (new \DateTime())->format('m/d/Y'),
57+
],
58+
];
59+
$this->request->setParams(['filters' => $filter]);
60+
$data = $this->getComponentProvidedData('standalone_media_gallery_listing');
61+
$items = $data['items'];
62+
$this->assertCount(1, $items);
63+
$item = reset($items);
64+
$this->assertEquals('testDirectory/path.jpg', $item['path']);
65+
}
66+
67+
/**
68+
* Call prepare method in the child components
69+
*
70+
* @param UiComponentInterface $component
71+
* @return void
72+
*/
73+
private function prepareChildComponents(UiComponentInterface $component): void
74+
{
75+
foreach ($component->getChildComponents() as $child) {
76+
$this->prepareChildComponents($child);
77+
}
78+
79+
$component->prepare();
80+
}
81+
82+
/**
83+
* Get component provided data
84+
*
85+
* @param string $namespace
86+
* @return array
87+
*/
88+
private function getComponentProvidedData(string $namespace): array
89+
{
90+
$component = $this->componentFactory->create($namespace);
91+
$this->prepareChildComponents($component);
92+
93+
return $component->getContext()->getDataProvider()->getData();
94+
}
95+
}

0 commit comments

Comments
 (0)