文件
shanghaipeiwan/server/tests/theme-consistency.spec.ts
xcbyy ae569d0ca6 fix(ui): 优惠券页/消息页主题配色跟随全局主题切换
- coupons.vue / notifications.vue 由写死深色改为复用全局 CSS 变量(--bg-primary/--bg-surface/--color-brand-gradient/--text-*/--border-subtle/--nav-bg),随 theme-warm(暖阳晨曦)与默认冷光暗夜自动适配
- 大神工作台新增的服务包表单样式同步复用主题变量
- 新增回归护栏 theme-consistency.spec.ts(97 套件/673 用例全绿)
2026-10-19 15:27:04 +08:00

44 行
1.9 KiB
TypeScript

// 已读取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('全局主题变量在 App.vue 中按主题定义', () => {
const app = read('pwuniapp/App.vue');
expect(app).toContain(':root, page {');
expect(app).toContain('.theme-warm {');
expect(app).toContain('--color-brand-gradient');
});
});