Squash merge PR #23. Included changes: - complete occupancy check-in required fields/default payload - improve responsive admin management pages - fix attendance edge cases and attendance period config - refine wallet/finance-related workflow handling Checks: - npm run typecheck -w apps/admin - npm run typecheck -w apps/server
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
findFirstAccessiblePath,
|
|
getRequiredPermission,
|
|
canAccessPath,
|
|
} from './permission-navigation';
|
|
|
|
describe('permission navigation', () => {
|
|
it('does not default to dashboard when dashboard permission is absent', () => {
|
|
const permissions = ['class:view', 'schedule:view'];
|
|
expect(findFirstAccessiblePath(permissions)).toBe('/classes');
|
|
});
|
|
|
|
it('lands teachers on the teacher workspace without global student or class access', () => {
|
|
expect(
|
|
findFirstAccessiblePath(['teacher-workspace:view', 'schedule:view', 'attendance:view']),
|
|
).toBe('/teacher-workspace');
|
|
expect(canAccessPath('/students', ['teacher-workspace:view'])).toBe(false);
|
|
expect(canAccessPath('/classes', ['teacher-workspace:view'])).toBe(false);
|
|
});
|
|
|
|
it('uses dashboard when it is the first accessible page', () => {
|
|
expect(findFirstAccessiblePath(['dashboard:view', 'student:view'])).toBe('/dashboard');
|
|
});
|
|
|
|
it('returns null when the user has no page permissions', () => {
|
|
expect(findFirstAccessiblePath(['profile:view'])).toBeNull();
|
|
});
|
|
|
|
it('keeps route permission lookup aligned for nested detail routes', () => {
|
|
expect(getRequiredPermission('/classes/12')).toBe('class:view');
|
|
expect(getRequiredPermission('/students/8/profile')).toBe('student:view');
|
|
expect(canAccessPath('/ai-config', ['ai:config:read'])).toBe(true);
|
|
expect(canAccessPath('/ai-config', ['integration:read'])).toBe(false);
|
|
});
|
|
});
|