|
| 1 | +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | +// |
| 3 | +// Regression guard for ADR-0057 (sys_department → sys_business_unit). The rename |
| 4 | +// once half-landed: the object label said "业务单元" while field labels still said |
| 5 | +// "上级部门" / "部门负责人". This asserts the object/plural label AND every FIELD |
| 6 | +// label across all locales no longer retains the old term. |
| 7 | +// |
| 8 | +// Scope is LABELS only — intentionally NOT field descriptions/help, NOT the `kind` |
| 9 | +// enum value `department` (a business unit can be OF KIND department), and NOT the |
| 10 | +// multi-concept node descriptions that list kinds. Those legitimately keep the word. |
| 11 | + |
| 12 | +import { describe, it, expect } from 'vitest'; |
| 13 | +import { enObjects } from './en.objects.generated.js'; |
| 14 | +import { zhCNObjects } from './zh-CN.objects.generated.js'; |
| 15 | +import { jaJPObjects } from './ja-JP.objects.generated.js'; |
| 16 | +import { esESObjects } from './es-ES.objects.generated.js'; |
| 17 | + |
| 18 | +const LOCALES = [ |
| 19 | + { name: 'en', objs: enObjects as Record<string, any>, old: /\bDepartment\b/ }, |
| 20 | + { name: 'zh-CN', objs: zhCNObjects as Record<string, any>, old: /部门/ }, |
| 21 | + { name: 'ja-JP', objs: jaJPObjects as Record<string, any>, old: /部門/ }, |
| 22 | + { name: 'es-ES', objs: esESObjects as Record<string, any>, old: /Departamento/ }, |
| 23 | +]; |
| 24 | +const OBJECTS = ['sys_business_unit', 'sys_business_unit_member']; |
| 25 | + |
| 26 | +describe('ADR-0057 BU rename — no stale "department" in object/field labels', () => { |
| 27 | + for (const { name, objs, old } of LOCALES) { |
| 28 | + for (const objName of OBJECTS) { |
| 29 | + it(`${name}: ${objName} object + field labels are fully renamed`, () => { |
| 30 | + const o = objs[objName]; |
| 31 | + expect(o, `${objName} missing from ${name} bundle`).toBeTruthy(); |
| 32 | + for (const key of ['label', 'pluralLabel'] as const) { |
| 33 | + if (o[key]) expect(String(o[key]), `${name} ${objName}.${key}`).not.toMatch(old); |
| 34 | + } |
| 35 | + for (const [fname, field] of Object.entries(o.fields ?? {})) { |
| 36 | + const label = (field as any)?.label; |
| 37 | + if (label) expect(String(label), `${name} ${objName}.fields.${fname}.label`).not.toMatch(old); |
| 38 | + } |
| 39 | + }); |
| 40 | + } |
| 41 | + } |
| 42 | +}); |
0 commit comments