Add Site Safety Assistant (ssa) role replacing reporter, supervisor and capa_owner. Portals move under /ssa (overview, my-reports, incidents, capas). Update RLS, schema, API role checks, notification recipients, nav and tests. Add db/ops/2026-11-06-merge-roles-into-ssa.sql (not yet applied; needs owner go-ahead and a pg_dump first). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
30 lines
788 B
TypeScript
30 lines
788 B
TypeScript
// __tests__/lib/auth/roles.test.ts
|
|
import { describe, it, expect } from 'vitest'
|
|
import { getRoleHome, ROLE_HOME, ALL_ROLES } from '@/lib/auth/roles'
|
|
|
|
describe('getRoleHome', () => {
|
|
it('returns /ssa for ssa role', () => {
|
|
expect(getRoleHome('ssa')).toBe('/ssa')
|
|
})
|
|
|
|
it('returns /hse for hse role', () => {
|
|
expect(getRoleHome('hse')).toBe('/hse')
|
|
})
|
|
|
|
it('returns /management for management role', () => {
|
|
expect(getRoleHome('management')).toBe('/management')
|
|
})
|
|
|
|
it('returns /admin for admin role', () => {
|
|
expect(getRoleHome('admin')).toBe('/admin')
|
|
})
|
|
|
|
it('ROLE_HOME covers exactly 4 roles', () => {
|
|
expect(Object.keys(ROLE_HOME)).toHaveLength(4)
|
|
})
|
|
|
|
it('ALL_ROLES lists exactly 4 roles', () => {
|
|
expect(ALL_ROLES).toHaveLength(4)
|
|
})
|
|
})
|