Skip to content

Commit

Permalink
Fix ui-select options placeholders for url-filter-applier && Clean ca…
Browse files Browse the repository at this point in the history
…ched options for ui-select component after closing slide form
  • Loading branch information
Nazar65 committed Aug 17, 2020
1 parent 4930963 commit 4ebe9d6
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 144 deletions.
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="AssertAdminMediaGalleryAssetFilterPlaceHolderActionGroup">
<annotations>
<description>Assert asset filter placeholder value</description>
</annotations>
<arguments>
<argument name="filterPlaceholder" type="string"/>
</arguments>

<seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.activeFilterPlaceholder(filterPlaceholder)}}" stepKey="assertFilterPLaceHolder" />
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminMediaGalleryCatalogUiCategoryGridSection">
<element name="activeFilterPlaceholder" type="text" selector="//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/>
<element name="path" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Path')]/preceding-sibling::th)]" parameterized="true"/>
<element name="name" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Name')]/preceding-sibling::th) +1 ]//*[text()='{{categoryName}}']" parameterized="true"/>
<element name="displayMode" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Display Mode')]/preceding-sibling::th) +1 ]//*[text()='{{productsText}}']" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,20 @@
<actionGroup ref="AdminMediaGalleryAssertImageInGridActionGroup" stepKey="assertImageInGrid">
<argument name="title" value="ImageMetadata.title"/>
</actionGroup>

<wait time="10" stepKey="waitForBookmarkToSaveView"/>
<reloadPage stepKey="reloadPage"/>
<waitForPageLoad stepKey="waitForGridReloaded"/>
<actionGroup ref="AdminAssertMediaGalleryFilterPlaceholderActionGroup" stepKey="assertFilterApplied">
<argument name="filterPlaceholder" value="$$product.name$$"/>
</actionGroup>

<actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/>
<actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectFirstImageToDelete">
<argument name="imageName" value="{{ImageMetadata.title}}"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clikDeleteSelectedButton"/>
<actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/>

</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<actionGroup ref="AdminEnhancedMediaGalleryClickEntityUsedInActionGroup" stepKey="clickUsedInCategories">
<argument name="entityName" value="Categories"/>
</actionGroup>
<actionGroup ref="AssertAdminMediaGalleryAssetFilterPlaceHolderActionGroup" stepKey="assertFilterApplied">
<argument name="filterPlaceholder" value="{{UpdatedImageDetails.title}}"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryAssertCategoryNameInCategoryGridActionGroup" stepKey="assertCategoryInGrid">
<argument name="categoryName" value="$$category.name$$"/>
</actionGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,54 +80,36 @@ public function prepare()
{
$options = [];
$productIds = [];
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
foreach ($bookmarks as $bookmark) {
if ($bookmark->getIdentifier() === 'current') {
$applied = $bookmark->getConfig()['current']['filters']['applied'];
if (isset($applied[$this->getName()])) {
$productIds = $applied[$this->getName()];
}
}
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
'current',
$this->context->getNameSpace()
);
if ($bookmark === null) {
parent::prepare();
return;
}

foreach ($productIds as $id) {
$product = $this->productRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $product->getName(),
'is_active' => $product->getStatus(),
'path' => $product->getSku(),
'optgroup' => false
$applied = $bookmark->getConfig()['current']['filters']['applied'];

];
if (isset($applied[$this->getName()])) {
$productIds = $applied[$this->getName()];
}

$this->wrappedComponent = $this->uiComponentFactory->create(
$this->getName(),
parent::COMPONENT,
[
'context' => $this->getContext(),
'options' => $options
]
);

$this->wrappedComponent->prepare();
$productsFilterJsConfig = array_replace_recursive(
$this->getJsConfig($this->wrappedComponent),
$this->getJsConfig($this)
);
$this->setData('js_config', $productsFilterJsConfig);

$this->setData(
'config',
array_replace_recursive(
(array)$this->wrappedComponent->getData('config'),
(array)$this->getData('config')
)
);

$this->applyFilter();

foreach ($productIds as $id) {
try {
$product = $this->productRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $product->getName(),
'is_active' => $product->getStatus(),
'path' => $product->getSku(),
'optgroup' => false
];
} catch (\Exception $e) {
continue;
}
}
$this->optionsProvider = $options;
parent::prepare();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,52 +80,36 @@ public function prepare()
{
$options = [];
$blockIds = [];
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
foreach ($bookmarks as $bookmark) {
if ($bookmark->getIdentifier() === 'current') {
$applied = $bookmark->getConfig()['current']['filters']['applied'];
if (isset($applied[$this->getName()])) {
$blockIds = $applied[$this->getName()];
}
}
}

foreach ($blockIds as $id) {
$block = $this->blockRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $block->getTitle(),
'is_active' => $block->isActive(),
'optgroup' => false
];
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
'current',
$this->context->getNameSpace()
);
if ($bookmark === null) {
parent::prepare();
return;
}

