Skip to content

Frontend customer account order list #28417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CreateCustomerOrderActionGroup">
<annotations>
<description>Create Order via API assigned to Customer.</description>
</annotations>
<arguments>
<argument name="Customer" />
<argument name="Product" />
</arguments>

<createData entity="CustomerCart" stepKey="CustomerCart">
<requiredEntity createDataKey="Customer"/>
</createData>

<createData entity="CustomerCartItem" stepKey="addCartItem">
<requiredEntity createDataKey="CustomerCart"/>
<requiredEntity createDataKey="Product"/>
</createData>

<createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress">
<requiredEntity createDataKey="CustomerCart"/>
</createData>

<updateData createDataKey="CustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation">
<requiredEntity createDataKey="CustomerCart"/>
</updateData>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
<element name="viewOrder" type="button" selector="//td[contains(concat(' ',normalize-space(@class),' '),' col actions ')]/a[contains(concat(' ',normalize-space(@class),' '),' action view ')]"/>
<element name="tabRefund" type="button" selector="//a[text()='Refunds']"/>
<element name="grandTotalRefund" type="text" selector="td[data-th='Grand Total'] > strong > span.price"/>
<element name="currentPage" type="text" selector=".order-products-toolbar .pages .current span:nth-of-type(2)"/>
<element name="pageNumber" type="text" selector="//*[@class='order-products-toolbar toolbar bottom']//a[contains(@class, 'page')]//span[2][contains(text() ,'{{var1}}')]" parameterized="true"/>
<element name="perPage" type="select" selector="//*[@class='order-products-toolbar toolbar bottom']//select[@id='limiter']"/>
<element name="rowsInColumn" type="text" selector="//tbody/tr/td[contains(@class, '{{column}}')]" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontCustomerAccountOrderListTest">
<annotations>
<stories value="Frontend Customer Account Orders list"/>
<title value="Verify that the list of Orders is displayed in the grid after changing the number of items on the page"/>
<description value="Verify that the list of Orders is displayed in the grid after changing the number of items on the page."/>
<severity value="CRITICAL"/>
<testCaseId value="MC-34953"/>
<group value="customer"/>
</annotations>

<before>

<!--Create Product via API-->
<createData entity="SimpleProduct2" stepKey="Product"/>

<!--Create Customer via API-->
<createData entity="Simple_US_Customer" stepKey="Customer"/>

<!--Create Orders via API-->
<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder1">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder2">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder3">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder4">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder5">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder6">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder7">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder8">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder9">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder10">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder11">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder12">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder13">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder14">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>

<actionGroup ref="CreateCustomerOrderActionGroup" stepKey="createCustomerOrder15">
<argument name="Customer" value="Customer"/>
<argument name="Product" value="Product"/>
</actionGroup>
<!--Create Orders via API-->

</before>

<after>
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
<deleteData createDataKey="Product" stepKey="deleteProduct"/>
<deleteData createDataKey="Customer" stepKey="deleteCustomer"/>
</after>

<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefront">
<argument name="Customer" value="$$Customer$$"/>
</actionGroup>

<actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToSidebarMenu">
<argument name="menu" value="My Orders"/>
</actionGroup>

<seeElement selector="{{StorefrontCustomerOrderSection.isMyOrdersSection}}" stepKey="waitOrderHistoryPage"/>

<scrollTo selector="{{StorefrontCustomerOrderSection.currentPage}}" stepKey="scrollToBottomToolbarSection"/>

<click selector="{{StorefrontCustomerOrderSection.pageNumber('2')}}" stepKey="clickOnPage2"/>

<scrollTo selector="{{StorefrontCustomerOrderSection.perPage}}" stepKey="scrollToLimiter"/>

<selectOption userInput="20" selector="{{StorefrontCustomerOrderSection.perPage}}" stepKey="selectLimitOnPage"/>

<waitForPageLoad stepKey="waitForLoadPage"/>

<seeElement selector="{{StorefrontCustomerOrderSection.isMyOrdersSection}}"
stepKey="seeElementOrderHistoryPage"/>

<dontSee selector="{{StorefrontOrderInformationMainSection.emptyMessage}}"
userInput="You have placed no orders." stepKey="dontSeeEmptyMessage"/>

<seeNumberOfElements selector="{{StorefrontCustomerOrderSection.rowsInColumn('id')}}" userInput="15"
stepKey="seeRowsCount"/>

</test>
</tests>
27 changes: 27 additions & 0 deletions app/code/Magento/Quote/Test/Mftf/Data/CustomerCartData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="CustomerCart" type="CustomerCart">
<var key="customer_id" entityType="customer" entityKey="id"/>
</entity>

