Board component, security, test updates

This commit is contained in:
Francis Cao committed 2026-06-29 18:17:57 -07:00
1 parent f525898b79
commit ab5b1bf354
23 files changed
+1128 -180

No files matched your search

+11
View File
@@ -1,7 +1,18 @@
import type { BoardEntityType } from './boards';
export const BOARD_COMPONENT_COMPATIBILITY_MATRIX = {
EventsMetricsBar: ['website'],
EventsChart: ['website'],
Funnel: ['website'],
Goal: ['website'],
RealtimeActiveUsers: ['website'],
RealtimeHeader: ['website'],
RealtimeChart: ['website'],
RevenueMetricsBar: ['website'],
RevenueChart: ['website'],
RevenueMetricsTable: ['website'],
UTM: ['website'],
WeeklyTraffic: ['website'],
} as const satisfies Partial<Record<string, readonly BoardEntityType[]>>;
export function getSupportedBoardComponentEntityTypes(componentType: string) {
+88
View File
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest';
import { getComponentDefinition } from '@/app/(main)/boards/boardComponentRegistry';
import {
BOARD_COMPONENT_COMPATIBILITY_MATRIX,
getSupportedBoardComponentEntityTypes,
@@ -14,14 +15,101 @@ test('isBoardComponentSupported rejects events chart on pixel and link boards',
expect(isBoardComponentSupported('EventsChart', BOARD_ENTITY_TYPES.link)).toBe(false);
});
test('isBoardComponentSupported rejects event metrics bar and weekly traffic on pixel and link boards', () => {
expect(isBoardComponentSupported('EventsMetricsBar', BOARD_ENTITY_TYPES.pixel)).toBe(false);
expect(isBoardComponentSupported('EventsMetricsBar', BOARD_ENTITY_TYPES.link)).toBe(false);
expect(isBoardComponentSupported('WeeklyTraffic', BOARD_ENTITY_TYPES.pixel)).toBe(false);
expect(isBoardComponentSupported('WeeklyTraffic', BOARD_ENTITY_TYPES.link)).toBe(false);
});
test('board component compatibility matrix defines website-only components explicitly', () => {
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.EventsMetricsBar).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.EventsChart).toEqual([BOARD_ENTITY_TYPES.website]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.Funnel).toEqual([BOARD_ENTITY_TYPES.website]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.Goal).toEqual([BOARD_ENTITY_TYPES.website]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RealtimeActiveUsers).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RealtimeHeader).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RealtimeChart).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RevenueMetricsBar).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RevenueChart).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.RevenueMetricsTable).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.UTM).toEqual([BOARD_ENTITY_TYPES.website]);
expect(BOARD_COMPONENT_COMPATIBILITY_MATRIX.WeeklyTraffic).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('EventsMetricsBar')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('EventsChart')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('Funnel')).toEqual([BOARD_ENTITY_TYPES.website]);
expect(getSupportedBoardComponentEntityTypes('Goal')).toEqual([BOARD_ENTITY_TYPES.website]);
expect(getSupportedBoardComponentEntityTypes('RealtimeActiveUsers')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('RealtimeHeader')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('RealtimeChart')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('RevenueMetricsBar')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('RevenueChart')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('RevenueMetricsTable')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
expect(getSupportedBoardComponentEntityTypes('UTM')).toEqual([BOARD_ENTITY_TYPES.website]);
expect(getSupportedBoardComponentEntityTypes('WeeklyTraffic')).toEqual([
BOARD_ENTITY_TYPES.website,
]);
});
test('isBoardComponentSupported leaves other components available for all board entities', () => {
expect(isBoardComponentSupported('WebsiteChart', BOARD_ENTITY_TYPES.pixel)).toBe(true);
expect(isBoardComponentSupported('TextBlock', BOARD_ENTITY_TYPES.link)).toBe(true);
});
test('metrics table limits pixel and link boards to overview-page metric types', () => {
const definition = getComponentDefinition('MetricsTable');
const options = definition?.configFields?.find(field => field.name === 'type')?.optionsByEntityType;
expect(options?.pixel?.map(option => option.value)).toEqual([
'referrer',
'channel',
'country',
'region',
'city',
'browser',
'os',
'device',
]);
expect(options?.link?.map(option => option.value)).toEqual([
'referrer',
'channel',
'country',
'region',
'city',
'browser',
'os',
'device',
]);
});