Skip to content

Commit e68dae8

Browse files
committed
test(cli,plugin-approvals): read a parsed action description as the template envelope; docblocks name the semantic entry (#27948)
Test Core 5/8 and 6/8 pinned a parsed action's `description` as a bare string. It now parses to `{ dialect: 'template', source }`, so the cli extractor pin expects the envelope and the two plugin-approvals pins read the sentence through templateSlotSource. The outcomeMessages docblock (action.zod.ts) and the action-copy-template module note said `os migrate meta` rewrites stored copy. The semantic entry action-dialog-outcome-copy-template-holes registers no conversion, so both now say the rewrite is by hand and name the entry. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibwQ8tWwY7TiHQPMCHR
1 parent 408466d commit e68dae8

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

‎packages/cli/test/i18n-extract-action-description.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ describe('one fixture action, all three surfaces (#7367 end-to-end)', () => {
169169
// 1. The producer accepts it.
170170
const parsed = ActionSchema.safeParse(authored);
171171
expect(parsed.success).toBe(true);
172+
// `description` is a `template` slot (#27948): a bare string parses to the
173+
// envelope, whose `source` is the sentence as written.
172174
expect(parsed.success && parsed.data.description)
173-
.toBe('Reject this request? The requester sees your reason.');
175+
.toEqual({ dialect: 'template', source: 'Reject this request? The requester sees your reason.' });
174176
expect(parsed.success && parsed.data.confirmText).toBeUndefined();
175177

176178
// 2. The extractor emits the address objectui's resolver reads

‎packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
import { describe, it, expect } from 'vitest';
25+
import { templateSlotSource } from '@objectstack/spec/automation';
2526
import { SysApprovalRequest } from './sys-approval-request.object.js';
2627

2728
const actions = (SysApprovalRequest as any).actions as any[];
@@ -134,18 +135,22 @@ describe('sys_approval_request declared actions', () => {
134135
it('the confirm question rides `description`, not `confirmText`, so one decision opens one dialog (#7278)', () => {
135136
const reject = byName('approval_reject');
136137
expect(reject.confirmText).toBeUndefined();
137-
expect(reject.description).toBe(
138+
// `description` is a `template` slot (#27948): the parsed value is the
139+
// envelope, so the sentence is read through the slot's one reader.
140+
const rejectText = templateSlotSource(reject.description);
141+
expect(rejectText).toBe(
138142
'Reject this request? A rejection is final for every approver.',
139143
);
140144
// the finality warning is the half that must survive the move
141-
expect(reject.description).toContain('final for every approver');
145+
expect(rejectText).toContain('final for every approver');
142146

143147
const recall = byName('approval_recall');
144148
expect(recall.confirmText).toBeUndefined();
145-
expect(recall.description).toBe(
149+
const recallText = templateSlotSource(recall.description);
150+
expect(recallText).toBe(
146151
'Recall this request? Approvers can no longer act on it and the record is unlocked.',
147152
);
148-
expect(recall.description).toContain('can no longer act on it');
153+
expect(recallText).toContain('can no longer act on it');
149154
});
150155

151156
it('no declared action pairs `confirmText` with `params` (#7278 ruling, object-wide)', () => {

‎packages/plugins/plugin-approvals/src/translations/approve-decision-question.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// that stopped being consulted shows up as English in the zh-CN case.
1616

1717
import { describe, it, expect } from 'vitest';
18+
import { templateSlotSource } from '@objectstack/spec/automation';
1819
import { translateMetadataDocument } from '@objectstack/spec/system';
1920
import { ApprovalsTranslations } from './index.js';
2021
import { enObjects } from './en.objects.generated.js';
@@ -31,7 +32,10 @@ interface CopyAction {
3132
const action = (doc: unknown, name: string): CopyAction => {
3233
const found = ((doc as { actions?: CopyAction[] }).actions ?? []).find((a) => a.name === name);
3334
expect(found, `${name} is declared`).toBeDefined();
34-
return found as CopyAction;
35+
// `description` is a `template` slot (#27948): a parsed object carries the
36+
// envelope, a translated one the bundle's string. Both read as the sentence.
37+
const copy = found as CopyAction;
38+
return { ...copy, description: templateSlotSource(copy.description) ?? copy.description };
3539
};
3640

3741
const bundleDescription = (bundle: unknown, name: string): unknown =>

‎packages/spec/src/ui/action-copy-template.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ import { InlineLocaleMapSchema } from './i18n.zod';
7979
* `description`, `helpText` and `outcomeMessages` took the same road one step
8080
* later (#27948): the runner filled `${…}` in them until they were typed, and
8181
* still fills it in a sentence with no `{{ }}` hole, so copy stored before the
82-
* migration (`os migrate meta`) keeps reading. The doors refuse a `${…}`
83-
* token there as in the other keys, so new copy is written with `{{ }}`.
82+
* rewrite keeps reading until its next save. The rewrite is by hand: the
83+
* semantic migration entry `action-dialog-outcome-copy-template-holes` names it
84+
* and registers no conversion. The doors refuse a `${…}` token there as in the
85+
* other keys, so new copy is written with `{{ }}`.
8486
*/
8587

8688
/** The root a `confirmText` / `successMessage` hole names for the record the action runs against. */

‎packages/spec/src/ui/action.zod.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,11 @@ const actionObject = () => strictObject({
15041504
* `successMessage` (#27948, ruling A): its `{{ }}` holes read `result` —
15051505
* for `type: 'api'` the `target` call's response body, for
15061506
* `type: 'script'` the handler's return value — and `record`. One dialect:
1507-
* a `${…}` token is refused at the doors, and `os migrate meta` rewrites
1508-
* stored copy to `{{ }}`.
1507+
* a `${…}` token is refused at the doors. Stored copy is rewritten to
1508+
* `{{ }}` by hand: the semantic migration entry
1509+
* `action-dialog-outcome-copy-template-holes` (`os migrate meta` lists it)
1510+
* names the edit and registers no conversion, since a `${…}` token can hold
1511+
* an expression with no mechanical `{{ }}` spelling.
15091512
*
15101513
* **Where it is refused** (`refuseInertOutcomeMessages`, and the
15111514
* declarative-update table): on a type with no server response to report

0 commit comments

Comments
 (0)