Skip to content

Commit

Permalink
test_for_manual_refund
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowee committed Jul 3, 2024
1 parent 12d7b90 commit 95a4f97
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
22 changes: 22 additions & 0 deletions playwright/pages/refundPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
22 changes: 22 additions & 0 deletions playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const OrderManualTransactionRefundAmount = ({
const { control } = useFormContext<ManualRefundForm>();

return (
<Box backgroundColor="default2" borderRadius={3} padding={4}>
<Box data-test-id="DUPA" backgroundColor="default2" borderRadius={3} padding={4}>
<Controller
name="amount"
control={control}
Expand All @@ -39,7 +39,7 @@ export const OrderManualTransactionRefundAmount = ({
</Box>
{!!error && (
<Box textAlign="right" paddingY={2}>
<Text color="critical1" size={1}>
<Text data-test-id="error-message" color="critical1" size={1}>
{error.message}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const OrderTransactionTileEvent = ({ event }: OrderTransactionTileEventPr

return (
<Box
data-test-id="transaction-event-row"
backgroundColor="default1"
display="grid"
gridTemplateColumns={5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface OrderTransactionTileRootProps {
export const OrderTransactionTileRoot = ({ error, children }: OrderTransactionTileRootProps) => {
return (
<Box
data-test-id="transaction-card"
borderStyle="solid"
borderWidth={1}
borderColor={error ? "critical1" : "default1"}
Expand Down

0 comments on commit 95a4f97

Please sign in to comment.