Skip to content

Commit effb3ba

Browse files
committed
MC-15845: Samples of Downloadable Products are not accessible, if product is disabled
1 parent 70d2287 commit effb3ba

9 files changed

+220
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontOpenDownloadableLinkActionGroup">
12+
<arguments>
13+
<argument name="linkId" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{StorefrontDownloadableLinkPage.url(linkId)}}" stepKey="openDownloadableLink"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontOpenDownloadableSampleActionGroup">
12+
<arguments>
13+
<argument name="sampleId" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{StorefrontDownloadableSamplePage.url(sampleId)}}" stepKey="openDownloadableSample"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Downloadable/Test/Mftf/Data/LinkData.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
<data key="file_type">URL</data>
6464
<data key="file">https://static.magento.com/sites/all/themes/mag_redesign/images/magento-logo.svg</data>
6565
</entity>
66+
<entity name="DownloadableSample" type="downloadable_sample">
67+
<data key="title" unique="suffix">downloadableSampleUrl</data>
68+
<data key="sort_order">1</data>
69+
<data key="sample_type">url</data>
70+
<data key="sample_url">http://example.com</data>
71+
</entity>
6672
<entity name="ApiDownloadableLink" type="downloadable_link">
6773
<data key="title" unique="suffix">Api Downloadable Link</data>
6874
<data key="price">2.00</data>
@@ -72,4 +78,4 @@
7278
<data key="sort_order">0</data>
7379
<data key="link_url">https://static.magento.com/sites/all/themes/mag_redesign/images/magento-logo.svg</data>
7480
</entity>
75-
</entities>
81+
</entities>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
11+
<operation name="CreateDownloadableSample" dataType="downloadable_sample" type="create" auth="adminOauth" url="/V1/products/{sku}/downloadable-links/samples" method="POST">
12+
<contentType>application/json</contentType>
13+
<object dataType="downloadable_sample" key="sample">
14+
<field key="title">string</field>
15+
<field key="sort_order">integer</field>
16+
<field key="sample_type">string</field>
17+
<field key="sample_file">string</field>
18+
<field key="sample_file_content">sample_file_content</field>
19+
<field key="sample_url">string</field>
20+
</object>
21+
<field key="isGlobalScopeContent">boolean</field>
22+
</operation>
23+
</operations>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="StorefrontDownloadableLinkPage" url="downloadable/download/linkSample/link_id/{{id}}/" area="storefront" module="Magento_Downloadable" parameterized="true">
12+
</page>
13+
</pages>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="StorefrontDownloadableSamplePage" url="downloadable/download/sample/sample_id/{{id}}/" area="storefront" module="Magento_Downloadable" parameterized="true">
12+
</page>
13+
</pages>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="StorefrontProductPage" url="/{{var1}}.html" area="storefront" module="Magento_Catalog" parameterized="true">
12+
<section name="StorefrontDownloadableProductSection" />
13+
</page>
14+
</pages>

