Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0414957

Browse files
committed
Merge remote-tracking branch 'austin/MAGETWO-80093-Functional-Test-Configurable-OOS-LayeredNavigation' into bugs
2 parents 9c14af7 + 5bbcc9c commit 0414957

File tree

8 files changed

+259
-0
lines changed

8 files changed

+259
-0
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,33 @@
272272
</field>
273273
</dataset>
274274

275+
<dataset name="sizes_S_M_L_Filterable">
276+
<field name="frontend_label" xsi:type="string">size_%isolation%</field>
277+
<field name="attribute_code" xsi:type="string">size_%isolation%</field>
278+
<field name="frontend_input" xsi:type="string">Dropdown</field>
279+
<field name="is_required" xsi:type="string">No</field>
280+
<field name="is_searchable" xsi:type="string">Yes</field>
281+
<field name="is_filterable" xsi:type="string">Filterable (with results)</field>
282+
<field name="is_filterable_in_search" xsi:type="string">Yes</field>
283+
<field name="options" xsi:type="array">
284+
<item name="0" xsi:type="array">
285+
<item name="is_default" xsi:type="string">No</item>
286+
<item name="admin" xsi:type="string">SIZE_S</item>
287+
<item name="view" xsi:type="string">SIZE_S</item>
288+
</item>
289+
<item name="1" xsi:type="array">
290+
<item name="is_default" xsi:type="string">No</item>
291+
<item name="admin" xsi:type="string">SIZE_M</item>
292+
<item name="view" xsi:type="string">SIZE_M</item>
293+
</item>
294+
<item name="2" xsi:type="array">
295+
<item name="is_default" xsi:type="string">No</item>
296+
<item name="admin" xsi:type="string">SIZE_L</item>
297+
<item name="view" xsi:type="string">SIZE_L</item>
298+
</item>
299+
</field>
300+
</dataset>
301+
275302
<dataset name="sizes_for_promo_rules">
276303
<field name="frontend_label" xsi:type="string">size_%isolation%</field>
277304
<field name="attribute_code" xsi:type="string">size_%isolation%</field>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Test\Constraint;
8+
9+
use Magento\Mtf\Fixture\FixtureFactory;
10+
use Magento\Mtf\Fixture\InjectableFixture;
11+
use Magento\Cms\Test\Page\CmsIndex;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
14+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
15+
use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct;
16+
17+
/**
18+
* Check whether OOS product attribute options for configurable product are displayed on frontend in Layered navigation.
19+
*/
20+
class AssertConfigurableProductAttributeOptionInLayeredNavigation extends AbstractConstraint
21+
{
22+
/**
23+
* Check whether the OOS attribute options are displayed on the frontend in Layered navigation.
24+
*
25+
* @param CatalogCategoryView $catalogCategoryView
26+
* @param InjectableFixture $product
27+
* @param CmsIndex $cmsIndex
28+
* @param FixtureFactory $fixtureFactory
29+
* @param string $outOfStockOption
30+
* @return void
31+
*/
32+
public function processAssert(
33+
CatalogCategoryView $catalogCategoryView,
34+
InjectableFixture $product,
35+
CmsIndex $cmsIndex,
36+
FixtureFactory $fixtureFactory,
37+
$outOfStockOption
38+
) {
39+
$fixtureFactory->createByCode(
40+
'catalogProductSimple',
41+
[
42+
'dataset' => 'product_with_category_with_anchor',
43+
'data' => [
44+
'category_ids' => [
45+
'dataset' => null,
46+
'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]
47+
]
48+
],
49+
]
50+
)->persist();
51+
52+
$cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
53+
$filters = $catalogCategoryView->getLayeredNavigationBlock()->getFilterContents();
54+
55+
\PHPUnit_Framework_Assert::assertFalse(
56+
in_array(strtoupper($outOfStockOption), $filters),
57+
'Out of Stock attribute option is present in layered navigation on category page.'
58+
);
59+
}
60+
61+
/**
62+
* Return string representation of object.
63+
*
64+
* @return string
65+
*/
66+
public function toString()
67+
{
68+
return 'Out of Stock attribute option is absent in layered navigation on category page.';
69+
}
70+
}

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,5 +1115,37 @@
11151115
</item>
11161116
</field>
11171117
</dataset>
1118+
<dataset name="product_with_3_sizes">
1119+
<field name="name" xsi:type="string">Configurable product with sizes %isolation%</field>
1120+
<field name="sku" xsi:type="string">sku_configurable_product_with_sizes_%isolation%</field>
1121+
<field name="product_has_weight" xsi:type="string">This item has weight</field>
1122+
<field name="weight" xsi:type="string">2</field>
1123+
<field name="status" xsi:type="string">Yes</field>
1124+
<field name="visibility" xsi:type="string">Catalog, Search</field>
1125+
<field name="tax_class_id" xsi:type="array">
1126+
<item name="dataset" xsi:type="string">taxable_goods</item>
1127+
</field>
1128+
<field name="url_key" xsi:type="string">configurable-product-with-size-%isolation%</field>
1129+
<field name="configurable_attributes_data" xsi:type="array">
1130+
<item name="dataset" xsi:type="string">size_3_items</item>
1131+
</field>
1132+
<field name="quantity_and_stock_status" xsi:type="array">
1133+
<item name="is_in_stock" xsi:type="string">In Stock</item>
1134+
</field>
1135+
<field name="website_ids" xsi:type="array">
1136+
<item name="0" xsi:type="array">
1137+
<item name="dataset" xsi:type="string">default</item>
1138+
</item>
1139+
</field>
1140+
<field name="category_ids" xsi:type="array">
1141+
<item name="dataset" xsi:type="string">default_anchor_subcategory</item>
1142+
</field>
1143+
<field name="attribute_set_id" xsi:type="array">
1144+
<item name="dataset" xsi:type="string">default</item>
1145+
</field>
1146+
<field name="price" xsi:type="array">
1147+
<item name="value" xsi:type="string">170</item>
1148+
</field>
1149+
</dataset>
11181150
</repository>
11191151
</config>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,44 @@
623623
</field>
624624
</dataset>
625625

