feat(C-01):路由/代理前缀冲突修复
SPA冲突路由改名+旧路径Navigate重定向(/api-docs→/open-api-docs、/api-detail→/open-api-detail、/article→/post、/user→/user-home);vite代理宽前缀改精确正则白名单;nginx.conf同步同口径;新增86路由回归脚本+Playwright 3项(86/86全绿)。
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// C-01 回归:新路由直访 + 旧链接重定向 + SPA 内部导航(对准 5174 实测端口)
|
||||
const BASE = process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:5174';
|
||||
|
||||
test('C-01 新路由直访返回 SPA(open-api/post/user-home)', async ({ page }) => {
|
||||
for (const r of ['/open-api', '/open-api-detail/1', '/post/1', '/user-home/1', '/articles', '/search']) {
|
||||
const resp = await page.goto(BASE + r, { waitUntil: 'domcontentloaded' });
|
||||
expect(resp?.status(), r).toBe(200);
|
||||
await expect(page.locator('#root')).toBeAttached();
|
||||
const body = await page.content();
|
||||
expect(body.includes('Django') && body.includes('Not Found'), r).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
test('C-01 旧分享链接客户端重定向存活', async ({ page }) => {
|
||||
await page.goto(BASE + '/article/1', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/post\/1/, { timeout: 8000 });
|
||||
await page.goto(BASE + '/user/1', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/user-home\/1/, { timeout: 8000 });
|
||||
await page.goto(BASE + '/api-detail/1', { waitUntil: 'domcontentloaded' });
|
||||
await expect(page).toHaveURL(/\/open-api-detail\/1/, { timeout: 8000 });
|
||||
});
|
||||
|
||||
test('C-01 API 代理回归(经 vite 直调后端)', async ({ request }) => {
|
||||
const a = await request.get(BASE + '/article/articles/');
|
||||
expect(a.status()).toBe(200);
|
||||
const b = await request.get(BASE + '/api/apidirectory/categories/');
|
||||
expect(b.status()).toBe(200);
|
||||
const c = await request.get(BASE + '/search/hot-keywords/');
|
||||
expect(c.status()).toBe(200);
|
||||
});
|
||||
Reference in New Issue
Block a user