app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
<element name="downloadableLinkBlock" type="text" selector="//div[contains(@class, 'field downloads required')]//span[text()='Downloadable Links']"/>
1313
<element name="downloadableLinkLabel" type="text" selector="//label[contains(., '{{title}}')]" parameterized="true" timeout="30"/>
1414
<element name="downloadableLinkByTitle" type="input" selector="//*[@id='downloadable-links-list']/*[contains(.,'{{title}}')]//input" parameterized="true" timeout="30"/>
15+
<element name="downloadableLinkSampleByTitle" type="text" selector="//label[contains(., '{{title}}')]/a[contains(@class, 'sample link')]" parameterized="true"/>
16+
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
1517
</section>
1618
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="VerifyDisableDownloadableProductSamplesAreNotAccessibleTest">
12+
<annotations>
13+
<features value="Downloadable"/>
14+
<stories value="Downloadable product"/>
15+
<title value="Samples of Downloadable Products are not accessible, if product is disabled"/>
16+
<description value="Samples of Downloadable Products are not accessible, if product is disabled"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-15845"/>
19+
<useCaseId value="MC-14824"/>
20+
<group value="downloadable"/>
21+
<group value="catalog"/>
22+
</annotations>
23+
<before>
24+
<!-- Create category -->
25+
<createData entity="_defaultCategory" stepKey="createCategory"/>
26+
27+
<!-- Create downloadable product -->
28+
<createData entity="DownloadableProductWithOneLink" stepKey="createProduct">
29+
<requiredEntity createDataKey="createCategory"/>
30+
</createData>
31+
32+
<!-- Add downloadable link -->
33+
<createData entity="downloadableLink1" stepKey="addDownloadableLink">
34+
<requiredEntity createDataKey="createProduct"/>
35+
</createData>
36+
37+
<!-- Add downloadable sample -->
38+
<createData entity="DownloadableSample" stepKey="addDownloadableSample">
39+
<requiredEntity createDataKey="createProduct"/>
40+
</createData>
41+
</before>
42+
<after>
43+
<!-- Delete product -->
44+
<deleteData createDataKey="createProduct" stepKey="deleteDownloadableProduct"/>
45+
46+
<!-- Delete category -->
47+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
48+
49+
<!-- Admin logout -->
50+
<actionGroup ref="logout" stepKey="adminLogout"/>
51+
</after>
52+
53+
<!-- Open Downloadable product from precondition on Storefront -->
54+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage">
55+
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
56+
</actionGroup>
57+
58+
<!-- Sample url is accessible -->
59+
<actionGroup ref="AssertStorefrontSeeElementActionGroup" stepKey="seeDownloadableSample">
60+
<argument name="selector" value="{{StorefrontDownloadableProductSection.downloadableSampleLabel(DownloadableSample.title)}}"/>
61+
</actionGroup>
62+
<click selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(DownloadableSample.title)}}" stepKey="clickDownloadableSample"/>
63+
64+
<!-- Grab Sample id -->
65+
<switchToNextTab stepKey="switchToSampleTab"/>
66+
<grabFromCurrentUrl regex="~/sample_id/(\d+)/~" stepKey="grabDownloadableSampleId"/>
67+
<closeTab stepKey="closeSampleTab"/>
68+
69+
<!-- Link Sample url is accessible -->
70+
<actionGroup ref="AssertStorefrontSeeElementActionGroup" stepKey="seeDownloadableLink">
71+
<argument name="selector" value="{{StorefrontDownloadableProductSection.downloadableLinkLabel(downloadableLink1.title)}}"/>
72+
</actionGroup>
73+
<click selector="{{StorefrontDownloadableProductSection.downloadableLinkSampleByTitle(downloadableLink1.title)}}" stepKey="clickDownloadableLinkSample"/>
74+
75+
<!-- Grab Link Sample id -->
76+
<switchToNextTab stepKey="switchToLinkSampleTab"/>
77+
<grabFromCurrentUrl regex="~/link_id/(\d+)/~" stepKey="grabDownloadableLinkId"/>
78+
<closeTab stepKey="closeLinkSampleTab"/>
79+
80+
<!-- Login as admin -->
81+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
82+
83+
<!-- Open Downloadable product from precondition -->
84+
<actionGroup ref="goToProductPageViaID" stepKey="openProductEditPage">
85+
<argument name="productId" value="$createProduct.id$"/>
86+
</actionGroup>
87+
88+
<!-- Change status of product to "Disable" and save it -->
89+
<actionGroup ref="AdminSetProductDisabled" stepKey="disableProduct"/>
90+
<actionGroup ref="saveProductForm" stepKey="clickSaveProduct"/>
91+
92+
<!-- Assert product is disable on Storefront -->
93+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="openProductPage">
94+
<argument name="category" value="$createCategory$"/>
95+
</actionGroup>
96+
<see selector="{{StorefrontCategoryMainSection.emptyProductMessage}}" userInput="We can't find products matching the selection." stepKey="seeEmptyProductMessage"/>
97+
98+
<!-- Navigate to Link Sample url on Storefront -->
99+
<actionGroup ref="StorefrontOpenDownloadableLinkActionGroup" stepKey="openDownloadableLinkSample">
100+
<argument name="linkId" value="{$grabDownloadableLinkId}"/>
101+
</actionGroup>
102+
103+
<!-- Link Sample url is not accessible. You are redirected to Home Page -->
104+
<seeInCurrentUrl url="{{StorefrontHomePage.url}}" stepKey="seeRedirectToHomePage"/>
105+
106+
<!-- Navigate to Sample url on Storefront -->
107+
<actionGroup ref="StorefrontOpenDownloadableSampleActionGroup" stepKey="openDownloadableSample">
108+
<argument name="sampleId" value="{$grabDownloadableSampleId}"/>
109+
</actionGroup>
110+
111+
<!-- Sample url is not accessible. You are redirected to Home Page -->
112+
<seeInCurrentUrl url="{{StorefrontHomePage.url}}" stepKey="seeHomePage"/>
113+
</test>
114+
</tests>

0 commit comments

Comments
 (0)