You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { test, expect } from "@playwright/test";
import { fillQuoteForm, mockQuoteApi } from "./helpers";
test.describe("查价页 E2E 核心路径task-089", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/embed-demo");
await expect(
page.getByRole("heading", { name: "卡派查价" }),
).toBeVisible({ timeout: 30_000 });
});
test("路径1L2 缓存命中 → 四档报价展示", async ({ page }) => {
await mockQuoteApi(page, "cache");
await fillQuoteForm(page);
await page.getByRole("button", { name: "获取报价" }).click();
await expect(page.getByRole("button", { name: "标准" })).toBeVisible({
timeout: 15_000,
});
await expect(page.getByRole("button", { name: "保证送达" })).toBeVisible();
});
test("路径2processing → Skeleton → 成功", async ({ page }) => {
await mockQuoteApi(page, "processing");
await fillQuoteForm(page);
await page.getByRole("button", { name: "获取报价" }).click();
await expect(page.getByText("正在查询报价")).toBeVisible();
await expect(page.getByRole("button", { name: "标准" })).toBeVisible({
timeout: 15_000,
});
});
test("路径3stale 降级 → WarningBanner", async ({ page }) => {
await mockQuoteApi(page, "stale");
await fillQuoteForm(page);
await page.getByRole("button", { name: "获取报价" }).click();
await expect(
page.getByText("非实时报价,仅供参考(已使用历史缓存降级)"),
).toBeVisible({ timeout: 15_000 });
});
test("路径4API 错误 → ErrorBanner + 重试", async ({ page }) => {
await mockQuoteApi(page, "error");
await fillQuoteForm(page);
await page.getByRole("button", { name: "获取报价" }).click();
await expect(page.getByRole("button", { name: "重试" })).toBeVisible({
timeout: 10_000,
});
});
test("路径5空闲态占位文案", async ({ page }) => {
await expect(page.getByText("填写信息后获取报价")).toBeVisible();
await expect(page.getByText("四档运价")).toBeVisible();
});
});