Skip to content

Commit f7c882f

Browse files
committed
ACQE-8277: Use empty file as a Custom Option of File type
- New Test case added
1 parent 536edc2 commit f7c882f

File tree

7 files changed

+118
-0
lines changed

7 files changed

+118
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<actionGroups
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="VerifyErrorMessageDisplayedWhileAddingProductWithEmptyFileToCartActionGroup" extends="AddToCartFromStorefrontProductPageActionGroup">
12+
<arguments>
13+
<argument name="productName" type="string"/>
14+
</arguments>
15+
<remove keyForRemoval="waitForSuccessMessage"/>
16+
<remove keyForRemoval="seeAddToCartSuccessMessage"/>
17+
<waitForText selector="{{StorefrontProductInfoMainSection.customEmptyFileValidationMessage}}" userInput="{{EmptyFilesAndValidationMessage.fileValidationMessage}}" stepKey="verify"/>
18+
</actionGroup>
19+
</actionGroups>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,4 +1604,9 @@
16041604
<requiredEntity type="product_option">ProductOptionField20</requiredEntity>
16051605
<requiredEntity type="product_option">ProductOptionField21</requiredEntity>
16061606
</entity>
1607+
<entity name="EmptyFilesAndValidationMessage">
1608+
<data key="file1">emptyTxtFile.txt</data>
1609+
<data key="file2">emptyPngFile.png</data>
1610+
<data key="fileValidationMessage">The file is empty. Select another file and try again.</data>
1611+
</entity>
16071612
</entities>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,14 @@
447447
<requiredEntity type="product_option_value">ProductValueCheckbox1</requiredEntity>
448448
<requiredEntity type="product_option_value">ProductValueCheckbox2</requiredEntity>
449449
</entity>
450+
<entity name="ProductOptionTextFile" type="product_option">
451+
<var key="product_sku" entityType="product" entityKey="sku" />
452+
<data key="title">OptionFile</data>
453+
<data key="type">file</data>
454+
<data key="is_require">true</data>
455+
<data key="sort_order">3</data>
456+
<data key="price">9.99</data>
457+
<data key="price_type">fixed</data>
458+
<data key="file_extension">txt</data>
459+
</entity>
450460
</entities>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@
117117
<element name="productCalenderButton" type="button" selector="//*[@id='product-options-wrapper']/div/div/fieldset/div/button" />
118118
<element name="productCalenderGoToday" type="button" selector="//*[@id='ui-datepicker-div']/div[2]/button[1]" />
119119
<element name="customDateField" type="text" selector='//*[@class="product-custom-option datetime-picker input-text _has-datepicker"]' />
120+
<element name="customEmptyFileValidationMessage" type="text" selector="//div[@data-ui-id='message-error']/div"/>
120121
</section>
121122
</sections>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<tests
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StoreFrontUseEmptyFileAsACustomOptionOfFileTypeTest">
12+
<annotations>
13+
<stories value="Empty file as a custom option for the file type"/>
14+
<title value="Product custom options"/>
15+
<description value="Verify the validation of an empty file as a custom option for the file type."/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="AC-3848"/>
18+
<group value="catalog"/>
19+
</annotations>
20+
<before>
21+
<!-- Pre-condition 1:Create Simple Product -->
22+
<createData entity="defaultSimpleProduct" stepKey="initialSimpleProduct"/>
23+
<!-- Login As Admin -->
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<!-- Delete product, Logout from Admin -->
28+
<deleteData createDataKey="initialSimpleProduct" stepKey="deleteSimpleProduct"/>
29+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
30+
</after>
31+
<!-- Step1: Open a product page in Admin and Open Customizable options tab.-->
32+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductForEdit">
33+
<argument name="productId" value="$initialSimpleProduct.id$"/>
34+
</actionGroup>
35+
<!-- Open custom option panel -->
36+
<click selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" stepKey="openCustomizableOptions"/>
37+
<waitForPageLoad stepKey="waitForCustomOptionsOpen"/>
38+
<!-- Step2: Add Custom file option -->
39+
<actionGroup ref="AddProductCustomOptionFileActionGroup" stepKey="addFileOption">
40+
<argument name="option" value="ProductOptionTextFile"/>
41+
</actionGroup>
42+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
43+
<!-- Step3: Open the product on Storefront -->
44+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
45+
<argument name="productUrl" value="$$initialSimpleProduct.custom_attributes[url_key]$$"/>
46+
</actionGroup>
47+
<!-- Step4: Upload an empty file -->
48+
<actionGroup ref="StorefrontAttachOptionFileActionGroup" stepKey="selectAndAttachFile">
49+
<argument name="file" value="EmptyFilesAndValidationMessage.file1" />
50+
</actionGroup>
51+
<!--Step4: Verify An error should be displayed when adding to cart -->
52+
<actionGroup ref="VerifyErrorMessageDisplayedWhileAddingProductWithEmptyFileToCartActionGroup" stepKey="addProductToCart">
53+
<argument name="productName" value="$initialSimpleProduct.name$"/>
54+
</actionGroup>
55+
<!-- Open product in admin and delete existing custom option-->
56+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductEditPage">
57+
<argument name="productId" value="$initialSimpleProduct.id$"/>
58+
</actionGroup>
59+
<!-- Open custom option panel -->
60+
<click selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" stepKey="openCustomizableOption"/>
61+
<waitForPageLoad stepKey="waitForCustomOptionOpen"/>
62+
<actionGroup ref="AdminDeleteProductCustomOptionActionGroup" stepKey="deleteCustomOptionFile">
63+
<argument name="option" value="ProductOptionTextFile"/>
64+
</actionGroup>
65+
<!-- Step5: Add a new custom option of File type that accepts only images-->
66+
<actionGroup ref="AddProductCustomOptionFileActionGroup" stepKey="addFileOptions">
67+
<argument name="option" value="ProductOptionFile"/>
68+
</actionGroup>
69+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveTheProduct"/>
70+
<!-- Step6: Open Product page in storeFront -->
71+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openTheProductPage">
72+
<argument name="productUrl" value="$$initialSimpleProduct.custom_attributes[url_key]$$"/>
73+
</actionGroup>
74+
<!--Step7: Upload an empty image -->
75+
<actionGroup ref="StorefrontAttachOptionFileActionGroup" stepKey="selectAndAttachTheFile">
76+
<argument name="file" value="EmptyFilesAndValidationMessage.file2" />
77+
</actionGroup>
78+
<!-- Step7: Verify An error should be displayed when adding to cart -->
79+
<actionGroup ref="VerifyErrorMessageDisplayedWhileAddingProductWithEmptyFileToCartActionGroup" stepKey="addTheProductToCart">
80+
<argument name="productName" value="$initialSimpleProduct.name$"/>
81+
</actionGroup>
82+
</test>
83+
</tests>

dev/tests/acceptance/tests/_data/emptyPngFile.png

Loading

dev/tests/acceptance/tests/_data/emptyTxtFile.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)