$this->wrappedComponent = $this->uiComponentFactory->create(
$this->getName(),
parent::COMPONENT,
[
'context' => $this->getContext(),
'options' => $options
]
);
$applied = $bookmark->getConfig()['current']['filters']['applied'];

$this->wrappedComponent->prepare();
$jsConfig = array_replace_recursive(
$this->getJsConfig($this->wrappedComponent),
$this->getJsConfig($this)
);
$this->setData('js_config', $jsConfig);

$this->setData(
'config',
array_replace_recursive(
(array)$this->wrappedComponent->getData('config'),
(array)$this->getData('config')
)
);
if (isset($applied[$this->getName()])) {
$blockIds = $applied[$this->getName()];
}

$this->applyFilter();
foreach ($blockIds as $id) {
try {
$block = $this->blockRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $block->getTitle(),
'is_active' => $block->isActive(),
'optgroup' => false
];
} catch (\Exception $e) {
continue;
}
}

$this->optionsProvider = $options;
parent::prepare();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,52 +80,35 @@ public function prepare()
{
$options = [];
$pageIds = [];
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
foreach ($bookmarks as $bookmark) {
if ($bookmark->getIdentifier() === 'current') {
$applied = $bookmark->getConfig()['current']['filters']['applied'];
if (isset($applied[$this->getName()])) {
$pageIds = $applied[$this->getName()];
}
}
}

foreach ($pageIds as $id) {
$page = $this->pageRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $page->getTitle(),
'is_active' => $page->isActive(),
'optgroup' => false
];
}

$this->wrappedComponent = $this->uiComponentFactory->create(
$this->getName(),
parent::COMPONENT,
[
'context' => $this->getContext(),
'options' => $options
]
);

$this->wrappedComponent->prepare();
$pagesFilterjsConfig = array_replace_recursive(
$this->getJsConfig($this->wrappedComponent),
$this->getJsConfig($this)
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
'current',
$this->context->getNameSpace()
);
$this->setData('js_config', $pagesFilterjsConfig);
if ($bookmark === null) {
parent::prepare();
return;
}

$this->setData(
'config',
array_replace_recursive(
(array)$this->wrappedComponent->getData('config'),
(array)$this->getData('config')
)
);
$applied = $bookmark->getConfig()['current']['filters']['applied'];

$this->applyFilter();
if (isset($applied[$this->getName()])) {
$pageIds = $applied[$this->getName()];
}

foreach ($pageIds as $id) {
try {
$page = $this->pageRepository->getById($id);
$options[] = [
'value' => $id,
'label' => $page->getTitle(),
'is_active' => $page->isActive(),
'optgroup' => false
];
} catch (\Exception $e) {
continue;
}
}
$this->optionsProvider = $options;
parent::prepare();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function execute()
$responseContent['options'][] = [
'value' => (string) $asset->getId(),
'label' => $asset->getTitle(),
'path' => $this->storage->getThumbnailUrl($this->images->getStorageRoot() . $asset->getPath())
'src' => $this->storage->getThumbnailUrl($this->images->getStorageRoot() . $asset->getPath())
];
$responseContent['total'] = count($responseContent['options']);
}
Expand Down
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="AdminAssertMediaGalleryFilterPlaceholderActionGroup">
<annotations>
<description>Assert asset filter placeholder value</description>
</annotations>
<arguments>
<argument name="filterPlaceholder" type="string"/>
</arguments>

<seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.activeFilterPlaceholder(filterPlaceholder)}}" stepKey="assertFilterPLaceHolder" />
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<element name="searchOptionsFilterOption" type="text" selector="//div[label/span[contains(text(), '{{filterName}}')]]//label[@class='admin__action-multiselect-label']/span[text()='{{optionName}}']" parameterized="true" timeout="30"/>
<element name="searchOptionsFilterDone" type="button" selector="//div[label/span[contains(text(), '{{filterName}}')]]//button[@data-action='close-advanced-select']" parameterized="true"/>
<element name="duplicatedFilterCheckbox" type="button" selector="//input[@name='duplicated']"/>
<element name="activeFilterValue" type="text" selector="//div[@class='media-gallery-container']//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/>
</section>
</sections>
Loading

0 comments on commit 4ebe9d6

Please sign in to comment.