Skip to content

Commit f3af713

Browse files
committed
MAGETWO-92952: Automate with MFTF adding Product images of different types and sizes
1 parent 5623b1b commit f3af713

File tree

5 files changed

+46
-29
lines changed

5 files changed

+46
-29
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminProductCheckUnsupportedFileActionGroup">
12+
<arguments>
13+
<argument name="filename" type="string"/>
14+
</arguments>
15+
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="{{filename}}" stepKey="attachImage"/>
16+
<waitForPageLoad stepKey="waitForUploadImage"/>
17+
<see selector="{{AdminConfirmationModalSection.message}}" userInput="We don't recognize or support this file extension type." stepKey="seeErrorMessage"/>
18+
<click selector="{{AdminProductImagesSection.modalOkBtn}}" stepKey="closeModal"/>
19+
</actionGroup>
20+
</actionGroups>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
<element name="checkbox" type="checkbox" selector="//div[contains(text(),'{{product}}')]/ancestor::tr[@class='data-row']//input[@class='admin__control-checkbox']" parameterized="true" />
2525
<element name="bulkActionOption" type="button" selector="//div[contains(@class,'admin__data-grid-header-row') and contains(@class, 'row')]//div[contains(@class, 'action-select-wrap')]//ul/li/span[text() = '{{label}}']" parameterized="true"/>
2626
<element name="productGridNameProduct" type="input" selector="//tbody//tr//td//div[contains(., '{{var1}}')]" parameterized="true" timeout="30"/>
27-
<element name="adminImgGridThumbnail" type="text" selector="img.admin__control-thumbnail[src*='/{{var1}}']" timeout="30" parameterized="true"/>
27+
<element name="adminImgGridThumbnail" type="text" selector="img.admin__control-thumbnail[src*='/{{var1}}']" parameterized="true"/>
2828
</section>
2929
</sections>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductMessagesSection">
1212
<element name="successMessage" type="text" selector=".message-success"/>
13-
<element name="attentionMessage" type="text" selector="aside.modal-popup.confirm .modal-content div"/>
1413
</section>
1514
</sections>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontProductMediaSection">
12-
<element name="imageFile" type="text" selector="//*[@class='product media']//img[contains(@src, '{{filename}}')]" parameterized="true"/>
12+
<element name="imageFile" type="text" selector=".product.media img[src*='{{filename}}']" parameterized="true"/>
1313
</section>
1414
</sections>

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

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<deleteData createDataKey="category" stepKey="deletePreReqCategory"/>
3535
<deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/>
3636
<deleteData createDataKey="secondProduct" stepKey="deleteSecondProduct"/>
37-
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
37+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
3838
</after>
3939

4040
<!-- Go to the first product edit page -->
@@ -55,63 +55,60 @@
5555
<click selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="expandImages"/>
5656

5757
<!-- *.bmp is not allowed -->
58-
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="bmp.bmp" stepKey="attachBmp"/>
59-
<waitForPageLoad stepKey="waitForUploadBmp"/>
60-
<see selector="{{AdminProductMessagesSection.attentionMessage}}" userInput="We don't recognize or support this file extension type." stepKey="seeErrorBmp"/>
61-
<click selector="{{AdminProductImagesSection.modalOkBtn}}" stepKey="closeModalBmp"/>
58+
<actionGroup ref="AdminProductCheckUnsupportedFileActionGroup" stepKey="attachBmp">
59+
<argument name="filename" value="bmp.bmp"/>
60+
</actionGroup>
6261

6362
<!-- *.ico is not allowed -->
64-
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="ico.ico" stepKey="attachIco"/>
65-
<waitForPageLoad stepKey="waitForUploadIco"/>
66-
<see selector="{{AdminProductMessagesSection.attentionMessage}}" userInput="We don't recognize or support this file extension type." stepKey="seeErrorIco"/>
67-
<click selector="{{AdminProductImagesSection.modalOkBtn}}" stepKey="closeModalIco"/>
63+
<actionGroup ref="AdminProductCheckUnsupportedFileActionGroup" stepKey="attachIco">
64+
<argument name="filename" value="ico.ico"/>
65+
</actionGroup>
6866

6967
<!-- *.svg is not allowed -->
70-
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="svg.svg" stepKey="attachSvg"/>
71-
<waitForPageLoad stepKey="waitForUploadSvg"/>
72-
<see selector="{{AdminProductMessagesSection.attentionMessage}}" userInput="We don't recognize or support this file extension type." stepKey="seeErrorSvg"/>
73-
<click selector="{{AdminProductImagesSection.modalOkBtn}}" stepKey="closeModalSvg"/>
68+
<actionGroup ref="AdminProductCheckUnsupportedFileActionGroup" stepKey="attachSvg">
69+
<argument name="filename" value="svg.svg"/>
70+
</actionGroup>
71+
7472

