43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { getGuardedAiModuleForPath, isAiModuleAllowed, isProgrammingProviderRoute } from '@/lib/ai-modules';
|
|
import {
|
|
DEFAULT_MODULE_ACCESS,
|
|
MODULE_ACCESS_KEYS,
|
|
normalizeModuleAccess,
|
|
} from '../../shared/module-access';
|
|
|
|
describe('module access projection', () => {
|
|
it('honors an explicit cloud Agent denial and does not initialize Code for its route', () => {
|
|
const access = normalizeModuleAccess({ cloud_agents: false });
|
|
expect(isAiModuleAllowed('cloud_agents', access)).toBe(false);
|
|
expect(getGuardedAiModuleForPath('/cloud-agents')).toBe('cloud_agents');
|
|
expect(isProgrammingProviderRoute('/cloud-agents')).toBe(false);
|
|
});
|
|
it('contains only the four supported product modules', () => {
|
|
expect(MODULE_ACCESS_KEYS).toEqual(['programming', 'design', 'robot', 'cloud_agents']);
|
|
expect(DEFAULT_MODULE_ACCESS).toEqual({
|
|
programming: true,
|
|
design: true,
|
|
robot: true,
|
|
cloud_agents: true,
|
|
});
|
|
});
|
|
|
|
it('drops the retired Learning key from legacy or upstream policy data', () => {
|
|
const access = normalizeModuleAccess({
|
|
programming: false,
|
|
design: true,
|
|
learning: false,
|
|
robot: false,
|
|
});
|
|
|
|
expect(access).toEqual({
|
|
programming: false,
|
|
design: true,
|
|
robot: false,
|
|
cloud_agents: true,
|
|
});
|
|
expect(access).not.toHaveProperty('learning');
|
|
});
|
|
});
|