From 95a4f97f118e25180f92dff22ac399dad0922b54 Mon Sep 17 00:00:00 2001 From: yellowee Date: Wed, 3 Jul 2024 12:31:30 +0200 Subject: [PATCH] test_for_manual_refund --- playwright/pages/refundPage.ts | 22 +++++++++++++++++++ playwright/tests/orders.spec.ts | 22 +++++++++++++++++++ .../OrderManualTransactionRefundAmount.tsx | 4 ++-- .../OrderTransactionTileEvent.tsx | 1 + .../OrderTransactionTileRoot.tsx | 1 + 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/playwright/pages/refundPage.ts b/playwright/pages/refundPage.ts index a5274887fcb..fa4ba518fa2 100644 --- a/playwright/pages/refundPage.ts +++ b/playwright/pages/refundPage.ts @@ -14,6 +14,10 @@ export class RefundPage extends OrdersPage { readonly refundReasonInput = page.getByTestId("refund-reason-input"), readonly lineRefundReasonDialog = page.getByTestId("refund-reason-dialog"), readonly lineRefundReasonButton = page.getByTestId("line-refund-reason-button"), + readonly transactionCard = page.getByTestId("transaction-card"), + readonly transactionEventRow = page.getByTestId("transaction-event-row"), + readonly refundAmountInput = page.getByTestId("refund-amount"), + readonly amountErrorMessage = page.getByTestId("error-message"), ) { super(page); this.addLineRefundReasonDialog = new AddLineRefundReasonDialog(page); @@ -76,9 +80,27 @@ export class RefundPage extends OrdersPage { await this.waitForDOMToFullyLoad(); } + async selectTransactionToRefund(status: string, amount: string) { + const transaction = await this.transactionCard + .locator(this.transactionEventRow) + .filter({ hasText: status }) + .filter({ hasText: amount }); + + await transaction.getByRole("radio").click(); + } + + async provideRefundAmount(amount: string) { + await this.refundAmountInput.fill(""); + await this.refundAmountInput.fill(amount); + } + async transferFunds() { await expect(this.saveButton).toHaveText("Transfer funds"); await this.clickSaveButton(); await this.waitForDOMToFullyLoad(); } + + async expectErrorMessage(error: string) { + expect(this.amountErrorMessage).toHaveText(error); + } } diff --git a/playwright/tests/orders.spec.ts b/playwright/tests/orders.spec.ts index efe39e16625..10fd7e7bb78 100644 --- a/playwright/tests/orders.spec.ts +++ b/playwright/tests/orders.spec.ts @@ -288,3 +288,25 @@ test("TC: SALEOR_191 Refund products from the fully paid order @e2e @refunds", a await refundPage.transferFunds(); await refundPage.expectSuccessBannerMessage("Refund has been sent"); }); + +test("TC: SALEOR_192 Create manual refund @e2e @refunds", async () => { + const order = ORDERS.fullyPaidOrderWithSeveralTransactions; + + await ordersPage.goToExistingOrderPage(order.id); + await ordersPage.clickAddRefundButton(); + await ordersPage.orderRefundDialog.pickManualRefund(); + await ordersPage.orderRefundModal.waitFor({ state: "hidden" }); + await refundPage.expectManualRefundPageOpen(order.id); + await refundPage.selectTransactionToRefund("SUCCESS", "100.00"); + await refundPage.transferFunds(); + await refundPage.expectErrorMessage("You must provide amount value"); + await refundPage.provideRefundAmount("1000"); + await refundPage.expectErrorMessage( + "Provided amount cannot exceed charged amount for the selected transaction", + ); + await refundPage.provideRefundAmount("10"); + await refundPage.transferFunds(); + await refundPage.expectSuccessBannerMessage("Refund has been sent"); + await ordersPage.goToExistingOrderPage(order.id); + await ordersPage.orderRefundSection.waitFor({ state: "visible" }); +}); diff --git a/src/orders/components/OrderManualTransactionRefundPage/components/OrderManualTransactionRefundAmount/OrderManualTransactionRefundAmount.tsx b/src/orders/components/OrderManualTransactionRefundPage/components/OrderManualTransactionRefundAmount/OrderManualTransactionRefundAmount.tsx index c8708fda043..3f747e3c8a5 100644 --- a/src/orders/components/OrderManualTransactionRefundPage/components/OrderManualTransactionRefundAmount/OrderManualTransactionRefundAmount.tsx +++ b/src/orders/components/OrderManualTransactionRefundPage/components/OrderManualTransactionRefundAmount/OrderManualTransactionRefundAmount.tsx @@ -16,7 +16,7 @@ export const OrderManualTransactionRefundAmount = ({ const { control } = useFormContext(); return ( - + {!!error && ( - + {error.message} diff --git a/src/orders/components/OrderTransactionTile/OrderTransactionTileEvent.tsx b/src/orders/components/OrderTransactionTile/OrderTransactionTileEvent.tsx index ff9f8e7fa34..37cf24d23f0 100644 --- a/src/orders/components/OrderTransactionTile/OrderTransactionTileEvent.tsx +++ b/src/orders/components/OrderTransactionTile/OrderTransactionTileEvent.tsx @@ -20,6 +20,7 @@ export const OrderTransactionTileEvent = ({ event }: OrderTransactionTileEventPr return ( { return (