app-template/e2e/errors.spec.ts

16 lines
546 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, test } from "@playwright/test";
test("未知路径返回 404 页面", async ({ page }) => {
const res = await page.goto("/zh-CN/definitely-not-a-page");
expect(res?.status()).toBe(404);
});
test("裸非法路径视为非法 locale 前缀,302 到本地化首页", async ({ request }) => {
const res = await request.get("/no-such-page", {
headers: { "accept-language": "zh-CN" },
maxRedirects: 0,
});
expect(res.status()).toBe(302);
expect(res.headers()["location"]).toBe("/zh-CN");
});