Skip to content

Commit 15abee9

Browse files
committed
Merge branch 'BUG#AC-6330' into spartans_pr_04082022
2 parents 63a97a6 + 2cff38e commit 15abee9

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontConfigurableProductSwatchWithDisplayOutOfStockEnabledTest">
11+
<annotations>
12+
<features value="Swatches"/>
13+
<stories value="Configurable product with swatch attribute and display out of stock enabled"/>
14+
<title value="Configurable product with swatch attribute and display out of stock enabled"/>
15+
<description value="Storefront selection of out of stock child products of configurable products are
16+
disabled when display of out of stock options are enabled and those child products that are in stock are enabled for selection"/>
17+
<severity value="CRITICAL"/>
18+
<group value="Swatches"/>
19+
</annotations>
20+
<before>
21+
<!--Set Display out of stock product-->
22+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 1" />
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
<!-- Create a new product attribute of type "Text Swatch" -->
25+
<actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="goToNewProductAttributePage"/>
26+
<fillField selector="{{AttributePropertiesSection.DefaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillDefaultLabel"/>
27+
<selectOption selector="{{AttributePropertiesSection.InputType}}" userInput="swatch_text" stepKey="selectInputType"/>
28+
<click selector="{{AdminManageSwatchSection.addSwatchText}}" stepKey="clickAddSwatch0"/>
29+
<fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('0')}}" userInput="red" stepKey="fillSwatch0"/>
30+
<fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('0')}}" userInput="Something red." stepKey="fillDescription0"/>
31+
<click selector="{{AdminManageSwatchSection.addSwatchText}}" stepKey="clickAddSwatch1"/>
32+
<fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('1')}}" userInput="green" stepKey="fillSwatch1"/>
33+
<fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('1')}}" userInput="Something green." stepKey="fillDescription1"/>
34+
<click selector="{{AttributePropertiesSection.AdvancedProperties}}" stepKey="expandAdvancedProperties"/>
35+
<selectOption selector="{{AttributePropertiesSection.Scope}}" userInput="1" stepKey="selectGlobalScope"/>
36+
<!-- Save and verify -->
37+
<click selector="{{AttributePropertiesSection.SaveAndEdit}}" stepKey="clickSave"/>
38+
<seeInField selector="{{AttributePropertiesSection.DefaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="seeDefaultLabel"/>
39+
<seeInField selector="{{AdminManageSwatchSection.nthSwatchText('1')}}" userInput="red" stepKey="seeSwatch0"/>
40+
<seeInField selector="{{AdminManageSwatchSection.nthSwatchAdminDescription('1')}}" userInput="Something red." stepKey="seeDescription0"/>
41+
<seeInField selector="{{AdminManageSwatchSection.nthSwatchText('2')}}" userInput="green" stepKey="seeSwatch1"/>
42+
<seeInField selector="{{AdminManageSwatchSection.nthSwatchAdminDescription('2')}}" userInput="Something green." stepKey="seeDescription1"/>
43+
<!-- Create a configurable product to verify the storefront with -->
44+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="amOnProductGridPage"/>
45+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateConfigurableProduct">
46+
<argument name="product" value="BaseConfigurableProduct"/>
47+
</actionGroup>
48+
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/>
49+
<fillField userInput="{{_defaultProduct.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/>
50+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="configProductTest123" stepKey="fillProductName"/>
51+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="configProductTest123" stepKey="fillProductSku"/>
52+
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="100" stepKey="fillProductPrice"/>
53+
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="100" stepKey="fillProductQty"/>
54+
<selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="In Stock" stepKey="selectStockStatus"/>
55+
<selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeight"/>
56+
<fillField selector="{{AdminProductFormSection.productWeight}}" userInput="100" stepKey="fillProductWeight"/>
57+
<!-- Create configurations based off the Text Swatch we created earlier -->
58+
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickCreateConfigurations"/>
59+
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickFilters"/>
60+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillFilterAttributeCodeField"/>
61+
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
62+
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
63+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
64+
<click selector="{{AdminCreateProductConfigurationsPanel.selectAll}}" stepKey="clickOnSelectAll"/>
65+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
66+
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
67+
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="1" stepKey="enterAttributeQuantity"/>
68+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
69+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
70+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/>
71+
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
72+
<!-- Edit the quantity of child product -->
73+
<actionGroup ref="FilterAndSelectProductActionGroup" stepKey="openAdminChildProductPage">
74+
<argument name="productSku" value="configProductTest123-Something red."/>
75+
</actionGroup>
76+
<selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="Out of Stock" stepKey="selectChildProductStockStatus"/>
77+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton3"/>
78+
<!-- Reindex invalidated indices after product attribute has been created/deleted -->
79+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
80+
</before>
81+
82+
<after>
83+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 0" />
84+
<actionGroup ref="DeleteProductsByKeywordActionGroup" stepKey="deleteProductsByKeyword">
85+
<argument name="keyword" value="configProductTest123"/>
86+
</actionGroup>
87+
<actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteCreatedAttribute">
88+
<argument name="productAttributeLabel" value="{{ProductAttributeFrontendLabel.label}}" />
89+
</actionGroup>
90+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
91+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
92+
</after>
93+
94+
<!-- Go to the product page and see text swatch options-->
95+
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="amOnProductPage"/>
96+
<waitForPageLoad time='60' stepKey="waitForProductPage"/>
97+
<see selector="{{StorefrontProductInfoMainSection.swatchAttributeOptions}}" userInput="red" stepKey="seeRed"/>
98+
<grabAttributeFrom selector="{{StorefrontProductInfoMainSection.nthSwatchOptionText('1')}}" userInput="disabled" stepKey="grabRedAttribute"/>
99+
<assertEquals stepKey="assertRedDisabled">
100+
<expectedResult type="string">true</expectedResult>
101+
<actualResult type="string">{$grabRedAttribute}</actualResult>
102+
</assertEquals>
103+
<click selector="{{StorefrontProductInfoMainSection.nthSwatchOptionText('2')}}" stepKey="selectGreenOption"/>
104+
<waitForElementClickable selector="{{StorefrontProductActionSection.addToCart}}" stepKey="waitForAddToCartButton"/>
105+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="clickOnAddToCartButton"/>
106+
<waitForPageLoad stepKey="waitForProductToAddInCart"/>
107+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
108+
<seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/>
109+
</test>
110+
</tests>

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ define([
506506

507507
if ($widget.options.jsonConfig.canDisplayShowOutOfStockStatus) {
508508
let salableProducts = $widget.options.jsonConfig.salable[item.id],
509-
swatchOptions = container.find('.swatch-option');
509+
swatchOptions = $(container).find(`[data-attribute-id='${item.id}']`).find('.swatch-option');
510510

511511
swatchOptions.each(function (key, value) {
512512
let optionId = $(value).data('option-id');

0 commit comments

Comments
 (0)