Skip to content

Commit

Permalink
test_for_manual_refund (#5018)
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowee authored Jul 5, 2024
1 parent dfb19e5 commit 93f5dce
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/early-vans-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

You can now run e2e test for a manual refund type
2 changes: 2 additions & 0 deletions playwright/data/e2eTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ export const ORDERS = {
},
fullyPaidOrderWithSeveralTransactions: {
id: "T3JkZXI6MTVhYTEwMzYtZWE3OS00MzJiLTliODctNDhlYTMwYmU1NmNl",
transactionToRefundId:
"VHJhbnNhY3Rpb25JdGVtOjExNzQxZmQ3LWJkZjAtNDIxNi1hNTVkLTFkZDhiNTk4YTA5Mw==",
},
partiallyPaidOrder: {
id: "T3JkZXI6NmVlMDMwMTctZTViOS00OGNmLWFkYTQtODg4YTQ5MDI3ZjNk",
Expand Down
1 change: 1 addition & 0 deletions playwright/pages/ordersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class OrdersPage extends BasePage {
const refund = await this.orderRefundList.locator("tr").filter({ hasText: refundInfo });

await refund.locator(this.editRefundButton).click();
await this.waitForDOMToFullyLoad();
}

async assertRefundOnList(refundInfo: string) {
Expand Down
19 changes: 19 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,24 @@ export class RefundPage extends OrdersPage {
await this.waitForDOMToFullyLoad();
}

async selectTransactionToRefund(transactionId: string) {
await this.waitForDOMToFullyLoad();

await this.transactionCard.locator(`id=${transactionId}`).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);
}
}
23 changes: 23 additions & 0 deletions playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,26 @@ 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 Should create a manual refund with a custom amount @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(order.transactionToRefundId);
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("Transaction action requested successfully");
await ordersPage.goToExistingOrderPage(order.id);
await ordersPage.orderRefundSection.waitFor({ state: "visible" });
await ordersPage.assertRefundOnList("Manual refund");
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 93f5dce

Please sign in to comment.