Files
ai-learning-platform/frontend/e2e/not-found.spec.ts
T

17 lines
582 B
TypeScript

import { test, expect } from '@playwright/test';
test.describe('404 页面', () => {
test('访问不存在页面显示 404', async ({ page }) => {
await page.goto('/this-page-does-not-exist-12345');
await expect(page.locator('body')).toBeVisible();
const has404 = page.getByText('404').first();
const hasNotFound = page.getByText(/找不到|不存在|页面/i).first();
const is404 = await has404.isVisible().catch(() => false);
const isNotFound = await hasNotFound.isVisible().catch(() => false);
expect(is404 || isNotFound).toBe(true);
});
});