Skip to content

Commit 0c87a0c

Browse files
committed
ACP2E-4060: Date Attribute in custom Attribute Group Fails to Show Datepicker in Admin
1 parent 014cc04 commit 0c87a0c

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertElementVisibleOnScreenActionGroup">
12+
<annotations>
13+
<description>Asserts that an element is fully visible on screen within viewport bounds, not just present in DOM</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="selector" type="string"/>
17+
</arguments>
18+
19+
<executeJS function="
20+
var element = document.querySelector('{{selector}}');
21+
if (!element) {
22+
return 'Element not found in DOM';
23+
}
24+
25+
var rect = element.getBoundingClientRect();
26+
var windowHeight = window.innerHeight;
27+
var windowWidth = window.innerWidth;
28+
29+
var isVisible = rect.top &gt;= 0 &amp;&amp;
30+
rect.left &gt;= 0 &amp;&amp;
31+
rect.bottom &lt;= windowHeight &amp;&amp;
32+
rect.right &lt;= windowWidth;
33+
34+
return isVisible ? 'Element is visible on screen' : 'Element is positioned off-screen';
35+
" stepKey="checkElementVisibility"/>
36+
37+
<assertStringContainsString stepKey="assertElementIsVisible">
38+
<expectedResult type="string">Element is visible on screen</expectedResult>
39+
<actualResult type="variable">$checkElementVisibility</actualResult>
40+
</assertStringContainsString>
41+
</actionGroup>
42+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
<element name="customSwitcherAttribute" type="checkbox" selector="//input[@name='product[{{attribute_code}}]' and @value='{{checked_value}}']/parent::div[@data-role='switcher']" parameterized="true"/>
9494
<element name="attributeOptionUncheckDefaultValue" type="checkbox" selector="input[name='use_default[{{attribute_code}}]']" parameterized="true"/>
9595
<element name="customAttributeUnderMassUpdate" type="select" selector="//select[@name='attributes[{{attribute_code}}][]']" parameterized="true"/>
96+
<element name="datePickerCalendar" type="button" selector="//div[{{row}}]//button[contains(@class, 'ui-datepicker-trigger')]" parameterized="true"/>
9697
</section>
9798
</sections>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminDateAttributeCalendarPositioningTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="ACP2E-4060: Date Attribute in custom Attribute Group Fails to Show Datepicker in Admin"/>
15+
<title value="Date attribute calendar should appear in correct position when assigned to attribute group"/>
16+
<description value="Verify that date attributes assigned to custom attribute groups display the calendar widget in the correct position relative to the input field"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="AC-15180"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
25+
<!-- Create a new date attribute -->
26+
<createData entity="dateProductAttribute" stepKey="attribute"/>
27+
28+
<!-- Go to default attribute set edit page -->
29+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
30+
31+
<!-- Assert created attribute in unassigned section -->
32+
<see userInput="$$attribute.attribute_code$$" selector="{{AdminProductAttributeSetEditSection.unassignedAttributesTree}}" stepKey="seeAttributeInUnassigned"/>
33+
34+
<!-- Assign the date attribute to the new group -->
35+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
36+
<argument name="group" value="Design"/>
37+
<argument name="attribute" value="$$attribute.attribute_code$$"/>
38+
</actionGroup>
39+
40+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>
41+
42+
<!-- Create a simple product for testing -->
43+
<createData entity="SimpleProduct" stepKey="createSimpleProduct"/>
44+
</before>
45+
46+
<after>
47+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
48+
<deleteData createDataKey="attribute" stepKey="deleteAttribute"/>
49+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
50+
</after>
51+
52+
<!-- Navigate to the product edit page -->
53+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex"/>
54+
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterProductGridBySku">
55+
<argument name="product" value="$$createSimpleProduct$$"/>
56+
</actionGroup>
57+
<click selector="{{AdminProductGridSection.productRowBySku($$createSimpleProduct.sku$$)}}" stepKey="openProduct"/>
58+
<waitForPageLoad stepKey="waitForProductToLoad"/>
59+
60+
<!-- Verify the date attribute is visible in the custom group -->
61+
<conditionalClick selector="{{AdminProductGridSection.productCollapsibleColumns('closed','Design')}}" dependentSelector="{{AdminProductGridSection.productCollapsibleColumns('closed','Design')}}" visible="true" stepKey="expandDesign"/>
62+
63+
<!-- Click on the date input field to trigger the calendar -->
64+
<click selector="{{AdminProductFormSection.datePickerCalendar('1')}}" stepKey="clickDatePickerTrigger"/>
65+
66+
<!-- Assert that the calendar is fully visible on screen -->
67+
<actionGroup ref="AssertElementVisibleOnScreenActionGroup" stepKey="assertCalendarVisibleOnScreen">
68+
<argument name="selector" value=".ui-datepicker"/>
69+
</actionGroup>
70+
</test>
71+
</tests>

0 commit comments

Comments
 (0)