-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
204 additions
and
11 deletions.
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,21 @@ | ||
import type { Page } from "@playwright/test"; | ||
|
||
export class AddLineRefundReasonDialog { | ||
readonly page: Page; | ||
|
||
constructor( | ||
page: Page, | ||
readonly lineRefundReasonInput = page.getByTestId("line-refund-reason-input"), | ||
readonly confirmButton = page.getByTestId("confirm-button"), | ||
) { | ||
this.page = page; | ||
} | ||
|
||
async provideLineRefundReason(reason: string) { | ||
await this.lineRefundReasonInput.fill(reason); | ||
} | ||
|
||
async submitLineRefundReason() { | ||
await this.confirmButton.click(); | ||
} | ||
} |
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 { BasePage } from "@pages/basePage"; | ||
import { Page } from "@playwright/test"; | ||
|
||
export class OrderRefundDialog extends BasePage { | ||
constructor( | ||
page: Page, | ||
readonly standardRefund = page.getByTestId("standard-refund"), | ||
readonly manualRefund = page.getByTestId("manual-refund"), | ||
readonly backButton = page.getByTestId("back-button"), | ||
readonly proceedButton = page.getByTestId("proceed-button"), | ||
) { | ||
super(page); | ||
} | ||
|
||
async pickLineItemsRefund() { | ||
await this.standardRefund.click(); | ||
await this.proceedButton.click(); | ||
} | ||
|
||
async pickManualRefund() { | ||
await this.manualRefund.click(); | ||
await this.proceedButton.click(); | ||
} | ||
} |
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,78 @@ | ||
import { URL_LIST } from "@data/url"; | ||
import { AddLineRefundReasonDialog } from "@pages/dialogs/lineRefundReasonDialog"; | ||
import { OrdersPage } from "@pages/ordersPage"; | ||
import { expect, Page } from "@playwright/test"; | ||
|
||
export class RefundPage extends OrdersPage { | ||
addLineRefundReasonDialog: AddLineRefundReasonDialog; | ||
|
||
constructor( | ||
page: Page, | ||
readonly allButton = page.getByTestId("all-button"), | ||
readonly productQuantityInput = page.getByTestId("product-quantity-input"), | ||
readonly maxLineRefundQuantity = page.getByTestId("max-line-refund-quantity"), | ||
readonly refundReasonInput = page.getByTestId("refund-reason-input"), | ||
readonly lineRefundReasonDialog = page.getByTestId("refund-reason-dialog"), | ||
readonly lineRefundReasonButton = page.getByTestId("line-refund-reason-button"), | ||
) { | ||
super(page); | ||
this.addLineRefundReasonDialog = new AddLineRefundReasonDialog(page); | ||
} | ||
|
||
async getProductRow(productName: string) { | ||
return await this.page.locator("table tr").filter({ hasText: productName }); | ||
} | ||
|
||
async expectLineItemsRefundPageOpen(orderId: string) { | ||
const orderLink = `${URL_LIST.orders}${orderId}/refund`; | ||
|
||
await expect(this.page).toHaveURL(orderLink); | ||
await this.waitForDOMToFullyLoad(); | ||
await expect(this.pageHeader).toContainText("Create refund with line items"); | ||
} | ||
|
||
async expectManualRefundPageOpen(orderId: string) { | ||
const orderLink = `${URL_LIST.orders}${orderId}/manual-refund`; | ||
|
||
await expect(this.page).toHaveURL(orderLink); | ||
await expect(this.pageHeader).toContainText("Refund with manual amount"); | ||
} | ||
|
||
async pickAllProductQuantityToRefund(productName: string) { | ||
const productRow = await this.getProductRow(productName); | ||
|
||
await productRow.locator(this.allButton).click(); | ||
|
||
const maxLineRefundQuantityText = await productRow | ||
.locator(this.maxLineRefundQuantity) | ||
.first() | ||
.innerText(); | ||
const value = maxLineRefundQuantityText.slice(-1); | ||
|
||
await expect(productRow.locator(this.productQuantityInput)).toHaveValue(value); | ||
} | ||
|
||
async provideRefundReason(reason: string) { | ||
await this.refundReasonInput.fill(reason); | ||
} | ||
|
||
async clickLineRefundReasonButton(productName: string) { | ||
const productRow = await this.getProductRow(productName); | ||
|
||
await productRow.locator(this.lineRefundReasonButton).click(); | ||
await this.lineRefundReasonDialog.waitFor({ state: "visible" }); | ||
} | ||
|
||
async inputProductLineQuantity(productName: string, amount: string) { | ||
const productRow = await this.getProductRow(productName); | ||
|
||
await productRow.locator(this.productQuantityInput).fill(amount); | ||
await expect(productRow.locator(this.productQuantityInput)).toHaveValue(amount); | ||
} | ||
|
||
async saveDraft() { | ||
await expect(this.saveButton).toHaveText("Save draft"); | ||
await this.clickSaveButton(); | ||
await this.waitForDOMToFullyLoad(); | ||
} | ||
} |
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
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
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
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