626+
<dataset name="size_3_items">
627+
<field name="attributes_data" xsi:type="array">
628+
<item name="attribute_key_0" xsi:type="array">
629+
<item name="options" xsi:type="array">
630+
<item name="option_key_0" xsi:type="array">
631+
<item name="pricing_value" xsi:type="string">40.00</item>
632+
<item name="include" xsi:type="string">Yes</item>
633+
</item>
634+
<item name="option_key_1" xsi:type="array">
635+
<item name="pricing_value" xsi:type="string">42.00</item>
636+
<item name="include" xsi:type="string">Yes</item>
637+
</item>
638+
<item name="option_key_2" xsi:type="array">
639+
<item name="pricing_value" xsi:type="string">44.00</item>
640+
<item name="include" xsi:type="string">Yes</item>
641+
</item>
642+
</item>
643+
</item>
644+
</field>
645+
<field name="attributes" xsi:type="array">
646+
<item name="attribute_key_0" xsi:type="string">catalogProductAttribute::sizes_S_M_L_Filterable</item>
647+
</field>
648+
<field name="matrix" xsi:type="array">
649+
<item name="attribute_key_0:option_key_0" xsi:type="array">
650+
<item name="qty" xsi:type="string">100</item>
651+
<item name="weight" xsi:type="string">1</item>
652+
</item>
653+
<item name="attribute_key_0:option_key_1" xsi:type="array">
654+
<item name="qty" xsi:type="string">100</item>
655+
<item name="weight" xsi:type="string">1</item>
656+
</item>
657+
<item name="attribute_key_0:option_key_2" xsi:type="array">
658+
<item name="qty" xsi:type="string">100</item>
659+
<item name="weight" xsi:type="string">1</item>
660+
</item>
661+
</field>
662+
</dataset>
663+
626664
<dataset name="color_and_size_with_images">
627665
<field name="attributes_data" xsi:type="array">
628666
<item name="attribute_key_0" xsi:type="array">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Scenario;
10+
11+
/**
12+
* Preconditions:
13+
1. Choose the color attribute and set attribute properties to
14+
2. is_filterable = Filterable (with results)
15+
3. is_filterable_in_search = Yes
16+
*
17+
* Steps:
18+
* 1. Log in to Admin.
19+
* 2. Open Products -> Catalog.
20+
* 3. Create a configurable product with three variations.
21+
* 4. Search and open child of configurable product from preconditions.
22+
* 4. Fill in data according to dataset.
23+
* 5. Save product.
24+
* 6. Perform all assertions.
25+
*
26+
* @group Configurable_Product
27+
* @ZephyrId MAGETWO-72439
28+
*/
29+
class VerifyConfigurableProductLayeredNavigationTest extends Scenario
30+
{
31+
/**
32+
* Verify configurable product options in layered navigation.
33+
*
34+
* @return array
35+
*/
36+
public function test()
37+
{
38+
$this->executeScenario();
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\ConfigurableProduct\Test\TestCase\VerifyConfigurableProductLayeredNavigationTest" summary="Verify OOS option configurable product in Layered Navigation on storefront">
10+
<variation name="VerifyConfigurableProductEntityPriceTestVariation2" summary="Verify the out of stock configurable attribute option doesn't show in Layered navigation" ticketId="MAGETWO-72439">
11+
<data name="product" xsi:type="string">configurableProduct::product_with_3_sizes</data>
12+
<data name="productUpdate/childProductUpdate" xsi:type="array">
13+
<item name="data" xsi:type="array">
14+
<item name="quantity_and_stock_status" xsi:type="array">
15+
<item name="is_in_stock" xsi:type="string">Out of Stock</item>
16+
</item>
17+
</item>
18+
</data>
19+
<data name="productUpdate/optionNumber" xsi:type="string">1</data>
20+
<data name="outOfStockOption" xsi:type="string">SIZE_S</data>
21+
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductAttributeOptionInLayeredNavigation" />
22+
</variation>
23+
</testCase>
24+
</config>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/testcase.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717
<step name="createProduct" module="Magento_Catalog" next="updateChildProduct" />
1818
<step name="updateChildProduct" module="Magento_ConfigurableProduct" />
1919
</scenario>
20+
<scenario name="VerifyConfigurableProductLayeredNavigationTest" firstStep="createProduct">
21+
<step name="createProduct" module="Magento_Catalog" next="updateChildProduct" />
22+
<step name="updateChildProduct" module="Magento_ConfigurableProduct" />
23+
</scenario>
2024
</config>

dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class Navigation extends Block
3636
*/
3737
protected $optionTitle = './/div[@class="filter-options-title" and contains(text(),"%s")]';
3838

39+
/**
40+
* Locator value for corresponding filtered attribute option content.
41+
*
42+
* @var string
43+
*/
44+
protected $optionContent = './/div[@class="filter-options-title" and contains(text(),"")]/following-sibling::div//a[contains(text(), \'SIZE\')]';
45+
3946
/**
4047
* Locator value for correspondent "Filter" link.
4148
*
@@ -92,6 +99,23 @@ public function getFilters()
9299
return $data;
93100
}
94101

102+
/**
103+
* Get all available filters.
104+
*
105+
* @return array
106+
*/
107+
public function getFilterContents()
108+
{
109+
$this->waitForElementVisible($this->loadedNarrowByList);
110+
$optionContents = $this->_rootElement->find($this->optionContent, Locator::SELECTOR_XPATH);
111+
$data =[];
112+
foreach ($optionContents as $optionContent) {
113+
$data[] = trim(strtoupper($optionContent->getText()));
114+
}
115+
116+
return $data;
117+
}
118+
95119
/**
96120
* Apply Layered Navigation filter.
97121
*

0 commit comments

Comments
 (0)