Skip to content

Commit 9d204cf

Browse files
MAGETWO-66666: Adding a product to cart from category page with an expired session does not allow product to be added
- Added automated test
1 parent 09def5e commit 9d204cf

File tree

3 files changed

+196
-0
lines changed

3 files changed

+196
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<!--Go To Products page-->
12+
<actionGroup name="GoToProductPage">
13+
<click selector="{{GoToProductPageSection.catalog}}" stepKey="clickOnCatalog" />
14+
<waitForPageLoad stepKey="waitForPage"/>
15+
<click selector="{{GoToProductPageSection.product}}" stepKey="clickToSelectProductsItem" />
16+
<waitForPageLoad stepKey="waitForPageProducts"/>
17+
</actionGroup>
18+
19+
<!--Create Simple product-->
20+
<actionGroup name="AdminCreateSimpleProduct">
21+
<click selector="{{GoToProductPageSection.add}}" stepKey="clickToAddProduct"/>
22+
<waitForPageLoad stepKey="WaitForProductPageIsLoaded"/>
23+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{SimpleProductOne.name}}" stepKey="setNameForProduct"/>
24+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{SimpleProductOne.sku}}" stepKey="setSKUForProduct"/>
25+
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{SimpleProductOne.price}}" stepKey="setPriceForProduct"/>
26+
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{SimpleProductOne.quantity}}" stepKey="setQuantityForProduct"/>
27+
<click selector="{{AdminProductFormSection.searchOptimization}}" stepKey="clickOnSearchEngineOptimization"/>
28+
<fillField selector="{{AdminProductFormSection.urlKey}}" userInput="{{SimpleProductOne.urlKey}}" stepKey="setSearchUrlForProduct"/>
29+
<click selector="{{AdminProductFormSection.saveButton}}" stepKey="clickSaveProduct"/>
30+
<waitForPageLoad stepKey="WaitForProductSave"/>
31+
<see userInput="You saved the product." stepKey="seeSaveConfirmation"/>
32+
</actionGroup>
33+
34+
35+
<actionGroup name="FindAndAddProductToCardActionGroup">
36+
<arguments>
37+
<argument name="product" defaultValue="SimpleProductOne"/>
38+
</arguments>
39+
40+
<click selector="{{StorefrontAddProductToCartSection.addToCartBtn}}" stepKey="addToCart"/>
41+
<waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" time="30" stepKey="waitForProductAdded"/>
42+
<click selector="{{StorefrontAddProductToCartSection.showCard}}" stepKey="clickToOpenCard"/>
43+
<waitForPageLoad stepKey="WaitForFormOpened" time="3"/>
44+
<click selector="{{StorefrontAddProductToCartSection.proceed}}" stepKey="clickToProceedToCheckout"/>
45+
<waitForPageLoad time="5" stepKey="waitForTheFormIsOpened"/>
46+
<see userInput="Shipping Address" stepKey="seeShippingAddress"/>
47+
</actionGroup>
48+
49+
50+
<actionGroup name="AgainGoToProductCategory">
51+
52+
<amOnPage url="/admin" stepKey="GoToDashboard"/>
53+
54+
<click selector="{{GoToProductPageSection.catalog}}" stepKey="clickOnCatalog" />
55+
<waitForPageLoad stepKey="waitForPage"/>
56+
<click selector="{{GoToProductPageSection.product}}" stepKey="clickToSelectProductsItem" />
57+
<waitForPageLoad stepKey="waitForPageProducts"/>
58+
</actionGroup>
59+
60+
<actionGroup name="DeleteCreatedProduct">
61+
62+
<click selector="{{DeleteCreatedProduct.createdProductID(SimpleProductOne.name)}}" stepKey="selectCreatedProduct"/>
63+
<wait stepKey="waitSelectCreatedProduct" time="2"/>
64+
<waitForElementVisible selector="{{DeleteCreatedProduct.actionSelectBox}}" stepKey="waitToSelectActionVisible" time="50"/>
65+
<click stepKey="clickToSelectAction" selector="{{DeleteCreatedProduct.actionSelectBox}}"/>
66+
<wait stepKey="waitClickToSelectAction" time="2"/>
67+
<click selector="{{DeleteCreatedProduct.deleteButton}}" stepKey="clickToDeleteProduct"/>
68+
<wait stepKey="waitClickToDeleteProduct" time="2"/>
69+
<click selector="{{DeleteCreatedProduct.okButton}}" stepKey="clickToConfirm"/>
70+
<wait stepKey="waitClickToConfirmButton" time="2"/>
71+
<see userInput="A total of 1 record(s) have been deleted." stepKey="productDeletedSuccessfully"/>
72+
73+
</actionGroup>
74+
75+
</actionGroups>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontAddProductToCartSection">
12+
<element name="addToCartBtn" type="button" selector="button.action.tocart.primary"/>
13+
<element name="successMsg" type="button" selector="div.message-success"/>
14+
<element name="showCard" type="button" selector=".action.showcart"/>
15+
<element name="proceed" type="button" selector="#top-cart-btn-checkout"/>
16+
17+
</section>
18+
19+
<section name="GoToProductPageSection">
20+
<!--Go to Catalog/Products-->
21+
<element name="catalog" type="button" selector="#menu-magento-catalog-catalog"/>
22+
<element name="product" type="button" selector="//span[contains(text(), 'Products')]"/>
23+
<element name="add" type="button" selector="#add_new_product-button"/>
24+
</section>
25+
26+
<section name="AdminProductFormSection">
27+
<element name="attributeSet" type="select" selector="div[data-index='attribute_set_id'] .admin__field-control"/>
28+
<element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input" timeout="30"/>
29+
<element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/>
30+
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
31+
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
32+
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
33+
<element name="enableProductLabel" type="checkbox" selector="input[name='product[status]']+label"/>
34+
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
35+
<element name="productNameUseDefault" type="checkbox" selector="input[name='use_default[name]']"/>
36+
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
37+
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
38+
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
39+
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
40+
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
41+
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']"/>
42+
<element name="productWeight" type="input" selector=".admin__field[data-index=weight] input"/>
43+
<element name="productWeightSelect" type="select" selector="select[name='product[product_has_weight]']"/>
44+
<element name="contentTab" type="button" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Content']"/>
45+
<element name="fieldError" type="text" selector="//input[@name='product[{{fieldName}}]']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
46+
<element name="priceFieldError" type="text" selector="//input[@name='product[price]']/parent::div/parent::div/label[@class='admin__field-error']"/>
47+
<element name="addAttributeBtn" type="button" selector="#addAttribute"/>
48+
<element name="createNewAttributeBtn" type="button" selector="button[data-index='add_new_attribute_button']"/>
49+
<element name="save" type="button" selector="#save"/>
50+
<element name="attributeTab" type="button" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Attributes']"/>
51+
<element name="attributeLabel" type="input" selector="//input[@name='frontend_label[0]']"/>
52+
<element name="frontendInput" type="select" selector="select[name = 'frontend_input']"/>
53+
<element name="productFormTab" type="button" selector="//strong[@class='admin__collapsible-title']/span[contains(text(), '{{tabName}}')]" parameterized="true"/>
54+
<element name="productFormTabState" type="text" selector="//strong[@class='admin__collapsible-title']/span[contains(text(), '{{tabName}}')]/parent::*/parent::*[@data-state-collapsible='{{state}}']" parameterized="true"/>
55+
<element name="visibility" type="select" selector="//select[@name='product[visibility]']"/>
56+
<element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/>
57+
<element name="divByDataIndex" type="input" selector="div[data-index='{{var}}']" parameterized="true"/>
58+
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
59+
<element name="searchOptimization" type="button" selector="//*[contains(text(),'Search Engine Optimization')]"/>
60+
<element name="urlKey" type="input" selector="//input[contains(@name,'url_key')]"/>
61+
<element name="saveButton" type="button" selector="#save-button"/>
62+
63+
</section>
64+
65+
<section name="DeleteCreatedProduct">
66+
<element name="createdProductID" type="select" selector="//*[@id='container']//*[text()='{{arg1}}']/parent::td/parent::tr//label[contains(@class, 'data-grid-checkbox-cell-inner')]" parameterized="true"/>
67+
<element name="actionSelectBox" type="button" selector="//*[@class='col-xs-2']"/>
68+
<element name="deleteButton" type="button" selector="//*[@class='admin__data-grid-header-row row row-gutter']//*[text()='Delete']"/>
69+
<element name="okButton" type="button" selector=".action-primary.action-accept"/>
70+
</section>
71+
72+
</sections>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AddingProductWithExpiredSessionTest">
12+
<annotations>
13+
<title value="Adding a product to cart from category page with an expired session"/>
14+
<features value="Module/ Catalog"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="MAGETWO-93289"/>
17+
<stories value="MAGETWO-66666: Adding a product to cart from category page with an expired session does not allow product to be added"/>
18+
<group value="customer"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
23+
<actionGroup ref="GoToProductPage" stepKey="goToProductPage"/>
24+
<actionGroup ref="AdminCreateSimpleProduct" stepKey="adminCreateSimpleProduct"/>
25+
</before>
26+
27+
<!--Navigate to a category page -->
28+
<amOnPage url="/{{SimpleProductOne.name}}.html" stepKey="GoToProductPage"/>
29+
30+
<waitForPageLoad stepKey="waitForPageLoad"/>
31+
32+
<!-- Remove PHPSESSID and form_key to replicate an expired session-->
33+
<executeJS function="var delete_cookie = function(name) {
34+
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 UTC; path=/;';};
35+
delete_cookie('PHPSESSID');
36+
delete_cookie('form_key');" stepKey="removeCookies" after="waitForPageLoad"/>
37+
38+
<!-- "Add to Cart" any product-->
39+
<actionGroup ref="FindAndAddProductToCardActionGroup" stepKey="addProductToCard"/>
40+
41+
<after>
42+
<!--Delete created product-->
43+
<actionGroup ref="AgainGoToProductCategory" stepKey="againGoToProductCategory"/>
44+
<wait stepKey="waitForProductPageLoaded" time="3"/>
45+
<actionGroup ref="DeleteCreatedProduct" stepKey="deleteCreatedProduct"/>
46+
</after>
47+
48+
</test>
49+
</tests>

0 commit comments

Comments
 (0)