test(e2e): cover chat limit payment flow

This commit is contained in:
2026-06-30 15:39:28 +08:00
parent 218df59345
commit 835c8e4f73
3 changed files with 53 additions and 3 deletions
+26 -3
View File
@@ -61,6 +61,8 @@ test("guest hits the chat quantity limit and can continue to login and subscript
limitTriggeredAt = index;
break;
}
await page.waitForTimeout(1_000);
}
expect(limitTriggeredAt).not.toBeNull();
@@ -94,9 +96,30 @@ test("guest hits the chat quantity limit and can continue to login and subscript
await page.getByRole("button", { name: "Login" }).click();
await expect(page).toHaveURL(/\/subscription\?type=vip&returnTo=chat$/);
await expect(
page.getByRole("button", { name: /Activate/i }),
).toBeVisible();
const createOrderRequestPromise = page.waitForRequest(
"**/api/payment/create-order",
);
const orderStatusRequestPromise = page.waitForRequest(
"**/api/payment/order-status**",
);
await page.getByRole("button", { name: /Pay and Activ/i }).click();
const createOrderRequest = await createOrderRequestPromise;
expect(createOrderRequest.postDataJSON()).toMatchObject({
planId: "vip_monthly",
payChannel: "stripe",
});
await orderStatusRequestPromise;
const paymentSuccessDialog = page.getByRole("alertdialog", {
name: "Payment successful",
});
await expect(paymentSuccessDialog).toBeVisible();
await paymentSuccessDialog.getByRole("button", { name: "OK" }).click();
await expect(page).toHaveURL(/\/chat$/);
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
});
async function isQuantityLimitVisible(