import { expect, test } from "@playwright/test"; test.describe("MS L2 UI fixture", () => { test.beforeEach(async ({ page }) => { await page.goto("/e2e-fixtures/ms-l2-ui"); }); test("补填态:空必填项红边高亮", async ({ page }) => { const details = page.getByTestId("ms-l2-details"); await expect(details.getByTestId("ms-details-pickup-company")).toHaveAttribute( "data-invalid", "true", ); await expect(details.getByTestId("ms-details-pickup-email")).toHaveAttribute( "data-invalid", "true", ); await expect(details.getByTestId("ms-details-pickup-company")).toHaveClass( /border-error/, ); await details.getByTestId("ms-details-pickup-company").fill("Acme Pickup LLC"); await expect( details.getByTestId("ms-details-pickup-company"), ).not.toHaveAttribute("data-invalid", "true"); }); test("附加服务卡片可勾选,详情开关可关", async ({ page }) => { const details = page.getByTestId("ms-l2-details"); await expect( details.getByText("选择提货/送货服务,避免追收附加费").first(), ).toBeVisible(); const liftgate = details.getByRole("button", { name: /尾板/ }).first(); await liftgate.click(); await expect(liftgate).toHaveClass(/border-primary/); await details.getByRole("switch").first().click(); await expect(details.getByText("需液压尾板装货").first()).toHaveCount(0); }); test("侧栏承运商/保障/结账可点", async ({ page }) => { const sidebar = page.getByTestId("ms-l2-sidebar"); await expect( sidebar.getByText("选择承运商", { exact: true }), ).toBeVisible(); await sidebar .getByRole("button", { name: /TForce Freight Direct/ }) .first() .click(); await expect(sidebar.getByText("已选").first()).toBeVisible(); await sidebar.getByText("Dedicated Dry Van").first().click(); await expect(sidebar.getByText(/运费|附加费|暂无更多费用明细/)).toBeVisible(); await expect(sidebar.getByText(/以官网为准/)).toHaveCount(0); await expect(sidebar.getByText("无法服务此货件的承运商")).toHaveCount(0); await sidebar.getByText("全额货运保障(FreightProtect)").click(); await expect(sidebar.getByText("最低约 $22.55")).toBeVisible(); await sidebar.getByPlaceholder("输入货物总价值").fill("1500"); await expect( sidebar.getByRole("button", { name: "了解更多", exact: true }), ).toHaveCount(0); await expect(sidebar.getByText(/外链暂未配置|官网查看/)).toHaveCount(0); await sidebar.getByText("承运商基础保障").click(); await expect( sidebar.getByRole("button", { name: "查看保障详情与除外条款" }), ).toHaveCount(0); await sidebar.getByRole("button", { name: /前往结账/ }).click(); await expect(page.getByTestId("last-action")).toHaveText( "lastAction=checkout-ok", ); }); });