<entity name="CustomerAddressInformation" type="CustomerAddressInformation">
<var key="cart_id" entityKey="return" entityType="CustomerCart"/>
<requiredEntity type="shipping_address">ShippingAddressTX</requiredEntity>
<requiredEntity type="billing_address">BillingAddressTX</requiredEntity>
<data key="shipping_method_code">flatrate</data>
<data key="shipping_carrier_code">flatrate</data>
</entity>

<entity name="CustomerOrderPaymentMethod" type="CustomerPaymentInformation">
<var key="cart_id" entityKey="return" entityType="CustomerCart"/>
<requiredEntity type="payment_method">PaymentMethodCheckMoneyOrder</requiredEntity>
<requiredEntity type="billing_address">BillingAddressTX</requiredEntity>
</entity>
</entities>
16 changes: 16 additions & 0 deletions app/code/Magento/Quote/Test/Mftf/Data/CustomerCartItemData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="CustomerCartItem" type="CustomerCartItem">
<var key="quote_id" entityKey="return" entityType="CustomerCart"/>
<var key="sku" entityKey="sku" entityType="product"/>
<data key="qty">1</data>
</entity>
</entities>
20 changes: 20 additions & 0 deletions app/code/Magento/Quote/Test/Mftf/Metadata/CustomerCartItemMeta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">

<operation name="CreateCustomerCartItem" dataType="CustomerCartItem" type="create" auth="adminOauth" url="/V1/carts/mine/items" method="POST">
<contentType>application/json</contentType>
<object key="cartItem" dataType="CustomerCartItem">
<field key="quote_id" type="string">string</field>
<field key="sku" type="string">string</field>
<field key="qty">integer</field>
</object>
</operation>
</operations>
63 changes: 63 additions & 0 deletions app/code/Magento/Quote/Test/Mftf/Metadata/CustomerCartMeta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
<operation name="CreateCustomerCart" dataType="CustomerCart" type="create"
auth="adminOauth" url="/V1/carts/mine" method="POST" >
<contentType>application/json</contentType>
<field key="customer_id">string</field>
</operation>

<operation name="AddAddressInfoToCustomerCart" dataType="CustomerAddressInformation" type="create" auth="adminOauth" url="/V1/carts/mine/shipping-information" method="POST">
<contentType>application/json</contentType>
<field key="cart_id">string</field>
<object key="addressInformation" dataType="CustomerAddressInformation">
<object key="shipping_address" dataType="shipping_address">
<field key="city">string</field>
<field key="region">string</field>
<field key="region_code">string</field>
<field key="region_id">integer</field>
<field key="country_id">string</field>
<array key="street">
<value>string</value>
</array>
<field key="postcode">string</field>
<field key="firstname">string</field>
<field key="lastname">string</field>
<field key="email">string</field>
<field key="telephone">string</field>
</object>
<object key="billing_address" dataType="billing_address">
<field key="city">string</field>
<field key="region">string</field>
<field key="region_code">string</field>
<field key="region_id">integer</field>
<field key="country_id">string</field>
<array key="street">
<value>string</value>
</array>
<field key="postcode">string</field>
<field key="firstname">string</field>
<field key="lastname">string</field>
<field key="email">string</field>
<field key="telephone">string</field>
</object>
<field key="shipping_method_code">string</field>
<field key="shipping_carrier_code">string</field>
</object>
</operation>

<operation name="SendCustomerPaymentInformation" dataType="CustomerPaymentInformation" type="update" auth="adminOauth" url="/V1/carts/mine/payment-information" method="POST">
<contentType>application/json</contentType>
<field key="cart_id">string</field>
<object key="paymentMethod" dataType="payment_method">
<field key="method">string</field>
</object>
</operation>
</operations>
22 changes: 21 additions & 1 deletion app/code/Magento/Theme/Block/Html/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Theme\Block\Html;

/**
Expand Down Expand Up @@ -466,7 +467,26 @@ public function getPageUrl($page)
*/
public function getLimitUrl($limit)
{
return $this->getPagerUrl([$this->getLimitVarName() => $limit]);
return $this->getPagerUrl($this->getPageLimitParams($limit));
}

/**
* Return page limit params
*
* @param int $limit
* @return array
*/
private function getPageLimitParams(int $limit): array
{
$data = [$this->getLimitVarName() => $limit];

$currentPage = $this->getCurrentPage();
$availableCount = (int) ceil($this->getTotalNum() / $limit);
if ($currentPage !== 1 && $availableCount < $currentPage) {
$data = array_merge($data, [$this->getPageVarName() => $availableCount === 1 ? null : $availableCount]);
}

return $data;
}

/**
Expand Down
Loading