7573
<!-- 0kb size is not allowed -->
76-
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="empty.jpg" stepKey="attachEmpty"/>
77-
<waitForPageLoad stepKey="waitForUploadEmpty"/>
78-
<see selector="{{AdminProductMessagesSection.attentionMessage}}" userInput="We don't recognize or support this file extension type." stepKey="seeErrorEmpty"/>
79-
<click selector="{{AdminProductImagesSection.modalOkBtn}}" stepKey="closeModalEmpty"/>
74+
<actionGroup ref="AdminProductCheckUnsupportedFileActionGroup" stepKey="attachEmpty">
75+
<argument name="filename" value="empty.jpg"/>
76+
</actionGroup>
8077

8178
<!-- 1~ kb is allowed -->
8279
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="small.jpg" stepKey="attachSmall"/>
8380
<waitForPageLoad stepKey="waitForUploadSmall"/>
84-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorSmall"/>
81+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorSmall"/>
8582

8683
<!-- 1~ mb is allowed -->
8784
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="medium.jpg" stepKey="attachMedium"/>
8885
<waitForPageLoad stepKey="waitForUploadMedium"/>
89-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorMedium"/>
86+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorMedium"/>
9087

9188
<!-- 10~ mb is allowed -->
9289
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="large.jpg" stepKey="attachLarge"/>
9390
<waitForPageLoad stepKey="waitForUploadLarge"/>
94-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorLarge"/>
91+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorLarge"/>
9592

9693
<!-- *.gif is allowed -->
9794
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="gif.gif" stepKey="attachGif"/>
9895
<waitForPageLoad stepKey="waitForUploadGif"/>
99-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorGif"/>
96+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorGif"/>
10097

10198
<!-- *.jpg is allowed -->
10299
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="jpg.jpg" stepKey="attachJpg"/>
103100
<waitForPageLoad stepKey="waitForUploadJpg"/>
104-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorJpg"/>
101+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorJpg"/>
105102

106103
<!-- *.png is allowed -->
107104
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="png.png" stepKey="attachPng"/>
108105
<waitForPageLoad stepKey="waitForUploadPng"/>
109-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorPng"/>
106+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorPng"/>
110107

111108
<!-- Save the first product and go to the storefront -->
112109
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
113110
<amOnPage url="$$firstProduct.name$$.html" stepKey="goToStorefront"/>
114-
<waitForPageLoad stepKey="waitForStorefront"/>
111+
<waitForPageLoad stepKey="waitForStorefront1"/>
115112

116113
<!-- See all of the images that we uploaded -->
117114
<seeElementInDOM selector="{{StorefrontProductMediaSection.imageFile('small')}}" stepKey="seeSmall"/>
@@ -140,7 +137,7 @@
140137
<click selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="expandImages2"/>
141138
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="large.jpg" stepKey="attachLarge2"/>
142139
<waitForPageLoad stepKey="waitForUploadLarge2"/>
143-
<dontSeeElement selector="{{AdminProductMessagesSection.attentionMessage}}" stepKey="dontSeeErrorLarge2"/>
140+
<dontSeeElement selector="{{AdminConfirmationModalSection.message}}" stepKey="dontSeeErrorLarge2"/>
144141

145142
<!-- Set url key -->
146143
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection2"/>
@@ -160,11 +157,12 @@
160157

161158
<!-- Go to the category page and see the uploaded image -->
162159
<amOnPage url="$$category.name$$.html" stepKey="goToCategoryPage2"/>
160+
<waitForPageLoad stepKey="waitForStorefront2"/>
163161
<seeElement selector="{{StorefrontCategoryMainSection.categoryPageProductImage('large')}}" stepKey="seeUploadedImg"/>
164162

165163
<!-- Go to the product page and see the uploaded image -->
166164
<amOnPage url="$$secondProduct.name$$.html" stepKey="goToStorefront2"/>
167-
<waitForPageLoad stepKey="waitForStorefront2"/>
165+
<waitForPageLoad stepKey="waitForStorefront3"/>
168166
<seeElementInDOM selector="{{StorefrontProductMediaSection.imageFile('large')}}" stepKey="seeLarge2"/>
169167
</test>
170168
</tests>

0 commit comments

Comments
 (0)