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__', }) }) })