Skip to content

Commit bfd6b6b

Browse files
fix(i18n): an approval rejection reads 驳回 in Chinese on the runtime surfaces (#35175)
Fixes #35021 repo:objectstack#1 · os-warren · session_01JQwxbXBffgVtUPBEY2nLFm Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:审批运行界面(审批中心、记录页审批条、审批动态、审批请求页的驳回按钮与状态、邮件确认页)的中文从「拒绝」改为「驳回」;简体 21 条、繁体 21 条界面词条,审批插件 zh-CN 5 处标签,邮件页 3 处。 - 为什么改:设计器里审批分支叫「驳回」,审批人点的却是「拒绝」,同一件事两个说法;按裁决 6973602227(选项 A)统一为「驳回」。 - 风险与回滚:只改显示文案,存储的状态 `rejected` 和动作键 `reject` 不变;权限、邀请、AI 工具审批里的「拒绝」保留。回滚即 revert 本 PR。 - 先看:`ui/packages/i18n/src/locales/zh-Hans.ts` 的 `approvalsInbox` 块(21 处);`packages/plugins/plugin-approvals/src/translations/zh-CN.objects.generated.ts`(驳回按钮、状态、审批动态);`packages/plugins/plugin-approvals/src/action-link-pages.ts`(邮件确认页)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/i18n/src/__tests__/approval-reject-wording-35021.test.ts`,预期 9 条全绿;或在 zh-CN 下打开审批中心,行内按钮显示「通过」「驳回」,已驳回的请求状态显示「已驳回」。 - 需要你做的:无,席位落地。 ## What changes Display text only. The stored status `rejected` and the action key `reject` are unchanged; en and every other language are untouched. - **`@object-ui/i18n`, `approvalsInbox`, zh-Hans 拒绝 to 驳回 and zh-Hant 拒絕 to 駁回 (21 keys each):** `statusRejected`, `sendBackAutoRejected`, `keyboardHint`, `actReject`, `reject`, `rejecting`, `rejectN`, `bulkRejectTitle` (+ `_one`, `_other`), `bulkRejectBody`, `bulkRejected` (+ `_one`, `_other`), `rejectOneTitle`, `rejectOneBody`, `rejectTitle`, `rejectBody`, `inlineRejected`, `rejectedToast`, `whyDisabledSubmitter`. zh-Hant was regenerated with `pnpm --filter @object-ui/i18n gen:zh-hant`, which reports it byte-identical to the committed file ("already current"). - **`@objectstack/plugin-approvals`, zh-CN bundle (hand-written translated leaf values, no key added or dropped; `check:i18n` in sync):** `sys_approval_request` status `rejected` 已驳回; `_actions.approval_reject` `label` 驳回, `description` 驳回该请求?驳回对所有审批人立即生效。, `successMessage` 已驳回“…”; `sys_approval_action` action option `reject` 驳回. The zh-Hant bundle already said 駁回 everywhere and is unchanged. - **`action-link-pages.ts` (email action-link confirm and result pages):** `Reject · 驳回`, `确认驳回该审批请求?`, `⛔ Rejected · 已驳回`. Which key family serves each runtime surface named in the ruling: the inbox page, the record approvals panel, the approval decision panel and the history timeline read `approvalsInbox.*` (`actReject`, `statusRejected`, the confirm and toast keys); the record-page reject lever, its confirm question and success toast are the declared `sys_approval_request` action, localized from the plugin bundle (the admin-override label wraps that same declared label); the generic object views read the plugin bundle's status and action options. **Kept, with the reason** (zh-Hans, mirrored in zh-Hant; 39 lines still carry 拒 in each pack): - Access denial or a refusal by the server: `form.navigateRefused`, `list.loadErrorRejectedTitle`, the `list.userFilters` formula-sort hint, `console.importMappingsRefused`, `console.savedViewsRefused`, `console.settingsView.cryptoRefusalNoSubject`, `console.settingsView.mapKeyNotOfferedHint`, `console.assignedWork.transferRefused`, `auth.device.deny` / `denying` / `deniedTitle` / `denyFailed`, `oauth.consent.deny` / `denied`, `errors.forbidden`, `preview.changes.securityBlockTitle` (+ `_one`, `_other`), `preview.changes.securityRule.cbpNoRelation` / `cbpAmbiguousRelation`, `organization.settings.deleteConfirmDescription`, `cloudConnection.errors.accessDenied`, `marketplace.install.dependencyMissing.heading`, `connectorConnections.redirectUriMissing`, `element.component.apiRefused`. - Declining an invitation: `organization.invitations.status.rejected`, `organization.accept.decline` / `declined` / `declineFailed`. - AI tool approvals, a different concept: `aiApprovals.statusRejected` / `reject` / `outcomeReject` / `fieldRejectionReason` / `rejectTitle`, `console.system.aiApprovals.subtitle`, `console.ai.toolDenyReason`, `chatbot.toolState.denied`. - An upstream provider rejecting a connector credential (not approval): `connectorCredentials.statusRejected` (被拒绝) and `connectorCredentials.rejectedReason`. Not touched, as ruled: the designer and flow canvas (`engine.inspector.flowEdge.branchReject` 驳回, `engine.flowCanvas.rejectedEnd` 已驳回, the Problems-tab hint that interpolates the branch label), the server notifications (`translations/messages.ts`, already 驳回 / 駁回, no 拒绝 for approval), 「退回」 (send-back). ## Tests - New `ui/packages/i18n/src/__tests__/approval-reject-wording-35021.test.ts`: for zh-Hans and zh-Hant, no `approvalsInbox` string says 拒绝 / 拒絕 (enumeration asserted non-empty), every key named for the reject decision says 驳回 / 駁回, the decision verb and status read 驳回 / 已驳回, and access denial, invitations and `aiApprovals` keep 拒绝; plus the agreement case the card's acceptance asks for: the runtime `actReject` equals the designer's `branchReject`, and `statusRejected` equals the canvas `rejectedEnd`. - New `packages/plugins/plugin-approvals/src/approval-reject-wording-35021.test.ts`: through the real resolvers (`translateMetadataDocument`, `translateObject`), zh-CN and zh-Hant read 驳回 / 駁回 for the reject lever, the `rejected` status and the `reject` history row; the lever's question and toast say it; no `sys_approval_request` / `sys_approval_action` string in either bundle says 拒绝 / 拒絕; the email confirm and result pages say 驳回 and no 拒绝. - Updated pins: `approval-status-vocabulary.test.ts` zh-CN `rejected` is 已驳回; `approvalOverride-zh-wording-13402.test.ts` composes 管理员代为驳回 from the reject lever's label. ## Acceptance notes - Ablation, one per behaviour, through `scripts/ablation-replace.mjs` (anchor hit 1 to 0, blob moved, restored to the HEAD blob with `git diff HEAD` empty): zh-Hans `actReject` back to 拒绝 turns the ui pin red (4 of 9 failed, including the designer-agreement case); the zh-CN `approval_reject` label back to 拒绝 turns the plugin pin red (2 of 7 failed). No build was involved: both suites import the edited files by relative path. - Observed, not filed (not one of the three filing classes): the approve wording also differs across surfaces, the plugin bundle saying 已批准 / 批准 (zh-Hant 核准) where the inbox says 已通过 / 通过; outside this card's ruling. - The designer's approval-node inspector help (`ui/packages/app-shell/src/views/metadata-admin/i18n.ts`) still says 拒绝 in five strings (the mode help, the status-mirror help, the escalation help and its `auto_reject` option 自动拒绝, the revision-limit help). The ruling keeps the designer unchanged, so they are left; raised to the seat as an open question. ## Verification All readings on head `f850687b6` (branch merged with `origin/main` `2fea6d2a1`), except the targeted runs and ablations, taken on `d863192a0` before the merge, which touched neither package. <details><summary>Tests</summary> - `pnpm --dir ui exec vitest run packages/i18n/` (verify lock): VERDICT command-exit 0, Test Files 104 passed (104), Tests 1956 passed, 13 skipped. - `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2` (verify lock): VERDICT command-exit 0, Test Files 123 passed (123), Tests 1748 passed (1748). - `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0, test layer held at the ledgered 321 errors in 8 files, the new test file adds none. - `pnpm --filter @object-ui/i18n type-check`: exit 0, after building its dependency closure (the first run exited 2 on TS6305, `ui/packages/core/dist` not yet built; the test program lists both edited test files). - Ablation runs: see Acceptance notes. </details> <details><summary>Local gates</summary> - `dispatch-gates.mjs --commands` on this tree: 71 families; `--ran` reconciliation: 71 accounted, 70 run with exit 0, 1 NOT MEASURED, 0 unrun. - NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3 PREREQUISITE NOT MET (it reads every package's `dist`, and this worktree built only the two packages' closures); CI runs it. - Exit 0 among them: `pnpm check:i18n` (10 packages, all bundles in sync), `pnpm check:i18n-stale-fill`, `pnpm check:keyed-text-bounds`, `pnpm check:role-word`, `pnpm check:published-files`, `pnpm check:undeclared-dep-imports`, `pnpm check:nul-bytes`, `pnpm check:cross-package-test-inputs`, `pnpm check:test-source-alias`, `pnpm check:type-check-debt`, `node scripts/check-adr-0087-registration.mjs --base origin/main`, `node scripts/check-closing-keyword-parity.mjs`, `node scripts/check-issue-citations.mjs`, `pnpm --dir ui exec vitest run scripts/` (Test Files 171 passed, 2 skipped). - `pnpm --dir ui check:new-line-citations`: 0 new citations. - `node scripts/pm/overlap-check.mjs`: VERDICT clean; #35122 shares both locale files and merges cleanly. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbXBffgVtUPBEY2nLFm)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c480f33 commit bfd6b6b

11 files changed

Lines changed: 305 additions & 59 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/plugin-approvals': patch
3+
'@object-ui/i18n': patch
4+
'@object-ui/app-shell': patch
5+
---
6+
7+
fix(i18n): an approval rejection reads 驳回 in Chinese, on the runtime surfaces and in the designer's approval panel
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
In Chinese, the approval runtime now names the reject decision 驳回 (zh-Hant 駁回), the word the flow designer gives the approval branch and the server notifications already use. Before, the designer's branch said 驳回 while its approval-node help and the approver's buttons said 拒绝 for the same decision.
13+
14+
- `@object-ui/i18n`: the `approvalsInbox` strings in zh-Hans and zh-Hant: the inbox and record-bar buttons, the bulk and single confirm dialogs, the toasts, the status chip (已拒绝 → 已驳回), the history row, the keyboard hint and the send-back limit notice.
15+
- `@objectstack/plugin-approvals`: the zh-CN labels of `sys_approval_request` (the `approval_reject` lever, its confirm question and success toast, the `rejected` status) and of the `reject` row of `sys_approval_action`; the zh-Hant bundle already said 駁回. The email action-link confirm and result pages read 驳回.
16+
- `@object-ui/app-shell`: the approval node's zh panel in the flow designer: the multi-approver help, the status-mirror help, the escalation help and its `auto_reject` option label (自动拒绝 → 自动驳回; the stored `auto_reject` value is unchanged), and the revision-limit help. Its branch label and Problems hint already said 驳回; a zh-Hant session draws the same Simplified table.
17+
18+
拒绝 stays where it means access denial or declining an invitation, in the AI tool approvals, and in the designer's end-node refused outcome and its API-key, bulk-update and audit-outcome refusals. Display text only: the stored `rejected` status and the `reject` action key are unchanged, and English and the other languages are untouched.

‎packages/plugins/plugin-approvals/src/action-link-pages.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export function renderConfirmPage(input: {
8585
actPath: string;
8686
}): string {
8787
const approving = input.action === 'approve';
88-
const verb = approving ? 'Approve · 通过' : 'Reject · 拒绝';
88+
const verb = approving ? 'Approve · 通过' : 'Reject · 驳回';
8989
return shell(`${verb} — Approval`, `
9090
<h1>${approving ? '✅ Approve this request?' : '⛔ Reject this request?'}</h1>
91-
<p class="sub">${approving ? '确认通过该审批请求?' : '确认拒绝该审批请求?'}
91+
<p class="sub">${approving ? '确认通过该审批请求?' : '确认驳回该审批请求?'}
9292
Acting as · 操作身份:<b>${esc(input.approverId)}</b></p>
9393
${summaryRows(input.request)}
9494
<form method="post" action="${esc(input.actPath)}" class="actions">
@@ -100,7 +100,7 @@ export function renderConfirmPage(input: {
100100

101101
const RESULT_COPY: Record<string, { cls: string; title: string; body: string }> = {
102102
approved: { cls: 'ok', title: '✅ Approved · 已通过', body: 'The decision was recorded. · 审批结果已记录。' },
103-
rejected: { cls: 'ok', title: '⛔ Rejected · 已拒绝', body: 'The decision was recorded. · 审批结果已记录。' },
103+
rejected: { cls: 'ok', title: '⛔ Rejected · 已驳回', body: 'The decision was recorded. · 审批结果已记录。' },
104104
invalid: { cls: 'err', title: 'Invalid link · 链接无效', body: 'This link is not recognized. · 无法识别该链接。' },
105105
expired: { cls: 'warn', title: 'Link expired · 链接已过期', body: 'Ask the requester to send a new reminder. · 请让申请人重新发送催办。' },
106106
consumed: { cls: 'warn', title: 'Already used · 链接已使用', body: 'This link was already used once. · 该链接已被使用过。' },
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
//
3+
// Approval-rejection wording pin (#35021, ruling 6973602227, option A).
4+
//
5+
// In Chinese an approval rejection reads 驳回 (zh-Hant 駁回): the record-page
6+
// lever this plugin declares (`approval_reject`), its confirm question and
7+
// success toast, the `rejected` status, the `reject` row of the action history,
8+
// and the email action-link confirm and result pages. The flow designer's
9+
// approval branch and the server notifications (`./translations/messages.ts`)
10+
// already say it, so every surface names one decision with one word. The
11+
// stored values (`rejected`, `reject`) are not display text and do not change.
12+
//
13+
// The labels are read through the real resolvers, so the cases also prove the
14+
// bundles are REACHED: the declared labels are English, and 驳回 can only come
15+
// from a bundle.
16+
17+
import { describe, it, expect } from 'vitest';
18+
import { translateObject, translateMetadataDocument } from '@objectstack/spec/system';
19+
20+
import { ApprovalsTranslations } from './translations/index.js';
21+
import { zhCNObjects } from './translations/zh-CN.objects.generated.js';
22+
import { zhHantObjects } from './translations/zh-Hant.objects.generated.js';
23+
import { SysApprovalRequest } from './sys-approval-request.object.js';
24+
import { SysApprovalAction } from './sys-approval-action.object.js';
25+
import { renderConfirmPage, renderResultPage } from './action-link-pages.js';
26+
27+
const LOCALES = [
28+
{ locale: 'zh-CN', bundle: zhCNObjects, reject: '驳回', deny: '拒绝' },
29+
{ locale: 'zh-Hant', bundle: zhHantObjects, reject: '駁回', deny: '拒絕' },
30+
] as const;
31+
32+
const optionLabel = (object: unknown, field: string, value: string, locale: string): string | undefined => {
33+
const doc = translateObject(object as any, ApprovalsTranslations, { locale });
34+
const options = (doc as any)?.fields?.[field]?.options as Array<{ value: string; label?: string }> | undefined;
35+
return options?.find((o) => o.value === value)?.label;
36+
};
37+
38+
const servedAction = (locale: string, name: string): Record<string, unknown> | undefined => {
39+
const doc = translateMetadataDocument('object', SysApprovalRequest, ApprovalsTranslations, { locale });
40+
return ((doc as { actions?: Array<Record<string, unknown>> }).actions ?? []).find((a) => a.name === name);
41+
};
42+
43+
/** Every string leaf of a bundle subtree, with its dotted path. */
44+
const leaves = (node: unknown, path: string[] = []): Array<[string, string]> => {
45+
if (typeof node === 'string') return [[path.join('.'), node]];
46+
if (!node || typeof node !== 'object') return [];
47+
return Object.entries(node).flatMap(([key, child]) => leaves(child, [...path, key]));
48+
};
49+
50+
describe('approval rejection reads 驳回 (#35021)', () => {
51+
describe.each(LOCALES)('$locale', ({ locale, bundle, reject, deny }) => {
52+
it(`the reject lever, the rejected status and the reject history row read ${reject}`, () => {
53+
expect(servedAction(locale, 'approval_reject')?.label).toBe(reject);
54+
expect(optionLabel(SysApprovalRequest, 'status', 'rejected', locale)).toBe(`已${reject}`);
55+
expect(optionLabel(SysApprovalAction, 'action', 'reject', locale)).toBe(reject);
56+
});
57+
58+
it(`the reject lever's question and success toast say ${reject}`, () => {
59+
const node = (bundle as any).sys_approval_request._actions.approval_reject;
60+
expect(node.description).toContain(reject);
61+
expect(node.successMessage).toContain(reject);
62+
});
63+
64+
it(`no approval object string in the bundle says ${deny}`, () => {
65+
const all = [
66+
...leaves((bundle as any).sys_approval_request, ['sys_approval_request']),
67+
...leaves((bundle as any).sys_approval_action, ['sys_approval_action']),
68+
];
69+
expect(all.length).toBeGreaterThan(0);
70+
expect(all.filter(([, value]) => value.includes(deny))).toEqual([]);
71+
});
72+
});
73+
74+
it('the email action-link pages say 驳回 for the reject decision', () => {
75+
const request = { id: 'req_1', record_id: 'rec_1', object_name: 'expense', process_name: 'p' } as any;
76+
const confirm = renderConfirmPage({
77+
request,
78+
action: 'reject',
79+
approverId: 'user_1',
80+
token: 'tok',
81+
actPath: '/act',
82+
});
83+
const result = renderResultPage('rejected', request);
84+
expect(confirm).toContain('驳回');
85+
expect(result).toContain('已驳回');
86+
expect([confirm, result].filter((page) => page.includes('拒绝'))).toEqual([]);
87+
});
88+
});

