// 已读取AGENTS.md import * as fs from 'fs'; import * as path from 'path'; /** * 第八十一批:新页面必须复用全局主题变量(随 theme-warm/theme-cool 切换自适应)。 * 背景:优惠券页/消息页初版写死深色,切到「暖阳晨曦」主题时不跟随,配色不一致。 */ describe('第八十一批主题一致性闸门', () => { const root = path.resolve(__dirname, '../../'); const read = (p: string) => fs.readFileSync(path.join(root, p), 'utf-8'); const coupons = read('pwuniapp/pages/user/coupons.vue'); const notifications = read('pwuniapp/pages/user/notifications.vue'); const workspace = read('pwuniapp/pages/expert/workspace.vue'); it('优惠券页使用全局主题变量而非写死配色', () => { for (const v of ['var(--bg-primary', 'var(--bg-surface', 'var(--color-brand-gradient', 'var(--text-primary', 'var(--text-secondary', 'var(--text-muted', 'var(--border-subtle', 'var(--nav-bg']) { expect(coupons).toContain(v); } expect(coupons).toContain("'theme-' + currentThemeKey"); }); it('消息通知页使用全局主题变量', () => { for (const v of ['var(--bg-primary', 'var(--bg-surface', 'var(--color-brand', 'var(--text-primary', 'var(--text-muted', 'var(--border-subtle', 'var(--nav-bg']) { expect(notifications).toContain(v); } expect(notifications).toContain("'theme-' + currentThemeKey"); }); it('大神工作台新增表单样式复用主题变量', () => { expect(workspace).toContain('var(--bg-surface-elevated'); expect(workspace).toContain('var(--color-brand'); expect(workspace).toContain('var(--text-secondary'); expect(workspace).toContain('var(--text-primary'); }); it('新页面导航栏遵循统一规范(总高=安全区,内容行贴底对齐胶囊,标题绝对居中)', () => { for (const page of [coupons, notifications]) { expect(page).toContain('height: var(--safe-header-gap'); expect(page).toContain('position: absolute;'); expect(page).toContain('bottom: 0;'); expect(page).toContain('height: var(--capsule-height'); expect(page).toContain('transform: translateX(-50%)'); expect(page).toContain('flex-direction: column'); } }); it('全局主题变量在 App.vue 中按主题定义', () => { const app = read('pwuniapp/App.vue'); expect(app).toContain(':root, page {'); expect(app).toContain('.theme-warm {'); expect(app).toContain('--color-brand-gradient'); }); });