Skip to content

Commit 5aaacbd

Browse files
authored
ENGCOM-7091: MFTF: Rename and rewrite Test that fake expired session #27277
2 parents faab855 + 09a56b9 commit 5aaacbd

8 files changed

+106
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="AddSimpleProductToCartActionGroup">
11+
<actionGroup name="AddSimpleProductToCartActionGroup" deprecated="Avoid using super-ActionGroups. Use StorefrontOpenProductEntityPageActionGroup, StorefrontAddSimpleProductToCartActionGroup and StorefrontAssertProductAddedToCartResultMessageActionGroup">
1212
<annotations>
1313
<description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description>
1414
</annotations>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontOpenProductEntityPageActionGroup">
11+
<annotations>
12+
<description>Opens Storefront Product page for the provided Product Entity</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="product" type="entity"/>
16+
</arguments>
17+
18+
<amOnPage url="{{StorefrontProductPage.url(product.custom_attributes[url_key])}}" stepKey="goToProductPage"/>
19+
<waitForPageLoad stepKey="waitForProductPageLoaded"/>
20+
</actionGroup>
21+
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontAssertProductAddToCartErrorMessageActionGroup">
11+
<arguments>
12+
<argument name="message" type="string" defaultValue=""/>
13+
</arguments>
14+
<waitForElementVisible selector="{{StorefrontMessagesSection.error}}" time="10" stepKey="waitForProductAddedMessage"/>
15+
<see selector="{{StorefrontMessagesSection.error}}" userInput="{{message}}" stepKey="seeAddToCartErrorMessage"/>
16+
</actionGroup>
17+
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontAssertProductAddToCartSuccessMessageActionGroup">
11+
<arguments>
12+
<argument name="message" type="string" defaultValue=""/>
13+
</arguments>
14+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" time="30" stepKey="waitForProductAddedMessage"/>
15+
<see selector="{{StorefrontMessagesSection.success}}" userInput="message" stepKey="seeAddToCartSuccessMessage"/>
16+
</actionGroup>
17+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontProductPageAddSimpleProductToCartActionGroup">
11+
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addToCart"/>
12+
<waitForElementVisible selector="{{StorefrontProductActionSection.addToCartButtonTitleIsAddToCart}}" stepKey="waitForElementVisibleAddToCartButtonTitleIsAddToCart"/>
13+
<waitForPageLoad stepKey="waitForPageLoad"/>
14+
</actionGroup>
15+
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontFakeBrokenSessionActionGroup">
11+
<resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/>
12+
<resetCookie userInput="form_key" stepKey="resetCookieForCart2"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Test/AddingProductWithExpiredSessionTest.xml renamed to app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddProductToCartWithExpiredSessionTest.xml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10-
<test name="AddingProductWithExpiredSessionTest">
10+
<test name="StorefrontAddProductToCartWithExpiredSessionTest">
1111
<annotations>
1212
<title value="Adding a product to cart from category page with an expired session"/>
1313
<description value="Adding a product to cart from category page with an expired session"/>
@@ -23,24 +23,20 @@
2323
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
2424
<requiredEntity createDataKey="createCategory"/>
2525
</createData>
26+
<magentoCron stepKey="runCronReindex" groups="index"/>
2627
</before>
27-
28-
<!--Navigate to a category page -->
29-
<amOnPage url="$$createSimpleProduct.name$$.html" stepKey="goToProductPage"/>
30-
<waitForPageLoad stepKey="waitForPageLoad"/>
31-
32-
<!-- Remove PHPSESSID and form_key to replicate an expired session-->
33-
<resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/>
34-
<resetCookie userInput="form_key" stepKey="resetCookieForCart2"/>
35-
36-
<!-- "Add to Cart" any product-->
37-
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addToCart"/>
38-
<see stepKey="assertErrorMessage" userInput="Your session has expired"/>
3928
<after>
40-
<!--Delete created product-->
4129
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
4230
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
4331
</after>
4432

33+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPage">
34+
<argument name="product" value="$$createSimpleProduct$$"/>
35+
</actionGroup>
36+
<actionGroup ref="StorefrontFakeBrokenSessionActionGroup" stepKey="fakeBrokenSession"/>
37+
<actionGroup ref="StorefrontProductPageAddSimpleProductToCartActionGroup" stepKey="addProductToCart"/>
38+
<actionGroup ref="StorefrontAssertProductAddToCartErrorMessageActionGroup" stepKey="assertFailure">
39+
<argument name="message" value="Your session has expired"/>
40+
</actionGroup>
4541
</test>
4642
</tests>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AddingProductWithExpiredSessionTest" extends="StorefrontAddProductToCartWithExpiredSessionTest" deprecated="Use StorefrontAddProductToCartWithExpiredSessionTest"/>
11+
</tests>

0 commit comments

Comments
 (0)