‎packages/plugins/plugin-approvals/src/translations/approval-status-vocabulary.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ describe('approval status vocabulary (#7232)', () => {
100100
expect(resolvedStatusLabels('zh-CN')).toEqual({
101101
pending: '待审批',
102102
approved: '已批准',
103-
rejected: '已拒绝',
103+
// #35021: an approval rejection reads 驳回, the flow designer's word for
104+
// the branch; 拒绝 is left to access denial and invitations.
105+
rejected: '已驳回',
104106
recalled: '已撤回',
105107
returned: '已退回修改',
106108
// #13568. 已作废, deliberately not 已取消: `recalled` is already 已撤回

‎packages/plugins/plugin-approvals/src/translations/zh-CN.objects.generated.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
6161
options: {
6262
pending: "待审批",
6363
approved: "已批准",
64-
rejected: "已拒绝",
64+
rejected: "已驳回",
6565
recalled: "已撤回",
6666
returned: "已退回修改",
6767
cancelled: "已作废"
@@ -152,9 +152,9 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
152152
}
153153
},
154154
approval_reject: {
155-
label: "拒绝",
156-
description: "拒绝该请求?拒绝对所有审批人立即生效。",
157-
successMessage: "已拒绝“{{ result.request.record_title }}”",
155+
label: "驳回",
156+
description: "驳回该请求?驳回对所有审批人立即生效。",
157+
successMessage: "已驳回“{{ result.request.record_title }}”",
158158
params: {
159159
comment: {
160160
label: "审批意见"
@@ -280,7 +280,7 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
280280
options: {
281281
submit: "提交",
282282
approve: "批准",
283-
reject: "拒绝",
283+
reject: "驳回",
284284
recall: "撤回",
285285
escalate: "升级",
286286
reassign: "转签",

‎ui/packages/app-shell/src/views/metadata-admin/i18n.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
472472
},
473473
behavior: {
474474
label: '审批方式',
475-
help: '多个审批人如何组合。任何一个拒绝在所有模式下都是否决。',
475+
help: '多个审批人如何组合。任何一个驳回在所有模式下都是否决。',
476476
opts: {
477477
first_response: '首个响应生效',
478478
unanimous: '全员通过',
@@ -484,7 +484,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
484484
lockRecord: { label: '锁定记录', help: '此节点待处理期间锁定触发记录,禁止编辑。' },
485485
approvalStatusField: {
486486
label: '状态字段',
487-
help: '将请求状态(待审 / 通过 / 拒绝)镜像到的业务对象字段。应为只读。',
487+
help: '将请求状态(待审 / 通过 / 驳回)镜像到的业务对象字段。应为只读。',
488488
},
489489
'escalation.enabled': { label: 'SLA 升级', help: '在超时内未做决策时升级。' },
490490
'escalation.timeoutHours': {
@@ -493,8 +493,8 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
493493
},
494494
'escalation.action': {
495495
label: '超时动作',
496-
help: '超过期限后怎么办:改派给其他人、自动通过、自动拒绝,或通知某人(默认)。',
497-
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动拒绝' },
496+
help: '超过期限后怎么办:改派给其他人、自动通过、自动驳回,或通知某人(默认)。',
497+
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动驳回' },
498498
},
499499
'escalation.escalateTo': {
500500
label: '升级至',
@@ -504,7 +504,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
504504
'escalation.notifySubmitter': { label: '通知提交人', help: '升级时通知提交请求的人。' },
505505
maxRevisions: {
506506
label: '最多退回次数',
507-
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
507+
help: '请求自动驳回前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
508508
},
509509
// objectstack#34818 — was English in the zh panel.
510510
onEmptyApprovers: {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35021 — the approval node's zh panel names the reject decision
5+
* 驳回, the word of its branch connection, of the runtime inbox and of the
6+
* approval notifications (ruling 6973602227, option A; premise corrected
7+
* 6975255638). The `auto_reject` value is stored metadata and stays.
8+
*
9+
* Every string the panel draws is enumerated, from the inspector's own field
10+
* table and from the fields the engine serves (the contract's JSON Schema),
11+
* and none may say 拒绝. A zh-Hant session draws the same Simplified table
12+
* (`isZhLocale`), so it is held too. The end node's refused outcome is not an
13+
* approval decision and keeps 已拒绝 — the control that the replacement did not
14+
* reach past the approval node.
15+
*/
16+
17+
import { describe, expect, it } from 'vitest';
18+
import { z } from 'zod';
19+
import { ApprovalNodeConfigSchema } from '@objectstack/spec/automation';
20+
import { fieldsForNodeType, localizeFlowFields, type FlowConfigField } from './flow-node-config.js';
21+
import { jsonSchemaToFlowFields } from './json-schema-to-fields.js';
22+
23+
/** Every visible string of a field, with where it sits. */
24+
function strings(field: FlowConfigField): Array<[string, string]> {
25+
const out: Array<[string, string]> = [[`${field.id}.label`, field.label]];
26+
if (field.help) out.push([`${field.id}.help`, field.help]);
27+
if (field.placeholder) out.push([`${field.id}.placeholder`, field.placeholder]);
28+
for (const o of field.options ?? []) out.push([`${field.id}.opt.${o.value}`, o.label]);
29+
for (const c of field.columns ?? []) {
30+
out.push([`${field.id}.col.${c.key}.label`, c.label]);
31+
if (c.help) out.push([`${field.id}.col.${c.key}.help`, c.help]);
32+
for (const o of c.options ?? []) out.push([`${field.id}.col.${c.key}.opt.${o.value}`, o.label]);
33+
}
34+
return out;
35+
}
36+
37+
const PANELS = [
38+
['the inspector table', () => fieldsForNodeType('approval')],
39+
['the served contract', () => jsonSchemaToFlowFields(z.toJSONSchema(ApprovalNodeConfigSchema, { io: 'input' }))!],
40+
] as const;
41+
42+
describe('the approval node panel says 驳回 for the reject decision (objectstack#35021)', () => {
43+
describe.each(['zh-CN', 'zh-Hant'])('%s', (locale) => {
44+
it.each(PANELS)('no string of %s says 拒绝', (_name, fields) => {
45+
const all = localizeFlowFields('approval', fields(), locale).flatMap(strings);
46+
expect(all.length).toBeGreaterThan(0);
47+
expect(all.filter(([, text]) => text.includes('拒绝'))).toEqual([]);
48+
});
49+
50+
it('the reject-decision strings say 驳回, and the auto_reject value is unchanged', () => {
51+
const byId = new Map(localizeFlowFields('approval', fieldsForNodeType('approval'), locale).map((f) => [f.id, f]));
52+
for (const id of ['behavior', 'approvalStatusField', 'escalation.action', 'maxRevisions']) {
53+
expect(byId.get(id)?.help, id).toContain('驳回');
54+
}
55+
const autoReject = byId.get('escalation.action')?.options?.find((o) => o.value === 'auto_reject');
56+
expect(autoReject?.label).toBe('自动驳回');
57+
});
58+
});
59+
60+
it('control: the end node keeps 已拒绝 for its refused outcome', () => {
61+
const outcome = localizeFlowFields('end', fieldsForNodeType('end'), 'zh-CN').find((f) => f.id === 'outcome');
62+
expect(outcome?.options?.find((o) => o.value === 'refused')?.label).toBe('已拒绝');
63+
});
64+
});
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* objectstack#35021 — an approval rejection reads 驳回 in Chinese, on the
3+
* runtime surfaces as in the designer (ruling 6973602227, option A).
4+
*
5+
* The inbox, the record approval bar and the history timeline name the reject
6+
* decision with the word the flow designer gives the approval branch, in
7+
* zh-Hans and zh-Hant. 拒绝 keeps its own meanings: access denial, declining an
8+
* invitation, and the AI tool approvals (`aiApprovals`), a different concept.
9+
*
10+
* What is pinned is the vocabulary, not the sentences: no `approvalsInbox`
11+
* string in either Chinese pack says 拒绝, every key named for the reject
12+
* decision says 驳回, and the runtime's decision word and status agree with the
13+
* designer's branch and end-node labels. Each enumeration asserts it is
14+
* non-empty first, so a family that stopped resolving cannot pass with
15+
* nothing checked.
16+
*/
17+
import { describe, it, expect } from 'vitest';
18+
import { builtInLocales } from '../locales';
19+
import STUDIO_ZH from '../namespaces/studio/zh.js';
20+
21+
type Pack = Record<string, unknown>;
22+
23+
const group = (locale: 'zh-Hans' | 'zh-Hant', name: string): Pack =>
24+
(builtInLocales[locale] as unknown as Record<string, Pack>)[name];
25+
26+
const strings = (pack: Pack): Array<[string, string]> =>
27+
Object.entries(pack).filter((entry): entry is [string, string] => typeof entry[1] === 'string');
28+
29+
const SCRIPTS = [
30+
{ locale: 'zh-Hans', reject: '驳回', deny: '拒绝' },
31+
{ locale: 'zh-Hant', reject: '駁回', deny: '拒絕' },
32+
] as const;
33+
34+
describe('approval rejection reads 驳回 on the runtime surfaces (objectstack#35021)', () => {
35+
describe.each(SCRIPTS)('$locale', ({ locale, reject, deny }) => {
36+
const inbox = group(locale, 'approvalsInbox');
37+
38+
it(`no approvalsInbox string says ${deny}`, () => {
39+
const entries = strings(inbox);
40+
expect(entries.length).toBeGreaterThan(0);
41+
expect(entries.filter(([, value]) => value.includes(deny))).toEqual([]);
42+
});
43+
44+
it(`every approvalsInbox key named for the reject decision says ${reject}`, () => {
45+
const rejectKeys = strings(inbox).filter(([key]) => /reject/i.test(key));
46+
expect(rejectKeys.length).toBeGreaterThan(0);
47+
expect(rejectKeys.filter(([, value]) => !value.includes(reject))).toEqual([]);
48+
});
49+
50+
it(`the decision verb reads ${reject} and the status reads 已${reject}`, () => {
51+
expect(inbox.actReject).toBe(reject);
52+
expect(inbox.reject).toBe(reject);
53+
expect(inbox.statusRejected).toBe(`已${reject}`);
54+
expect(inbox.rejectedToast).toBe(`已${reject}`);
55+
});
56+
57+
it(`access denial, invitations and AI tool approvals keep ${deny}`, () => {
58+
const aiApprovals = group(locale, 'aiApprovals');
59+
expect(aiApprovals.reject).toBe(deny);
60+
expect(aiApprovals.statusRejected).toBe(`已${deny}`);
61+
const organization = group(locale, 'organization') as Record<string, Pack>;
62+
expect((organization.invitations.status as Pack).rejected).toBe(`已${deny}`);
63+
expect(organization.accept.decline).toBe(deny);
64+
expect(String(group(locale, 'errors').forbidden)).toContain(deny);
65+
});
66+
});
67+
68+
it('the runtime decision word agrees with the designer branch and end node', () => {
69+
const inbox = group('zh-Hans', 'approvalsInbox');
70+
expect(inbox.actReject).toBe(STUDIO_ZH['engine.inspector.flowEdge.branchReject']);
71+
expect(inbox.statusRejected).toBe(STUDIO_ZH['engine.flowCanvas.rejectedEnd']);
72+
});
73+
});

0 commit comments

Comments
 (0)