Skip to content

Commit 1a780d2

Browse files
committed
MC-5233: DateTime product attributes support
1 parent a9f42f9 commit 1a780d2

File tree

5 files changed

+98
-27
lines changed

5 files changed

+98
-27
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@
345345
<fillField stepKey="fillDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{{date}}"/>
346346
</actionGroup>
347347

348+
<!-- Inputs datetime default value and attribute code-->
349+
<actionGroup name="CreateProductAttributeWithDatetimeField" extends="createProductAttribute" insertAfter="checkRequired">
350+
<annotations>
351+
<description>EXTENDS: createProductAttribute. Fills in the Attribute Code and Default Value (Attribute Type: Date and Time Field).</description>
352+
</annotations>
353+
<arguments>
354+
<argument name="date" type="string"/>
355+
</arguments>
356+
357+
<scrollTo selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="scrollToAdvancedSection"/>
358+
<click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="openAdvancedSection"/>
359+
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" stepKey="waitForSlideOutAdvancedSection"/>
360+
<fillField stepKey="fillCode" selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{attribute.attribute_code}}"/>
361+
<scrollTo selector="{{AdvancedAttributePropertiesSection.DefaultValueDatetime}}" stepKey="scrollToDefaultField"/>
362+
<fillField stepKey="fillDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDatetime}}" userInput="{{date}}"/>
363+
</actionGroup>
364+
348365
<!-- Creates dropdown option at row without saving-->
349366
<actionGroup name="createAttributeDropdownNthOption">
350367
<annotations>
@@ -377,7 +394,7 @@
377394
<description>Navigate and open Advanced Attribute Properties section on product attribute page</description>
378395
</annotations>
379396

