Files
carmanagement/apps/homepage/tests/unit/integrations/analytics.test.ts
T
root d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
redesign the homepage
2026-06-26 16:27:21 -04:00

31 lines
1020 B
TypeScript

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,
);
});
});