Files
prop-ai-hr/frontend/src/views/system/tenant-org-binding.test.ts
T

33 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const frontendRoot = existsSync(resolve(process.cwd(), 'src')) ? process.cwd() : resolve(process.cwd(), 'frontend');
const src = (...parts: string[]) => readFileSync(resolve(frontendRoot, 'src', ...parts), 'utf8');
describe('tenant organization binding governance contract', () => {
it('keeps the platform page superadmin-only and exposes the four required interaction states', () => {
const router = src('router', 'index.ts');
const page = src('views', 'system', 'tenant-org-binding.vue');
expect(router).toContain("path: 'tenant-org-binding'");
expect(router).toContain("title: '租户与组织绑定'");
expect(router).toContain('roles: tenantGovernanceRoles');
expect(page).toContain('租户与组织绑定');
expect(page).toContain('执行预检');
expect(page).toContain('发现 ${precheckResult.conflicts.length} 项独占范围冲突');
expect(page).toContain('采用仅汇总方案');
expect(src('layout', 'components', 'Navbar.vue')).toContain("router.currentRoute.value.path !== '/system/tenant-org-binding'");
});
it('does not offer a browser-supplied synchronization scope and labels aggregate-only correctly', () => {
const api = src('api', 'aihr', 'tenant-org-governance.ts');
const page = src('views', 'system', 'tenant-org-binding.vue');
expect(api).toContain('/api/aihr/platform/tenant-org-bindings/precheck');
expect(api).not.toContain('groupId');
expect(api).not.toContain('companyId');
expect(api).not.toContain('departmentId');
expect(page).toContain('仅汇总范围不保存人员明细,且没有组织同步入口');
expect(page).toContain('当前开放 API 只支持集团、公司或部门作为同步边界');
});
});