Files
chunyu_prject_react/tests/e01-visual.spec.ts
T
chunyu e397fae928 feat(C-05):SEO预渲染+依赖瘦身+i18n补齐
build链追加seo预渲染(19工具页静态HTML+sitemap+robots)与seo:check验收;剔除chakra/emotion/@types/qrcode死依赖(pnpm-lock同步,手写qrcode.d.ts顶上);6语言locales补齐新功能文案。附带vite/nginx代理段与C-01同口径微调。e01-visual.spec.ts仅归档不跑(需8756/5173真机)。
2026-09-15 15:26:56 +08:00

33 lines
1.6 KiB
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 { test, expect } from '@playwright/test';
// E-01 视觉验收:登录 → /report → Canvas 750×1000 + 邀请码 + 二维码区 + 保存按钮
const BE = 'http://localhost:8756';
const FE = 'http://localhost:5173';
test('E-01 战报页渲染与出图', async ({ page }) => {
const name = 'e01shot_' + Math.random().toString(36).slice(2, 8);
// 注册拿 token(经后端直调)
const reg = await page.request.post(BE + '/api/auth/register', { data: { username: name, password: 'e2ePass123' } });
expect(reg.status()).toBe(200);
const { token } = await reg.json();
// token 注入(前端 tokenStore 键名:ed_auth)
await page.goto(FE + '/login');
await page.evaluate((t) => {
localStorage.setItem('ed_auth', t);
localStorage.setItem('ed_user_hint', JSON.stringify({ username: 'shot' }));
}, token);
await page.goto(FE + '/report');
await expect(page.getByRole('heading', { name: /本周学习周报/ })).toBeVisible({ timeout: 10000 });
const canvas = page.locator('canvas[aria-label="学习周报图片预览"]');
await expect(canvas).toBeVisible();
const box = await canvas.boundingBox();
console.log('canvas-css-box:', JSON.stringify(box));
// Canvas 位图必须 1500×2000(750×1000 @2x)
const size = await canvas.evaluate((c: HTMLCanvasElement) => ({ w: c.width, h: c.height }));
console.log('canvas-bitmap:', JSON.stringify(size));
expect(size.w).toBe(1500);
expect(size.h).toBe(2000);
await expect(page.getByRole('button', { name: /分享 \/ 保存图片/ })).toBeVisible();
await page.screenshot({ path: 'test-results/e01-report.png', fullPage: true });
});