forked from saleor/saleor-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[E2E] [TEST] Adding test for a line item refund type (saleor#5003)
* adding changeset * e2e tests for refunds * refund test
- Loading branch information
1 parent
583c66f
commit d1c114d
Showing
16 changed files
with
254 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
You can now run e2e tests without flakiness |
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,5 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
--- | ||
|
||
You can now run E2E tests for refunds |
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
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,84 @@ | ||
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(); | ||
} | ||
|
||
async transferFunds() { | ||
await expect(this.saveButton).toHaveText("Transfer funds"); | ||
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
Oops, something went wrong.