-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add order history page #301
Open
AureRita
wants to merge
2
commits into
PrestaShop:main
Choose a base branch
from
AureRita:addOrderHistoryPage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {FOBasePagePageInterface} from '@interfaces/FO'; | ||
import {type Page} from '@playwright/test'; | ||
import {type OrderHistory, OrderHistoryMessage} from '@data/types/order'; | ||
|
||
export interface FoOrderHistoryPageInterface extends FOBasePagePageInterface { | ||
readonly pageTitle: string; | ||
|
||
getNumberOfOrders(page: Page): Promise<number>; | ||
getOrderHistoryDetails(page: Page, row?: number): Promise<OrderHistory>; | ||
isReorderLinkVisible(page: Page, orderRow?: number): Promise<boolean>; | ||
clickOnReorderLink(page: Page, orderRow?: number): Promise<void>; | ||
getOrderStatus(page: Page, orderRow?: number): Promise<string>; | ||
isInvoiceVisible(page: Page, orderRow?: number): Promise<boolean>; | ||
getOrderIdFromInvoiceHref(page: Page, orderRow?: number): Promise<string>; | ||
downloadInvoice(page: Page, row?: number): Promise<string | null>; | ||
goToDetailsPage(page: Page, orderRow?: number): Promise<void>; | ||
goToOrderDetailsPage(page: Page, orderID?: number): Promise<void>; | ||
clickOnBackToYourAccountLink(page: Page): Promise<void>; | ||
clickOnHomeLink(page: Page): Promise<void>; | ||
isBoxMessagesSectionVisible(page: Page): Promise<boolean>; | ||
isMessageRowVisible(page: Page, row?: number): Promise<boolean>; | ||
getMessageRow(page: Page, row?: number): Promise<string>; | ||
sendMessage(page: Page, messageText: OrderHistoryMessage): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,9 @@ | ||||||
import type {FoOrderHistoryPageInterface} from '@interfaces/FO/myAccount/orderHistory'; | ||||||
|
||||||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||||||
function requirePage(): FoOrderHistoryPageInterface { | ||||||
return require('@versions/develop/pages/FO/classic/myAccount/orderHistory').orderHistoryPage; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||||||
|
||||||
export default requirePage(); |
263 changes: 263 additions & 0 deletions
263
src/versions/develop/pages/FO/classic/myAccount/orderHistory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,263 @@ | ||||||||||
import {FoOrderHistoryPageInterface} from '@interfaces/FO/myAccount/orderHistory'; | ||||||||||
import FOBasePage from '@pages/FO/FOBasePage'; | ||||||||||
import {type OrderHistory, OrderHistoryMessage} from '@data/types/order'; | ||||||||||
|
||||||||||
import type {Page} from 'playwright'; | ||||||||||
|
||||||||||
/** | ||||||||||
* Order history page, contains functions that can be used on the page | ||||||||||
* @class | ||||||||||
* @extends FOBasePage | ||||||||||
*/ | ||||||||||
class OrderHistoryPage extends FOBasePage implements FoOrderHistoryPageInterface { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
public readonly pageTitle: string; | ||||||||||
|
||||||||||
public readonly messageSuccessSent: string; | ||||||||||
|
||||||||||
private readonly ordersTable: string; | ||||||||||
|
||||||||||
private readonly ordersTableRows: string; | ||||||||||
|
||||||||||
protected readonly ordersTableRow: (row: number) => string; | ||||||||||
|
||||||||||
private readonly orderTableColumn: (row: number, column: number) => string; | ||||||||||
|
||||||||||
private readonly orderTableColumnReference: (row: number) => string; | ||||||||||
|
||||||||||
protected reorderLink: (row: number) => string; | ||||||||||
|
||||||||||
protected detailsLink: (row: number) => string; | ||||||||||
|
||||||||||
private readonly orderTableColumnInvoice: (row: number) => string; | ||||||||||
|
||||||||||
private readonly orderDetailsLink: (orderID: number) => string; | ||||||||||
|
||||||||||
private readonly backToYourAccountLink: string; | ||||||||||
|
||||||||||
private readonly homeLink: string; | ||||||||||
|
||||||||||
private readonly boxMessagesSection: string; | ||||||||||
|
||||||||||
private readonly messageRow: (row: number) => string; | ||||||||||
|
||||||||||
private readonly orderMessageForm: string; | ||||||||||
|
||||||||||
private readonly productSelect: string; | ||||||||||
|
||||||||||
private readonly messageTextarea: string; | ||||||||||
|
||||||||||
private readonly sendMessageButton: string; | ||||||||||
|
||||||||||
/** | ||||||||||
* @constructs | ||||||||||
* Setting up texts and selectors to use on order history page | ||||||||||
*/ | ||||||||||
constructor(theme: string = 'classic') { | ||||||||||
super(theme); | ||||||||||
|
||||||||||
this.pageTitle = 'Order history'; | ||||||||||
|
||||||||||
// Text message | ||||||||||
this.messageSuccessSent = 'Message successfully sent'; | ||||||||||
|
||||||||||
// Selectors | ||||||||||
this.ordersTable = '#content table'; | ||||||||||
this.ordersTableRows = `${this.ordersTable} tbody tr`; | ||||||||||
this.ordersTableRow = (row: number) => `${this.ordersTableRows}:nth-child(${row})`; | ||||||||||
this.orderTableColumn = (row: number, column: number) => `${this.ordersTableRow(row)} td:nth-child(${column})`; | ||||||||||
this.orderTableColumnReference = (row: number) => `${this.ordersTableRow(row)} th:nth-child(1)`; | ||||||||||
this.reorderLink = (row: number) => `${this.ordersTableRow(row)} a.reorder-link`; | ||||||||||
this.detailsLink = (row: number) => `${this.ordersTableRow(row)} a.view-order-details-link`; | ||||||||||
this.orderTableColumnInvoice = (row: number) => `${this.ordersTableRow(row)} td:nth-child(6) a`; | ||||||||||
this.orderDetailsLink = (orderID: number) => `${this.ordersTableRows}` | ||||||||||
+ ` td a.view-order-details-link[href$='order-detail&id_order=${orderID}']`; | ||||||||||
this.backToYourAccountLink = 'footer a[data-role=back-to-your-account]'; | ||||||||||
this.homeLink = 'footer a[data-role=home]'; | ||||||||||
|
||||||||||
// Messages block | ||||||||||
this.boxMessagesSection = '.box.messages'; | ||||||||||
this.messageRow = (row: number) => `${this.boxMessagesSection} div:nth-child(${row}).message.row`; | ||||||||||
|
||||||||||
// Add message block | ||||||||||
this.orderMessageForm = '.order-message-form'; | ||||||||||
this.productSelect = `${this.orderMessageForm} select[data-role='product']`; | ||||||||||
this.messageTextarea = `${this.orderMessageForm} textarea[data-role='msg-text']`; | ||||||||||
this.sendMessageButton = `${this.orderMessageForm} button.form-control-submit`; | ||||||||||
} | ||||||||||
|
||||||||||
/* | ||||||||||
Methods | ||||||||||
*/ | ||||||||||
|
||||||||||
/** | ||||||||||
* Get number of order in order history page | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @returns {Promise<number>} | ||||||||||
*/ | ||||||||||
async getNumberOfOrders(page: Page): Promise<number> { | ||||||||||
return page.locator(this.ordersTableRows).count(); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Get order history details | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param row {number} Row in order history table | ||||||||||
*/ | ||||||||||
async getOrderHistoryDetails(page: Page, row: number = 1): Promise<OrderHistory> { | ||||||||||
return { | ||||||||||
reference: await this.getTextContent(page, this.orderTableColumnReference(row)), | ||||||||||
date: await this.getTextContent(page, this.orderTableColumn(row, 2)), | ||||||||||
price: await this.getTextContent(page, this.orderTableColumn(row, 3)), | ||||||||||
paymentType: await this.getTextContent(page, this.orderTableColumn(row, 4)), | ||||||||||
status: await this.getTextContent(page, this.orderTableColumn(row, 5)), | ||||||||||
invoice: await this.getTextContent(page, this.orderTableColumn(row, 6)), | ||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Is reorder link visible | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {Number} Row on orders table | ||||||||||
* @returns {Promise<boolean>} | ||||||||||
*/ | ||||||||||
async isReorderLinkVisible(page: Page, orderRow: number = 1): Promise<boolean> { | ||||||||||
return this.elementVisible(page, this.reorderLink(orderRow), 1000); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* | ||||||||||
* Click on reorder link | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {Number} Row in orders table | ||||||||||
* @returns {Promise<void>} | ||||||||||
*/ | ||||||||||
async clickOnReorderLink(page: Page, orderRow: number = 1): Promise<void> { | ||||||||||
await this.clickAndWaitForURL(page, this.reorderLink(orderRow)); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Get order status from orders history page | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {number} Row number in orders table | ||||||||||
* @return {Promise<string>} | ||||||||||
*/ | ||||||||||
async getOrderStatus(page: Page, orderRow: number = 1): Promise<string> { | ||||||||||
return this.getTextContent(page, `${this.orderTableColumn(orderRow, 5)} span`); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Is invoice visible on order history table row | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {number} Row number in orders table | ||||||||||
* @returns {Promise<boolean>} | ||||||||||
*/ | ||||||||||
async isInvoiceVisible(page: Page, orderRow: number = 1): Promise<boolean> { | ||||||||||
return this.elementVisible(page, this.orderTableColumnInvoice(orderRow), 1000); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Get order id from invoice href | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {number} Row number in orders table | ||||||||||
* @returns {Promise<string>} | ||||||||||
*/ | ||||||||||
async getOrderIdFromInvoiceHref(page: Page, orderRow: number = 1): Promise<string> { | ||||||||||
return this.getAttributeContent(page, this.orderTableColumnInvoice(orderRow), 'href'); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Download invoice | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param row {number} Row number in orders table | ||||||||||
*/ | ||||||||||
async downloadInvoice(page: Page, row: number = 1): Promise<string | null> { | ||||||||||
return this.clickAndWaitForDownload(page, this.orderTableColumnInvoice(row)); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Go to details page from order history page | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderRow {Number} row in orders table | ||||||||||
* @returns {Promise<void>} | ||||||||||
*/ | ||||||||||
async goToDetailsPage(page: Page, orderRow: number = 1): Promise<void> { | ||||||||||
await this.clickAndWaitForURL(page, this.detailsLink(orderRow)); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Go to order details page | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param orderID {number} Order ID | ||||||||||
* @returns {Promise<void>} | ||||||||||
*/ | ||||||||||
async goToOrderDetailsPage(page: Page, orderID: number = 1): Promise<void> { | ||||||||||
await this.clickAndWaitForURL(page, this.orderDetailsLink(orderID)); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Click on back to your account link | ||||||||||
* @param page {Page} Browser tab | ||||||||||
*/ | ||||||||||
async clickOnBackToYourAccountLink(page: Page): Promise<void> { | ||||||||||
await this.clickAndWaitForURL(page, this.backToYourAccountLink); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Click on home link | ||||||||||
* @param page {Page} Browser tab | ||||||||||
*/ | ||||||||||
async clickOnHomeLink(page: Page): Promise<void> { | ||||||||||
await this.clickAndWaitForURL(page, this.homeLink); | ||||||||||
} | ||||||||||
|
||||||||||
// Methods for box messages | ||||||||||
/** | ||||||||||
* Is box messages section visible | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @returns {Promise<boolean>} | ||||||||||
*/ | ||||||||||
async isBoxMessagesSectionVisible(page: Page): Promise<boolean> { | ||||||||||
return this.elementVisible(page, this.boxMessagesSection, 1000); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Is message visible | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param row {number} Row on table messages (2 is the first row) | ||||||||||
* @returns {Promise<boolean>} | ||||||||||
*/ | ||||||||||
async isMessageRowVisible(page: Page, row: number = 1): Promise<boolean> { | ||||||||||
return this.elementVisible(page, this.messageRow(row + 1), 1000); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Get message row | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param row {number} Row on table messages (2 is the first row) | ||||||||||
* @returns {Promise<string>} | ||||||||||
*/ | ||||||||||
async getMessageRow(page: Page, row: number = 1): Promise<string> { | ||||||||||
return this.getTextContent(page, this.messageRow(row + 1)); | ||||||||||
} | ||||||||||
|
||||||||||
// Methods for Add message form | ||||||||||
/** | ||||||||||
* Send message | ||||||||||
* @param page {Page} Browser tab | ||||||||||
* @param messageText {OrderHistoryMessage} Data to set on Add message form | ||||||||||
* @returns {Promise<string>} | ||||||||||
*/ | ||||||||||
async sendMessage(page: Page, messageText: OrderHistoryMessage): Promise<string> { | ||||||||||
if (messageText.product !== '') { | ||||||||||
await this.selectByVisibleText(page, this.productSelect, messageText.product); | ||||||||||
} | ||||||||||
|
||||||||||
await this.setValue(page, this.messageTextarea, messageText.message); | ||||||||||
await this.clickAndWaitForURL(page, this.sendMessageButton); | ||||||||||
|
||||||||||
return this.getTextContent(page, this.alertSuccessBlock); | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
const orderHistoryPage = new OrderHistoryPage(); | ||||||||||
export {orderHistoryPage, OrderHistoryPage}; | ||||||||||
Comment on lines
+262
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort by alphabetical order