Skip to content

Commit

Permalink
refund test
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowee committed Jul 2, 2024
1 parent 13dd12a commit 250c329
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .changeset/cool-doors-drum.md
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
1 change: 0 additions & 1 deletion .github/actions/prepare-tests-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,4 @@ runs:
echo "::notice title=POOL_INSTANCE::${POOL_INSTANCE}"
echo "::notice title=BACKUP_NAMESPACE::${BACKUP_NAMESPACE}"
echo "::notice title=SNAPSHOT::backup_id=${BACKUP_ID}, version=${BACKUP_VER}, name=${BACKUP_NAME}"
echo "::notice title=SALEOR_CLOUD_SERVICE::${SALEOR_CLOUD_SERVICE}"
15 changes: 15 additions & 0 deletions playwright/pages/ordersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export class OrdersPage extends BasePage {
readonly addRefundButton = page.getByTestId("add-new-refund-button"),
readonly customerEmail = page.getByTestId("customer-email"),
readonly orderRefundModal = page.getByTestId("order-refund-dialog"),
readonly orderRefundSection = page.getByTestId("order-refund-section"),
readonly orderRefundList = page.getByTestId("refund-list"),
readonly editRefundButton = page.getByTestId("edit-refund-button"),
) {
super(page);
this.markOrderAsPaidDialog = new MarkOrderAsPaidDialog(page);
Expand Down Expand Up @@ -117,4 +120,16 @@ export class OrdersPage extends BasePage {
await this.addRefundButton.click();
await this.orderRefundModal.waitFor({ state: "visible" });
}

async clickEditRefundButton(refundInfo: string) {
const refund = await this.orderRefundList.locator("tr").filter({ hasText: refundInfo });

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

async assertRefundOnList(refundInfo: string) {
const refund = await this.orderRefundList.locator("tr").filter({ hasText: refundInfo });

await refund.waitFor({ state: "visible" });
}
}
6 changes: 6 additions & 0 deletions playwright/pages/refundPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ export class RefundPage extends OrdersPage {
await this.clickSaveButton();
await this.waitForDOMToFullyLoad();
}

async transferFunds() {
await expect(this.saveButton).toHaveText("Transfer funds");
await this.clickSaveButton();
await this.waitForDOMToFullyLoad();
}
}
11 changes: 10 additions & 1 deletion playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,19 @@ test("TC: SALEOR_191 Refund products from the fully paid order @e2e @refunds", a
order.lineItems[0].quantity,
);

const refundReason = "Expectations not met";

await refundPage.inputProductLineQuantity(order.lineItems[1].name, "1");
await refundPage.clickLineRefundReasonButton(order.lineItems[0].name);
await refundPage.addLineRefundReasonDialog.provideLineRefundReason("Item is damaged");
await refundPage.addLineRefundReasonDialog.submitLineRefundReason();
await refundPage.provideRefundReason("Expectations not met");
await refundPage.provideRefundReason(refundReason);
await refundPage.saveDraft();
await refundPage.expectSuccessBanner();
await ordersPage.goToExistingOrderPage(order.id);
await ordersPage.orderRefundSection.waitFor({ state: "visible" });
await ordersPage.assertRefundOnList(refundReason);
await ordersPage.clickEditRefundButton(refundReason);
await refundPage.transferFunds();
await refundPage.expectSuccessBannerMessage("Refund has been sent");
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const OrderDetailsRefundLine: React.FC<OrderDetailsRefundLineProps> = ({
<Box display="flex" justifyContent="flex-end">
{isEditable ? (
<Link to={orderTransactionRefundEditUrl(orderId, refund.id)}>
<Button icon={<EditIcon />} variant="secondary" />
<Button data-test-id="edit-refund-button" icon={<EditIcon />} variant="secondary" />
</Link>
) : (
<Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const OrderDetailsRefundTable: React.FC<OrderDetailsRefundTableProps> = (
});

return (
<DashboardCard>
<DashboardCard data-test-id="order-refund-section">
<Box paddingTop={6} display="flex" justifyContent="space-between" paddingX={6}>
<Text size={5} fontWeight="bold">
<FormattedMessage {...refundGridMessages.refundSection} />
Expand All @@ -57,7 +57,7 @@ export const OrderDetailsRefundTable: React.FC<OrderDetailsRefundTableProps> = (
)}
</Tooltip>
</Box>
<GridTable height="100%" paddingX={6}>
<GridTable data-test-id="refund-list" height="100%" paddingX={6}>
<GridTable.Colgroup>
<GridTable.Col __width="1%" />
<GridTable.Col __width="10%" />
Expand Down

0 comments on commit 250c329

Please sign in to comment.