gongxiangp2/lib/__tests__/department-dashboard-scope.test.ts
2026-08-19 12:08:38 +08:00

31 lines
964 B
TypeScript

import { buildDepartmentDashboardEmployeeWhere } from '@/lib/department-dashboard-scope'
describe('department dashboard scope', () => {
it('matches only the exact department subtree and memberships', () => {
const where = buildDepartmentDashboardEmployeeWhere(' 集团 / 品牌中心 ')
expect(where).toEqual({
OR: [
{ departmentPath: '集团/品牌中心' },
{ departmentPath: { startsWith: '集团/品牌中心/' } },
{
departmentMemberships: {
some: {
OR: [
{ departmentPath: '集团/品牌中心' },
{ departmentPath: { startsWith: '集团/品牌中心/' } },
],
},
},
},
],
})
})
it('fails closed when no reliable department path is available', () => {
expect(buildDepartmentDashboardEmployeeWhere(null)).toEqual({
id: '__department_dashboard_scope_unavailable__',
})
})
})