fix(GOV-009): 完成脚手架审查整改

This commit is contained in:
2026-08-13 18:30:57 +08:00
parent dcdf634457
commit 3a8120a33a
47 changed files with 752 additions and 101 deletions
+14 -6
View File
@@ -9,12 +9,20 @@ export default defineConfig({
baseURL: 'http://127.0.0.1:5173',
trace: 'retain-on-failure',
},
webServer: {
command: 'env -u NO_COLOR pnpm dev',
url: 'http://127.0.0.1:5173',
reuseExistingServer: false,
timeout: 30_000,
},
webServer: [
{
command: 'node ../server/tools/run-test-api.mjs',
url: 'http://127.0.0.1:3000/api/v1/health',
reuseExistingServer: false,
timeout: 30_000,
},
{
command: 'env -u NO_COLOR pnpm dev',
url: 'http://127.0.0.1:5173',
reuseExistingServer: false,
timeout: 30_000,
},
],
projects: [
{
name: 'desktop-chromium',
+16
View File
@@ -0,0 +1,16 @@
// @vitest-environment node
import { describe, expect, it } from 'vitest';
import viteConfig from '../vite.config';
describe('Vite 本地 API 代理', () => {
it('通过同源 /api 转发到本地 NestJS,避免浏览器依赖跨域配置', () => {
expect(viteConfig.server?.proxy).toMatchObject({
'/api': {
target: 'http://127.0.0.1:3000',
changeOrigin: false,
},
});
});
});
+8
View File
@@ -21,3 +21,11 @@ test('应用外壳在桌面和移动视口均可正常呈现', async ({ page })
expect(hasHorizontalOverflow).toBe(false);
expect(runtimeErrors).toEqual([]);
});
test('Web 通过同源代理访问真实 API 健康契约', async ({ request }) => {
const response = await request.get('/api/v1/health');
const body = (await response.json()) as { process?: string; status?: string };
expect(response.status()).toBe(200);
expect(body).toMatchObject({ process: 'api', status: 'healthy' });
});
+7
View File
@@ -37,5 +37,12 @@ export default defineConfig({
host: '127.0.0.1',
port: 5173,
strictPort: true,
proxy: {
// 本地浏览器始终请求同源 /api,由 Vite 转发到 NestJS,避免开发环境放宽 CORS。
'/api': {
target: 'http://127.0.0.1:3000',
changeOrigin: false,
},
},
},
});