Skip to content

Commit dcbb363

Browse files
fix(app-shell): the report quick edit saves the report's own text, not the served translation (#35080)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ Closes #35008 Claim: restated for this branch on #35008, comment 6966756598 (file surface incl. `ReportConfigPanel.tsx`, amendment 6966697599). Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:报表页「编辑」面板的编辑缓冲改为从未翻译的分层读取(作者存储的原文,有待发布草稿时取草稿)填充;页面展示仍用服务端按语言翻译后的报表;面板里的草稿条不再用翻译后的草稿覆盖编辑内容。 - 为什么改:中文界面下快速编辑报表任意一个字段再保存,会把中文译文(标题、描述、每个分块标题)当作源文存入;发布后英文读者看到的是「任务概览(联合)」,已实测复现。 - 风险与回滚:只动前端 app-shell 两个文件,无服务端、无 spec 改动;分层读取失败时面板不打开并弹出错误(原来会用翻译副本打开);编辑期间预览显示源文而非译文。回滚即 revert 本 PR。 - 先看:ReportView.tsx 的 handleOpenConfigPanel 与 handleCloseConfigPanel;ReportConfigPanel.tsx 移除 onResume 的那一处;新测试 ReportView.authoredEditBuffer-35008.test.tsx。 - 两分钟验证:`cd ui && pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/views/ReportView.authoredEditBuffer-35008.test.tsx`,预期 3 passed。 - 需要你做的:无,席位落地。 ## What changes - `ui/packages/app-shell/src/views/ReportView.tsx`: the Edit button now reads the report's layers (`metadataClient.layered('report', name, { packageId })`, the package taken from the served report's `_packageId`) and seeds the edit buffer with `authoredBuffer('report', layers, null)`, the same helper the Studio editors use. That is the pending draft as stored when there is one, else the published report, untranslated and without the read's `_`-decorations. The served (translated) report stays the display copy. If the layered read fails or holds nothing, the editor does not open and a toast names the failure (`engine.edit.loadFailed`). A close with no landed save puts the served report back as the preview. A close after a landed save keeps the edited preview until the metadata refresh replaces it, as before. The drill fallback's caller package now comes from the served report directly (`servedPackageId(reportData)`), because the edit buffer no longer carries `_packageId`. - `ui/packages/app-shell/src/views/ReportConfigPanel.tsx`: the panel no longer passes `onResume` to `RuntimeDraftBar`. The bar's resume hands over the SERVED draft (`readRuntimeDraft`, `get(..., { state: 'draft' })`), which the server translates for the console locale. Seeding the inspector with it stored the translations on the next Save. The host now seeds the pending draft as stored, so the resume was redundant as well as harmful. The bar still reads the draft for its indicator, Publish and Discard. - One changeset, `patch` for `@object-ui/app-shell` and `@object-ui/console`. ## Tests - New: `ReportView.authoredEditBuffer-35008.test.tsx` runs the real `ReportView`, `ReportConfigPanel`, `RuntimeDraftBar` and persistence seam over a client whose served reads are translated and whose layered read is the stored source. - Case 1: a zh-CN quick edit then save stores the source label and block labels. Control: the edited field (`description`) changes. The layered read uses the served package, and `_packageId` is not in the body. - Case 2: with a pending draft, the draft is edited as stored, and the draft bar's served resume does not overwrite it. - Case 3: a refused layered read opens no editor and saves nothing. - Adapted: `ReportView.saveRefusal-11583.test.tsx`. Its client doubles gain a `layered` read returning the same stored report the served list carried. No assertion was changed or removed. - Both test files load `@objectstack/lint` at module top. `check:test-source-alias` flagged the editor's dynamic import of it, which is reachable through the panel's inspector. - Narrowed locally: the full app-shell suite (2319 files) is left to CI's Test UI lane. Locally the ReportView, ReportConfigPanel and RuntimeDraftBar slice ran. - Final head `ae31401e36`: 11 files / 43 tests passed. That is the ReportView, ReportConfigPanel and RuntimeDraftBar slice of app-shell. `pnpm --filter @object-ui/app-shell run type-check` exited 0. <details><summary>Test run on ae31401</summary> ```text cd ui && pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/views/ReportView packages/app-shell/src/views/ReportConfigPanel packages/app-shell/src/views/RuntimeDraftBar Test Files 11 passed (11) Tests 43 passed (43) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Ablations (one-time, fix committed first; both restored by HEAD blob hash, git diff HEAD empty)</summary> The predicted direction was written in the test header before the run. Ablation 1 seeded the edit buffer from `reportData` again (the unmodified behaviour). Cases 1 and 2 went RED and case 3 stayed green, as predicted: ```text × a zh-CN quick edit then save stores the source label and block labels, and the edited field changes × a pending draft is edited as stored: the draft bar does not resume the served (translated) draft over it AssertionError: expected '任务概览(联合)' to be 'Task Overview (Joined)' Tests 2 failed | 1 passed (3) VERDICT command-exit 1 ``` Restored: ReportView.tsx blob `82d995a6a1d1` equals HEAD. Ablation 2 restored the panel's `onResume` to the draft bar. Only case 2 went RED, as predicted: ```text × a pending draft is edited as stored: the draft bar does not resume the served (translated) draft over it AssertionError: expected '任务概览(联合)' to be 'Task Overview (Joined)' Tests 1 failed | 2 passed (3) VERDICT command-exit 1 ``` Restored: ReportConfigPanel.tsx blob `adeed6e83d37` equals HEAD. The first attempt at ablation 2 was a no-op. Its replacement text contained its own anchor, so `ablation-replace.mjs` refused it and restored the file, and nothing ran. The retry used a different anchor. Its landing was confirmed on disk before the run. </details> ## Acceptance notes - **File surface:** the claim declared `ReportView.tsx` and its tests. This PR also touches `ReportConfigPanel.tsx` (one prop removed). The panel's draft-bar resume is a second route by which the served translation reaches the save body, and without the change the pending-draft case still stores translations (ablation 2). It is declared here for the seat. - **Behaviour changes a reviewer may notice:** - While the panel is open in a non-source locale, the preview and the form show the report's source text, not the translation. The form edits what is stored, the same as the Studio editors. - A refused layered read now refuses to open the editor. Before, it opened on the served copy. - Cancel without saving now reverts the preview to the served report. Before, the unsaved edits stayed in the preview until the next metadata refresh. - **Read-only showcase pair, unchanged:** measured live on `/apps/com.example.showcase/report/showcase_task_overview`. The editor opens from the layered read, the save answers `403` with the server's save-into-the-pair message, and the toast reads `保存失败` followed by that message. The panel stays open. This is the same outcome `ReportView.saveRefusal-11583.test.tsx` pins. - **List-view config save (`objectViewViewCrud.tsx`, type `view`), not folded in:** it was NOT MEASURED live. On this boot the view toolbar renders no `settings` view action (no button titled Settings), so `ViewConfigPanel` could not be opened inside the timebox. The served zh-CN view label is translated (`翻译测试列表` for a view stored as `QA Task List`). Read statically, `buildViewConfigSaveBody` carries the draft's `label`, and that draft is seeded from the served `activeView`. The `ViewConfigPanel` draft-bar resume uses the same served `readRuntimeDraft`. It is likely the same mechanism, but the fix is a different shape: `ObjectView` / `ViewConfigPanel` / `buildViewConfigSaveBody`, not this host's buffer seed. It is outside the declared surface, so it is left for the seat to decide. - The door-side restore for every translatable type (option A) is a separate decision card and is not in this PR. ## Verification Live before/after on a fresh boot with a writable en-source package `com.qa.tr` (a copy of the showcase joined report as `qatr_task_overview`, plus a zh-CN translation). Each leg opens the report page in a zh-CN browser session, clicks 编辑, changes only 描述, and saves. Served code was confirmed per leg by grepping the module vite served. <details><summary>Before: origin/main code. The captured draft PUT stores the translation</summary> ```text PUT /api/v1/meta/report/qatr_task_overview?mode=draft {"label":"任务概览(联合)","description":"reportview probe 35008","blocks":["未完成任务","已完成任务"],"_packageId":"com.qa.tr"} diff vs stored: label "Task Overview (Joined)" -> "任务概览(联合)"; blocks.0.label "Open Tasks" -> "未完成任务"; blocks.1.label "Completed Tasks" -> "已完成任务"; description -> "reportview probe 35008" after publish, en read: label 任务概览(联合), blocks 未完成任务 / 已完成任务 ``` </details> <details><summary>After: this branch. Only the edited field changes, and the en read shows the source</summary> ```text PUT /api/v1/meta/report/qatr_task_overview?mode=draft {"label":"Task Overview (Joined)","description":"reportview probe 35008","blocks":["Open Tasks","Completed Tasks"]} diff vs stored: report.description: "Multiple task sub-reports stacked into one joined view." -> "reportview probe 35008" second edit over the pending draft (form opened with description "reportview probe 35008", the draft as stored): PUT /api/v1/meta/report/qatr_task_overview?mode=draft {"label":"Task Overview (Joined)","description":"reportview probe 35008 second","blocks":["Open Tasks","Completed Tasks"]} after publish: servedEn {"label":"Task Overview (Joined)","description":"reportview probe 35008 second","b0":"Open Tasks","b1":"Completed Tasks"} servedZh {"label":"任务概览(联合)","description":"将多个任务子报表堆叠在一个联合视图中。","b0":"未完成任务","b1":"已完成任务"} ``` </details> ## Local gates `node scripts/pm/dispatch-gates.mjs --commands` derived 38 commands for this diff. All 38 ran, plus `pnpm check:changeset-fixed`, whose roster sits under `.changeset`. Every exit code was 0 on the final head. Reconciliation result: `✓ dispatch-gates --ran: 38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of them is 3)`. <details><summary>Two first-run reds, both resolved</summary> - `pnpm check:test-source-alias` exited 1 on `5b37669150` and named both edited test files. It was fixed in `ae31401e36` with a module-top `import '@objectstack/lint'`, then re-ran: `check-test-source-alias OK`, exit 0. - The first run of `pnpm --dir ui exec vitest run scripts/` was killed by SIGKILL when the shared box ran out of memory. That run measured nothing. It re-ran with `--maxWorkers=2` under the verify lock: `Test Files 171 passed | 2 skipped (173)`, `Tests 5077 passed | 2 skipped (5079)`, `VERDICT command-exit 0`. - After `ae31401e36`, these re-ran green: test-source-alias, undeclared-dep-imports, nul-bytes, cross-package-test-inputs, type-check-coverage, type-check-debt, tier-file-adoption, refd-timer-probe, engine-double-contract, and app-shell `type-check`. - `node scripts/pm/overlap-check.mjs` against origin/main `a3e216efae` gave `VERDICT clean exit 0`. </details> Type-check lanes, the artifact rosters and the wide-population families belong to CI and are read from this PR's check-runs. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzi6WQ71HhZSLSvHhdF <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzi6WQ71HhZSLSvHhdF --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ad9b74b commit dcbb363

5 files changed

Lines changed: 332 additions & 19 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(app-shell): the report quick edit saves the report's own text, not the served translation
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The in-app report editor (a report page's Edit button) seeded its form from the report as the console was served it. In a non-source locale that copy is translated (the report's label, description and each block's label), and the metadata save stores a report body as sent, so saving any edit stored the translations as the report's source text: after a publish, readers in every other language were shown them. The editor now edits the report as its author stored it, read from the layered metadata read the Studio editors already use (the pending draft when there is one, else the published report), and keeps the served copy for display. If that read fails, the editor says so and does not open. The draft bar in the editor no longer resumes the served (translated) draft over it.

‎ui/packages/app-shell/src/views/ReportConfigPanel.tsx‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,6 @@ export function ReportConfigPanel({
141141
onClose();
142142
}, [onSave, onClose]);
143143

144-
// ADR-0034 (#1515): resume a pending draft into the inspector on open
145-
// (flag-ON only). The report document IS the inspector draft, so seed it
146-
// directly.
147-
const handleResumeDraft = useCallback((body: Record<string, unknown>) => {
148-
const next = { ...body };
149-
draftRef.current = next;
150-
setDraft(next);
151-
setDirty(false);
152-
}, []);
153-
154144
const handleDiscard = useCallback(() => {
155145
onClose();
156146
}, [onClose]);
@@ -210,7 +200,11 @@ export function ReportConfigPanel({
210200
name={name}
211201
metadataClient={metadataClient}
212202
dirty={dirty}
213-
onResume={handleResumeDraft}
203+
// objectstack#35008 — no `onResume`: the host seeds `config` with the
204+
// pending draft as stored (`ReportView`, the layered read's
205+
// `authoredBuffer`). The bar's resume hands over the SERVED draft,
206+
// which the server translates for the console's locale, and seeding
207+
// the inspector with it stored the translations on the next Save.
214208
onAfterChange={onAfterChange}
215209
/>
216210
<Button variant="ghost" size="sm" onClick={handleDiscard} data-testid="report-config-discard">
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35008 — the report quick edit edits the report as its author
5+
* wrote it, never the report as it is served.
6+
*
7+
* ## The defect this pins
8+
*
9+
* `ReportView` seeded its editor with `reportData`, the report from the served
10+
* `/meta/report` list. In a zh-CN session that read is translated (`label`,
11+
* `description`, each block's `label`), and the save door stores a report body
12+
* verbatim, so a quick edit of any one field stored the translations as the
13+
* source text: measured live, an en reader was served `任务概览(联合)` after
14+
* the publish. A pending draft took the same route a second way: the draft
15+
* bar's resume handed the inspector the SERVED draft, translated likewise.
16+
*
17+
* ## What runs
18+
*
19+
* The real `ReportView`, the real `ReportConfigPanel`, the real
20+
* `RuntimeDraftBar` and the real persistence seam, over a metadata client
21+
* double: its served reads (the list, `get(…, { state: 'draft' })`) answer the
22+
* translated report, its layered read the stored source. The panel's spec
23+
* inspector is reduced to one edit of `description` that also shows the label
24+
* and block labels it was handed.
25+
*
26+
* Direction, written before the run: with the buffer seeded from `reportData`
27+
* (the unmodified tree) the first two cases go RED on the stored labels, and
28+
* the description control stays GREEN; with the panel's draft-bar resume
29+
* restored, the pending-draft case goes RED.
30+
*/
31+
32+
import * as React from 'react';
33+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
34+
import { render, screen, waitFor, fireEvent, act, cleanup } from '@testing-library/react';
35+
import { toast } from 'sonner';
36+
37+
vi.mock('sonner', () => ({
38+
toast: Object.assign(vi.fn(), {
39+
success: vi.fn(), error: vi.fn(), info: vi.fn(),
40+
warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(),
41+
}),
42+
}));
43+
44+
vi.mock('@object-ui/plugin-report', async (importOriginal) => ({
45+
...(await importOriginal<Record<string, unknown>>()),
46+
ReportRenderer: () => null,
47+
}));
48+
vi.mock('@object-ui/plugin-dashboard', async (importOriginal) => ({
49+
...(await importOriginal<Record<string, unknown>>()),
50+
DrillDownDrawer: () => null,
51+
}));
52+
// The panel's spec inspector, reduced to one edit of an unrelated field.
53+
vi.mock('./metadata-admin/inspectors/ReportDefaultInspector', () => ({
54+
ReportDefaultInspector: ({ onPatch, draft }: any) => (
55+
<button
56+
type="button"
57+
data-testid="stub-report-edit"
58+
data-label={String(draft?.label)}
59+
data-blocks={JSON.stringify((draft?.blocks ?? []).map((b: any) => b?.label))}
60+
onClick={() => onPatch({ description: 'Edited description' })}
61+
>
62+
edit
63+
</button>
64+
),
65+
}));
66+
67+
const meta = vi.hoisted(() => ({ value: null as any }));
68+
vi.mock('../providers/MetadataProvider', () => ({ useMetadata: () => meta.value }));
69+
70+
vi.mock('react-router-dom', () => ({
71+
useParams: () => ({ reportName: 'task_overview' }),
72+
useNavigate: () => vi.fn(),
73+
useLocation: () => ({ pathname: '/apps/com.qa.tr/report/task_overview', search: '' }),
74+
}));
75+
76+
vi.mock('./useOpenRecordList', () => ({
77+
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
78+
}));
79+
vi.mock('./MetadataInspector', () => ({
80+
MetadataPanel: () => null,
81+
useMetadataInspector: () => ({ showDebug: false }),
82+
}));
83+
const client = vi.hoisted(() => ({ value: null as any }));
84+
vi.mock('./metadata-admin/useMetadata', () => ({ useMetadataClient: () => client.value }));
85+
vi.mock('../providers/AdapterProvider', () => ({ useAdapter: () => ({}) }));
86+
vi.mock('../providers/ExpressionProvider', () => ({ useExpressionContext: () => ({ app: undefined }) }));
87+
vi.mock('@object-ui/auth', async (importOriginal) => ({
88+
...(await importOriginal<Record<string, unknown>>()),
89+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
90+
}));
91+
92+
// `ReportView` reaches a dynamic `import('@objectstack/lint')` (through the panel's
93+
// inspector): pay its load at collection, never inside a case's clocked window
94+
// (`check:test-source-alias`).
95+
import '@objectstack/lint';
96+
import { ReportView } from './ReportView';
97+
98+
const PKG = 'com.qa.tr';
99+
100+
/** The report as its author stored it (en source). */
101+
const SOURCE = {
102+
name: 'task_overview',
103+
label: 'Task Overview (Joined)',
104+
description: 'Multiple task sub-reports stacked into one joined view.',
105+
type: 'joined',
106+
blocks: [
107+
{ name: 'open_block', label: 'Open Tasks', type: 'summary', dataset: 'task_metrics', rows: ['status'], values: ['est_hours'] },
108+
{ name: 'done_block', label: 'Completed Tasks', type: 'summary', dataset: 'task_metrics', rows: ['status'], values: ['task_count'] },
109+
],
110+
};
111+
112+
/** The same report as the zh-CN read serves it: translated, with the read's decorations. */
113+
function served(doc: typeof SOURCE) {
114+
return {
115+
...doc,
116+
label: '任务概览(联合)',
117+
description: '将多个任务子报表堆叠在一个联合视图中。',
118+
blocks: [
119+
{ ...doc.blocks[0], label: '未完成任务' },
120+
{ ...doc.blocks[1], label: '已完成任务' },
121+
],
122+
_packageId: PKG,
123+
};
124+
}
125+
126+
const refresh = vi.fn(async () => {});
127+
128+
function mountReport() {
129+
meta.value = {
130+
apps: [],
131+
objects: [],
132+
dashboards: [],
133+
reports: [served(SOURCE)],
134+
pages: [],
135+
loading: false,
136+
error: null,
137+
refresh,
138+
invalidate: () => {},
139+
ensureType: async () => [],
140+
getItem: vi.fn(async () => null),
141+
getItemsByType: () => [],
142+
getTypeStatus: () => 'ready',
143+
};
144+
render(<ReportView dataSource={{ find: vi.fn(async () => ({ data: [] })) } as any} />);
145+
}
146+
147+
/** A client whose served reads translate and whose layered read is the stored row. */
148+
function makeClient({ draft }: { draft: typeof SOURCE | null }) {
149+
return {
150+
// The served draft read (`RuntimeDraftBar`): translated, like every served read.
151+
get: vi.fn(async () => (draft ? served(draft) : null)),
152+
layered: vi.fn(async () => ({ code: null, overlay: null, overlayScope: null, effective: SOURCE, draft })),
153+
save: vi.fn(async () => ({})),
154+
publish: vi.fn(async () => ({})),
155+
reset: vi.fn(async () => ({})),
156+
};
157+
}
158+
159+
async function openEditAndSave() {
160+
fireEvent.click(await screen.findByTestId('report-edit-button'));
161+
await screen.findByTestId('report-config-panel');
162+
// Let the draft bar's read settle, so a resume (if any) has landed first.
163+
await waitFor(() => expect(client.value.get).toHaveBeenCalled());
164+
await act(async () => {});
165+
fireEvent.click(screen.getByTestId('stub-report-edit'));
166+
await act(async () => {
167+
fireEvent.click(screen.getByTestId('report-config-save'));
168+
});
169+
await waitFor(() => expect(client.value.save).toHaveBeenCalledTimes(1));
170+
return client.value.save.mock.calls[0];
171+
}
172+
173+
beforeEach(() => {
174+
vi.spyOn(console, 'warn').mockImplementation(() => {});
175+
vi.spyOn(console, 'error').mockImplementation(() => {});
176+
});
177+
178+
afterEach(() => {
179+
cleanup();
180+
vi.restoreAllMocks();
181+
vi.clearAllMocks();
182+
});
183+
184+
describe('the report quick edit edits the authored report (objectstack#35008, ReportView)', () => {
185+
it('a zh-CN quick edit then save stores the source label and block labels, and the edited field changes', async () => {
186+
client.value = makeClient({ draft: null });
187+
mountReport();
188+
const [type, name, body, opts] = await openEditAndSave();
189+
190+
expect([type, name, opts]).toEqual(['report', 'task_overview', { mode: 'draft' }]);
191+
// Read at the package the served report came from.
192+
expect(client.value.layered).toHaveBeenCalledWith('report', 'task_overview', { packageId: PKG });
193+
expect(body.label).toBe(SOURCE.label);
194+
expect(body.blocks.map((b: any) => b.label)).toEqual(['Open Tasks', 'Completed Tasks']);
195+
// Control: the edit itself is what the save carries.
196+
expect(body.description).toBe('Edited description');
197+
// The read's decoration is not the report's.
198+
expect(body).not.toHaveProperty('_packageId');
199+
expect(toast.error).not.toHaveBeenCalled();
200+
});
201+
202+
it('a pending draft is edited as stored: the draft bar does not resume the served (translated) draft over it', async () => {
203+
const pending = { ...SOURCE, description: 'Draft description' };
204+
client.value = makeClient({ draft: pending });
205+
mountReport();
206+
const [, , body] = await openEditAndSave();
207+
208+
expect(body.label).toBe(SOURCE.label);
209+
expect(body.blocks.map((b: any) => b.label)).toEqual(['Open Tasks', 'Completed Tasks']);
210+
expect(body.description).toBe('Edited description');
211+
// The draft bar still reads the draft, for its indicator and Publish.
212+
expect(client.value.get).toHaveBeenCalledWith('report', 'task_overview', { state: 'draft' });
213+
});
214+
215+
it('with nothing authored to read the editor does not open, and nothing is saved from the served copy', async () => {
216+
client.value = {
217+
...makeClient({ draft: null }),
218+
layered: vi.fn(async () => {
219+
throw Object.assign(new Error('Layered read refused'), { status: 403 });
220+
}),
221+
};
222+
mountReport();
223+
fireEvent.click(await screen.findByTestId('report-edit-button'));
224+
225+
await waitFor(() => expect(toast.error).toHaveBeenCalledTimes(1));
226+
expect(String(vi.mocked(toast.error).mock.calls[0][0])).toContain('Layered read refused');
227+
expect(screen.queryByTestId('report-config-panel')).toBeNull();
228+
expect(client.value.save).not.toHaveBeenCalled();
229+
});
230+
});

‎ui/packages/app-shell/src/views/ReportView.saveRefusal-11583.test.tsx‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,28 @@ vi.mock('@object-ui/auth', async (importOriginal) => ({
101101
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
102102
}));
103103

104+
// `ReportView` reaches a dynamic `import('@objectstack/lint')` (through the panel's
105+
// inspector): pay its load at collection, never inside a case's clocked window
106+
// (`check:test-source-alias`).
107+
import '@objectstack/lint';
104108
import { ReportView } from './ReportView';
105109

106110
const refresh = vi.fn(async () => {});
107111

112+
/**
113+
* The layered read the editor seeds its buffer from (objectstack#35008): the
114+
* stored report, which here is the served one (no translation in play).
115+
*/
116+
function storedLayers() {
117+
return vi.fn(async () => ({
118+
code: null,
119+
overlay: null,
120+
overlayScope: null,
121+
effective: { name: 'revenue_by_month', label: 'Revenue by Month', dataSource: { object: 'acct' } },
122+
draft: null,
123+
}));
124+
}
125+
108126
function mountReport() {
109127
meta.value = {
110128
apps: [],
@@ -152,6 +170,7 @@ describe('the report editor\'s Save says a refused save (objectui#11583, ReportV
152170
it('a refused save raises the refusal, once per Save', async () => {
153171
client.value = {
154172
get: vi.fn(async () => null),
173+
layered: storedLayers(),
155174
save: vi.fn(async () => {
156175
throw Object.assign(new Error('Saving reports requires the Manage Metadata permission'), { status: 403 });
157176
}),
@@ -175,7 +194,7 @@ describe('the report editor\'s Save says a refused save (objectui#11583, ReportV
175194
});
176195

177196
it('a save that lands raises nothing and refreshes the read (control)', async () => {
178-
client.value = { get: vi.fn(async () => null), save: vi.fn(async () => ({})) };
197+
client.value = { get: vi.fn(async () => null), layered: storedLayers(), save: vi.fn(async () => ({})) };
179198
mountReport();
180199
await editThriceAndSave();
181200

0 commit comments

Comments
 (0)