phase 16 implementation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { analyticsEventRegistry, validateAnalyticsEvent } from '@/lib/analytics/events';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const context = {
|
||||
routeId: 'home',
|
||||
locale: 'en',
|
||||
direction: 'ltr',
|
||||
resolvedTheme: 'light',
|
||||
source: 'hero',
|
||||
} as const;
|
||||
|
||||
describe('analytics contract', () => {
|
||||
it('accepts allowlisted non-personal demo events', () => {
|
||||
expect(validateAnalyticsEvent('demo_open', context)).toEqual({ name: 'demo_open', context });
|
||||
});
|
||||
|
||||
it('rejects unknown events and payload properties', () => {
|
||||
expect(validateAnalyticsEvent('lead_created', context)).toBeNull();
|
||||
expect(
|
||||
validateAnalyticsEvent('demo_open', { ...context, email: 'person@example.test' }),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('marks every registry entry as non-personal and consent-gated', () => {
|
||||
expect(analyticsEventRegistry.every((event) => !event.personalData)).toBe(true);
|
||||
expect(analyticsEventRegistry.every((event) => event.consentCategory === 'analytics')).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user