安全/鉴权:登出清服务端 httpOnly 令牌、登录 IP 限流前置 bcrypt、停用账号 令牌在 6 个内联 role handler 失效、admin/items 存在性 oracle 认证前置、 同意偏好 sanitize fail-closed、api-crypto 按 HTTP 方法判体。 CMS:workflow 状态更新+审计收进交互式 $transaction(失败即回滚)、编辑器 richtext 走 textarea 防换行损毁、array/object 子字段按作用域读写防污染、 about/contact/erp-upgrade 补 ISR revalidate 与路由映射。 UI/a11y:AnimatedCounter 入视口前显起点、CLS 累计上报、MetricCard 动画入 effect 并卸载取消 rAF、后台状态四态映射/搜索防抖+序号守卫/媒体单 input/ 吞错改横幅/表单 label-aria 关联。 新增对应判别性单测与 pagination/rate-limit/client-ip/sanitize/validate-content-data 等模块及 tests-integration 真库集成层。
171 lines
8.2 KiB
TypeScript
171 lines
8.2 KiB
TypeScript
// @ts-nocheck
|
||
import { describe, it, expect } from '@jest/globals';
|
||
import { DESIGN_SYSTEM } from './design-system';
|
||
|
||
describe('DESIGN_SYSTEM', () => {
|
||
describe('animation configuration', () => {
|
||
it('has duration values', () => {
|
||
expect(DESIGN_SYSTEM.animation.duration).toBeDefined();
|
||
expect(DESIGN_SYSTEM.animation.duration.fast).toBe('0.2s');
|
||
expect(DESIGN_SYSTEM.animation.duration.normal).toBe('0.4s');
|
||
expect(DESIGN_SYSTEM.animation.duration.slow).toBe('0.6s');
|
||
expect(DESIGN_SYSTEM.animation.duration.slower).toBe('0.8s');
|
||
expect(DESIGN_SYSTEM.animation.duration.countUp).toBe('2s');
|
||
});
|
||
|
||
it('has easing functions', () => {
|
||
expect(DESIGN_SYSTEM.animation.easing).toBeDefined();
|
||
expect(DESIGN_SYSTEM.animation.easing.smooth).toMatch(/^cubic-bezier\(/);
|
||
expect(DESIGN_SYSTEM.animation.easing.bounce).toMatch(/^cubic-bezier\(/);
|
||
expect(DESIGN_SYSTEM.animation.easing.easeOut).toMatch(/^cubic-bezier\(/);
|
||
expect(DESIGN_SYSTEM.animation.easing.easeInOut).toMatch(/^cubic-bezier\(/);
|
||
});
|
||
|
||
it('has delay values', () => {
|
||
expect(DESIGN_SYSTEM.animation.delay).toBeDefined();
|
||
expect(DESIGN_SYSTEM.animation.delay.stagger).toBe(0.08);
|
||
expect(DESIGN_SYSTEM.animation.delay.section).toBe(0.15);
|
||
});
|
||
});
|
||
|
||
describe('spacing configuration', () => {
|
||
it('has section spacing', () => {
|
||
expect(DESIGN_SYSTEM.spacing.section).toBeDefined();
|
||
expect(DESIGN_SYSTEM.spacing.section.py).toContain('py-20');
|
||
expect(DESIGN_SYSTEM.spacing.section.pyCompact).toContain('py-16');
|
||
});
|
||
|
||
it('has container spacing', () => {
|
||
expect(DESIGN_SYSTEM.spacing.container).toBeDefined();
|
||
expect(DESIGN_SYSTEM.spacing.container.default).toContain('max-w-7xl');
|
||
expect(DESIGN_SYSTEM.spacing.container.narrow).toContain('max-w-5xl');
|
||
expect(DESIGN_SYSTEM.spacing.container.wide).toContain('max-w-[1400px]');
|
||
});
|
||
|
||
it('has grid spacing', () => {
|
||
expect(DESIGN_SYSTEM.spacing.grid).toBeDefined();
|
||
expect(DESIGN_SYSTEM.spacing.grid.gap).toContain('gap-6');
|
||
expect(DESIGN_SYSTEM.spacing.grid.gapSmall).toContain('gap-4');
|
||
});
|
||
});
|
||
|
||
describe('typography configuration', () => {
|
||
it('has hero typography', () => {
|
||
expect(DESIGN_SYSTEM.typography.hero).toBeDefined();
|
||
expect(DESIGN_SYSTEM.typography.hero.title).toContain('text-4xl');
|
||
expect(DESIGN_SYSTEM.typography.hero.subtitle).toContain('text-lg');
|
||
expect(DESIGN_SYSTEM.typography.hero.description).toContain('text-base');
|
||
});
|
||
|
||
it('has section typography', () => {
|
||
expect(DESIGN_SYSTEM.typography.section).toBeDefined();
|
||
expect(DESIGN_SYSTEM.typography.section.title).toContain('text-3xl');
|
||
expect(DESIGN_SYSTEM.typography.section.subtitle).toContain('text-lg');
|
||
expect(DESIGN_SYSTEM.typography.section.body).toContain('text-base');
|
||
});
|
||
|
||
it('has card typography', () => {
|
||
expect(DESIGN_SYSTEM.typography.card).toBeDefined();
|
||
expect(DESIGN_SYSTEM.typography.card.title).toContain('text-lg');
|
||
expect(DESIGN_SYSTEM.typography.card.description).toContain('text-sm');
|
||
});
|
||
});
|
||
|
||
describe('effects configuration', () => {
|
||
it('has inkGlow effect', () => {
|
||
expect(DESIGN_SYSTEM.effects.inkGlow).toBeDefined();
|
||
expect(DESIGN_SYSTEM.effects.inkGlow.border).toContain('conic-gradient');
|
||
expect(DESIGN_SYSTEM.effects.inkGlow.glow).toContain('radial-gradient');
|
||
expect(DESIGN_SYSTEM.effects.inkGlow.speed).toBe('3s');
|
||
});
|
||
|
||
it('has hover effect', () => {
|
||
expect(DESIGN_SYSTEM.effects.hover).toBeDefined();
|
||
expect(DESIGN_SYSTEM.effects.hover.translateY).toBe('-4px');
|
||
expect(DESIGN_SYSTEM.effects.hover.shadow).toBe('shadow-xl');
|
||
expect(DESIGN_SYSTEM.effects.hover.transition).toContain('cubic-bezier');
|
||
});
|
||
|
||
it('has scroll animation configuration', () => {
|
||
expect(DESIGN_SYSTEM.effects.scroll).toBeDefined();
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp).toBeDefined();
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.initial).toEqual({ opacity: 0, y: 24 });
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.animate).toEqual({ opacity: 1, y: 0 });
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.viewport).toEqual({ once: true, margin: '-80px' });
|
||
// CONTEXT.md「动效设计四原则」:入场 180–280ms(--transition-fast … --transition-normal),
|
||
// 子元素 stagger 30–60ms。断言区间而非具体值,令牌漂移时才会红。
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.transition.duration).toBeGreaterThanOrEqual(0.18);
|
||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.transition.duration).toBeLessThanOrEqual(0.28);
|
||
expect(DESIGN_SYSTEM.effects.scroll.staggerChildren.delay).toBeGreaterThanOrEqual(0.03);
|
||
expect(DESIGN_SYSTEM.effects.scroll.staggerChildren.delay).toBeLessThanOrEqual(0.06);
|
||
});
|
||
});
|
||
|
||
describe('color references', () => {
|
||
it('has brand colors', () => {
|
||
expect(DESIGN_SYSTEM.colors.brand).toBeDefined();
|
||
expect(DESIGN_SYSTEM.colors.brand.primary).toContain('var(--color-brand)');
|
||
expect(DESIGN_SYSTEM.colors.brand.light).toContain('var(--color-brand-bg)');
|
||
expect(DESIGN_SYSTEM.colors.brand.lighter).toContain('rgba');
|
||
expect(DESIGN_SYSTEM.colors.brand.gradient).toContain('linear-gradient');
|
||
});
|
||
|
||
it('has neutral color scale', () => {
|
||
expect(DESIGN_SYSTEM.colors.neutral).toBeDefined();
|
||
expect(DESIGN_SYSTEM.colors.neutral[50]).toContain('var(--color-bg-primary)');
|
||
expect(DESIGN_SYSTEM.colors.neutral[100]).toContain('var(--color-bg-section)');
|
||
expect(DESIGN_SYSTEM.colors.neutral[200]).toContain('var(--color-border-primary)');
|
||
expect(DESIGN_SYSTEM.colors.neutral[700]).toContain('var(--color-text-primary)');
|
||
expect(DESIGN_SYSTEM.colors.neutral[900]).toContain('var(--color-text-primary)');
|
||
});
|
||
|
||
it('has ink colors', () => {
|
||
expect(DESIGN_SYSTEM.colors.ink).toBeDefined();
|
||
expect(DESIGN_SYSTEM.colors.ink.light).toContain('rgba');
|
||
expect(DESIGN_SYSTEM.colors.ink.medium).toContain('rgba');
|
||
expect(DESIGN_SYSTEM.colors.ink.texture).toContain('repeating-linear-gradient');
|
||
});
|
||
});
|
||
|
||
describe('component styles', () => {
|
||
it('has card component styles', () => {
|
||
expect(DESIGN_SYSTEM.components.card).toBeDefined();
|
||
expect(DESIGN_SYSTEM.components.card.base).toContain('rounded-2xl');
|
||
expect(DESIGN_SYSTEM.components.card.hover).toContain('hover:');
|
||
expect(DESIGN_SYSTEM.components.card.padding).toContain('p-6');
|
||
});
|
||
|
||
it('has badge component styles', () => {
|
||
expect(DESIGN_SYSTEM.components.badge).toBeDefined();
|
||
expect(DESIGN_SYSTEM.components.badge.base).toContain('rounded-full');
|
||
expect(DESIGN_SYSTEM.components.badge.variants).toBeDefined();
|
||
// 双通道(DESIGN.md:154):底色仍走 --color-brand-bg,文字走翻转的 --color-brand-ink。
|
||
expect(DESIGN_SYSTEM.components.badge.variants.primary).toContain('bg-[var(--color-brand-bg)]');
|
||
expect(DESIGN_SYSTEM.components.badge.variants.primary).toContain('text-brand-ink');
|
||
expect(DESIGN_SYSTEM.components.badge.variants.secondary).toContain('var(--color-text-secondary)');
|
||
expect(DESIGN_SYSTEM.components.badge.variants.success).toContain('text-green-700');
|
||
expect(DESIGN_SYSTEM.components.badge.variants.warning).toContain('text-yellow-700');
|
||
});
|
||
|
||
it('has button component styles', () => {
|
||
expect(DESIGN_SYSTEM.components.button).toBeDefined();
|
||
expect(DESIGN_SYSTEM.components.button.primary).toContain('bg-[var(--color-brand)]');
|
||
expect(DESIGN_SYSTEM.components.button.secondary).toContain('border-[var(--color-border-primary)]');
|
||
expect(DESIGN_SYSTEM.components.button.ghost).toContain('text-brand-ink');
|
||
});
|
||
|
||
it('has metric component styles', () => {
|
||
expect(DESIGN_SYSTEM.components.metric).toBeDefined();
|
||
expect(DESIGN_SYSTEM.components.metric.container).toContain('rounded-xl');
|
||
expect(DESIGN_SYSTEM.components.metric.value).toContain('text-3xl');
|
||
expect(DESIGN_SYSTEM.components.metric.label).toContain('text-sm');
|
||
expect(DESIGN_SYSTEM.components.metric.description).toContain('text-xs');
|
||
});
|
||
});
|
||
|
||
describe('immutability', () => {
|
||
it('is frozen', () => {
|
||
expect(Object.isFrozen(DESIGN_SYSTEM)).toBe(true);
|
||
});
|
||
});
|
||
}); |