380-
<scrollTo selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="scrollToSection"/>
397+
<scrollTo selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="scrollToSection"/>
381398
<click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="openSection"/>
382399
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" stepKey="waitForSlideOutSection"/>
383400
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
<data key="frontend_input">date</data>
310310
<data key="is_required_admin">No</data>
311311
</entity>
312-
<entity name="datetimeProductAttribute" extends="productAttributeWysiwyg" type="ProductAttribute">
312+
<entity name="DatetimeProductAttribute" extends="productAttributeWysiwyg" type="ProductAttribute">
313313
<data key="frontend_input">datetime</data>
314314
<data key="is_required_admin">No</data>
315315
</entity>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
<element name="productCount" type="text" selector="#catalog_category_products-total-count"/>
3737
<element name="productPerPage" type="select" selector="#catalog_category_products_page-limit"/>
3838
<element name="storeViewDropdown" type="text" selector="//select[@name='store_id']/option[contains(.,'{{storeView}}')]" parameterized="true"/>
39+
<element name="inputByCodeRangeFrom" type="input" selector="input.admin__control-text[name='{{code}}[from]']" parameterized="true"/>
40+
<element name="inputByCodeRangeTo" type="input" selector="input.admin__control-text[name='{{code}}[to]']" parameterized="true"/>
3941
</section>
4042
</sections>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,31 @@
1414
<description value="Admin should be able to create datetime product attribute"/>
1515
<severity value="CRITICAL"/>
1616
<testCaseId value="MC-21451"/>
17-
<group value="Catalog"/>
17+
<group value="catalog"/>
1818
</annotations>
1919
<before>
2020
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
2121
</before>
2222
<after>
2323
<actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute">
24-
<argument name="ProductAttribute" value="datetimeProductAttribute"/>
24+
<argument name="ProductAttribute" value="DatetimeProductAttribute"/>
2525
</actionGroup>
2626
<actionGroup ref="logout" stepKey="logout"/>
2727
</after>
28-
29-
<amOnPage url="{{ProductAttributePage.url}}" stepKey="navigateToNewProductAttributePage"/>
30-
<waitForPageLoad stepKey="waitForPageLoad"/>
31-
<!-- Set attribute properties -->
32-
<fillField selector="{{AttributePropertiesSection.DefaultLabel}}"
33-
userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillDefaultLabel"/>
34-
<selectOption selector="{{AttributePropertiesSection.InputType}}"
35-
userInput="{{datetimeProductAttribute.frontend_input}}" stepKey="fillInputType"/>
36-
<actionGroup ref="AdminNavigateToProductAttributeAdvancedSection" stepKey="goToAdvancedSectionNew"/>
37-
<fillField selector="{{AdvancedAttributePropertiesSection.AttributeCode}}"
38-
userInput="{{datetimeProductAttribute.attribute_code}}"
39-
stepKey="fillAttributeCode"/>
40-
<!-- Generate and set a default value -->
28+
<!-- Generate the datetime default value -->
4129
<generateDate date="now" format="m/j/y g:i A" stepKey="generateDefaultValue"/>
42-
<fillField selector="{{AdvancedAttributePropertiesSection.DefaultValueDatetime}}"
43-
userInput="{$generateDefaultValue}"
44-
stepKey="fillDefaultValue"/>
45-
<!-- Save the new product attribute -->
46-
<click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSaveAttribute"/>
47-
<waitForPageLoad stepKey="waitForGridPageLoadAfterSaveAttribute"/>
48-
<seeElement selector="{{AdminProductMessagesSection.successMessage}}"
49-
stepKey="waitForSuccessMessage"/>
30+
<!-- Create new datetime product attribute -->
31+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/>
32+
<waitForPageLoad stepKey="waitForPageLoadAttributes"/>
33+
<actionGroup ref="CreateProductAttributeWithDatetimeField" stepKey="createAttribute">
34+
<argument name="attribute" value="DatetimeProductAttribute"/>
35+
<argument name="date" value="{$generateDefaultValue}"/>
36+
</actionGroup>
5037
<!-- Navigate to created product attribute -->
5138
<actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute">
52-
<argument name="ProductAttribute" value="datetimeProductAttribute"/>
39+
<argument name="ProductAttribute" value="DatetimeProductAttribute"/>
5340
</actionGroup>
54-
<!-- Check the saved date and time default value -->
41+
<!-- Check the saved datetime default value -->
5542
<actionGroup ref="AdminNavigateToProductAttributeAdvancedSection" stepKey="goToAdvancedSection"/>
5643
<scrollTo selector="{{AdvancedAttributePropertiesSection.DefaultValueDatetime}}" stepKey="scrollToDefaultValue"/>
5744
<seeInField userInput="{$generateDefaultValue}"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCreateSimpleProductWithDatetimeAttributeTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Datetime product attributes support"/>
14+
<title value="Set datetime attribute to product"/>
15+
<description value="Admin should be able to specify datetime attribute to product and find by them in product grid"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-21461"/>
18+
<group value="catalog"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="createDatetimeAttribute" stepKey="DatetimeProductAttribute"/>
26+
<actionGroup ref="deleteProductBySku" stepKey="deleteCreatedProduct">
27+
<argument name="sku" value="{{_defaultProduct.sku}}"/>
28+
</actionGroup>
29+
<actionGroup ref="logout" stepKey="logout"/>
30+
</after>
31+
32+
<!-- Generate default value -->
33+
<generateDate date="now" format="m/j/Y g:i A" stepKey="generateDefaultValue"/>
34+
<generateDate date="now" format="M j, Y g:i:00 A" stepKey="generateDefaultGridValue"/>
35+
<generateDate date="+1 minute" format="m/j/Y g:i A" stepKey="generateFilterToDate"/>
36+
<!-- Create new datetime product attribute -->
37+
<createData entity="DatetimeProductAttribute" stepKey="createDatetimeAttribute">
38+
<field key="default_value">{$generateDefaultValue}</field>
39+
</createData>
40+
<!-- Open the new simple product page -->
41+
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="openNewProductPage"/>
42+
<actionGroup ref="fillMainProductForm" stepKey="fillDefaultProductFields"/>
43+
<!-- Add datetime attribute -->
44+
<actionGroup ref="addProductAttributeInProductModal" stepKey="addDatetimeAttribute">
45+
<argument name="attributeCode" value="$createDatetimeAttribute.attribute_code$"/>
46+
</actionGroup>
47+
<!-- Check default value -->
48+
<scrollTo selector="{{AdminProductAttributesSection.sectionHeader}}" stepKey="goToAttributesSection"/>
49+
<click selector="{{AdminProductAttributesSection.sectionHeader}}" stepKey="openAttributesSection"/>
50+
<waitForElementVisible selector="{{AdminProductAttributesSection.attributeTextInputByCode($createDatetimeAttribute.attribute_code$)}}" stepKey="waitForSlideOutAttributes"/>
51+
<seeInField selector="{{AdminProductAttributesSection.attributeTextInputByCode($createDatetimeAttribute.attribute_code$)}}" userInput="$generateDefaultValue" stepKey="checkDefaultValue"/>
52+
<!-- Save the product -->
53+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
54+
<!-- Check datetime grid filter -->
55+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToAdminProductIndexPage"/>
56+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
57+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
58+
<fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeFrom($createDatetimeAttribute.attribute_code$)}}" userInput="{$generateDefaultValue}" stepKey="fillProductDatetimeFromFilter"/>
59+
<fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeTo($createDatetimeAttribute.attribute_code$)}}" userInput="{$generateFilterToDate}" stepKey="fillProductDatetimeToFilter"/>
60+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
61+
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad"/>
62+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="{{_defaultProduct.name}}" stepKey="checkAppliedDatetimeFilter"/>
63+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="{$generateDefaultGridValue}" stepKey="checkDefaultValueInGrid"/>
64+
</test>
65+
</tests>

0 commit comments

Comments
 (0)