Skip to content

Commit d076975

Browse files
os-warrenclaude
andauthored
feat(console): build a new report from the design mode's Add menu item (#36657)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ89Betg8QPoUPD5NhDenSfS2)_ Fixes #36364 Clause-②: yes (widening) — three new `@object-ui/i18n` keys (`designMode.menu.newReport`, `designMode.menu.newReportLeft`, `report.builder.addsToMenu`) in all 11 locales; no spec, schema or public export change Metadata-protocol: none repo:objectstack#1 · os-warren · session_01JQwxbXq2Dxb31zZNmSqCtz ## 维护者速读 - 用户能看到什么变化:管理员在设计模式里「添加菜单项 → 报表」,第一行是「新建报表…」,点了会占好菜单位置并打开报表搭建页;选好数据来源和指标、保存后,新报表出现在占好的位置,设计模式里的其他改动一起保存。 - 为什么做:设计模式专题卡的报表这一半,按席位定的方案:报表必须先有数据来源和指标,所以从搭建页新建,而不是只填名字。 - 出错会怎样:菜单保存失败时,刚建的报表会被删掉,设计模式和搭建页都保持打开;中途关闭搭建页或离开它,什么都不写、占位消失;可以直接撤回本次合并。 - 要你做什么:不用做什么。 ## What changes The report half of #36364, on top of the report builder (#36644), per the seat's ruling (option A, comment 7090058961): a report needs `dataset` and `values`, so 「New report…」 opens the builder, and the report and its menu entry are written only when the builder saves. - **Picker** (`DesignModeMenu.tsx`): the Reports list starts with 「New report…」. It holds the place (the dashed row now reads 「New report…」), offers a slot, and navigates to the app's `reports/new`. Nothing is written. - **The slot** (`designModeReportSlot.ts`, new): the menu lives in the sidebar and the builder in the page, with no shared tree, so a module-level store holds one slot `{ path, save, cancel }`. It is keyed by the builder's address, not the app's name, because the console addresses an app by its route segment (the showcase app is `/apps/com.example.showcase`, its name `showcase_app`). This was found on the live run, and a page test pins it. The menu withdraws the slot when the place is dropped and when it unmounts (the design mode ended). Without a slot the builder is the plain new-report page, as before. - **The builder page** (`ReportNewPage.tsx`): when a slot waits on its address, it says 「Saving creates this report and adds it to the menu where you placed it, with your other design changes.」. Its Save hands `(name, label, body)` to the slot and writes nothing itself. A refused save keeps the builder open. Its Close cancels the place and goes back. - **The save** (`designModeMenuCreate.ts`): `NewMenuItem` gains a `report` arm carrying the builder's body. `saveAppMenuWithNewItem` runs the dashboard half's order unchanged: every menu-save check first, then the report saved and published in the menu's own package (`saveAndPublishInPackage`, the package-bound door `saveDashboardInPlace` now shares), then the menu written with the entry in the held place and every other staged edit (`saveWith`). On a refused menu the report is removed again. - **Leaving the builder another way** (a menu link, Back) drops the held place too, so no row waits for a builder that is gone. - **The entry's label**: a report entry with no `label` shows its machine name (only object, view and dashboard entries inherit their target's label, per the cloud#2021 ruling), so the new entry carries the report's label. The live run first showed `hui_kuan_fenxi` in the menu, and this fixes it. ## Tests - `pnpm --dir ui exec vitest run packages/app-shell/src/layout packages/app-shell/src/views/ReportNewPage` at `f3021225`: `Test Files 157 passed (157)`, `Tests 1284 passed (1284)`. `DesignModeMenu-36363.test.tsx` was rerun at head `ecbe0f66` after the label change: `38 passed`. Earlier at `f7737e36`, `packages/i18n` gave `1978 passed`, with the de quote-pairing count raised 128 → 129 for `newReportLeft`'s „{{name}}“. - New pins: - `designModeMenuCreate-36364.test.ts`: 4 report cases. They cover the body, the package write order (ensure → save/publish report → save/publish app), a refused menu resetting the report, and an unlisted package creating nothing. - `DesignModeMenu-36363.test.tsx`: 5 report cases. They cover the picker row holding the place and writing nothing; the builder's Save writing the report, then the menu with the labelled entry and the other staged edit, then leaving the mode; a refused menu; the builder's Close; and leaving the builder. - `ReportNewPage.menuSlot-36364.test.tsx`: 5 cases. They cover Save going through the slot; a refused save staying open; Close cancelling and going back; a route segment other than the app's name; and another app's slot not being used. - Ablations (one-shot, not kept): without the page change, the page file went 3 failed | 1 passed. Without the menu change, all 5 menu report cases were red. - `tsc --noEmit` (app-shell) exit 0. ESLint on the changed files: 0 errors. `check-i18n-call-site-keys` exit 0. ## Screenshots Taken on the live showcase example (fresh backend, console dev server, zh-CN, deviceScaleFactor 2). They are stored with the seat's project files (`issue-36364/`): 1. 「添加菜单项 → 报表」, with 「新建报表…」 first. 2. The builder, with the held 「新建报表…」 row under 数据分析 and the 「adds to the menu」 line. 3. The builder filled: Invoice Metrics, grouped by status, named 回款分析. 4. After Save: the design mode is left, and 「回款分析」 sits in the held place, open. 5. Cancel path: a second 「新建报表…」, closed from the builder. The page goes back, no held row is left, and the mode stays on. Checked through the API after the run: - `report/hui_kuan_fenxi` is stored in `com.example.showcase.custom`, the menu's package (the same item Studio lists), with `_diagnostics.valid: true`. - The app's menu holds `{ id: nav_item_1, type: report, reportName: hui_kuan_fenxi, label: 回款分析 }` under `grp_analytics`. - It is the only `hui_kuan*` report, so the cancelled build left nothing. ## Overlap `overlap-check`: merges cleanly with main, #36655 and #36525. With #36629 it conflicts only in `de-quote-pairing-3876.test.ts`, because both PRs raise the same German quote count. Whichever lands second re-adds 1 to the count. --- _Generated by [Claude Code](https://claude.ai/code)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9fa05c6 commit d076975

21 files changed

Lines changed: 703 additions & 45 deletions
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/i18n': patch
4+
---
5+
6+
feat(console): a new report is built from the design mode's 「Add menu item」 and lands in the place held for it
7+
8+
Clause-②: yes (widening) — new `@object-ui/i18n` keys (`designMode.menu.newReport`, `designMode.menu.newReportLeft`, `report.builder.addsToMenu`) in all 11 locales; no package export, spec or schema change
9+
Metadata-protocol: none
10+
11+
In the design mode's 「Add menu item」 picker, the 「Reports」 list now starts with 「New report…」. A report needs a data source and a measure before it can be published, so it is not created from a name: the place stays held in the menu (「New report…」) and the report builder opens at the app's `reports/new`, saying that saving adds the report to the menu. The builder's Save creates and publishes the report in the package the menu is saved to (the app's package when it is writable, else its customization package), puts its entry in the held place, and saves the menu with every other change staged in the mode; the mode is then left and the report's page opens. When the menu save is refused the report is removed again, the mode and the held place stay, and the builder stays open with the reason. The builder's Close, or leaving the builder any other way, drops the held place and writes nothing. Opened outside the design mode, `reports/new` saves on its own as before.

‎ui/packages/app-shell/src/layout/DesignModeMenu.tsx‎

Lines changed: 107 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
* place, and the mode saves at once, every other staged change with it
3939
* (`saveAppMenuWithNewItem`); then the mode is left and the new dashboard
4040
* opens for editing (`dashboardEditArrival`). 「Cancel」 writes nothing.
41+
* In 「Reports」 the first row is 「New report…」: a report needs a data source
42+
* and a measure, so the place stays held and the report builder opens; its
43+
* Save creates the report and saves the mode the same way
44+
* (`designModeReportSlot`), and its Close drops the place, writing nothing.
4145
*
4246
* Every edit is staged with the mode (`useDesignModeChange`), under one key
4347
* for the app's menu: the mode's 「Save」 writes it (`saveAppMenu`), its
@@ -56,7 +60,7 @@
5660
*/
5761

5862
import * as React from 'react';
59-
import { Link, useNavigate } from 'react-router-dom';
63+
import { Link, useLocation, useNavigate } from 'react-router-dom';
6064
import { toast } from 'sonner';
6165
import {
6266
DndContext,
@@ -160,6 +164,7 @@ import {
160164
} from './designModeMenuSave.js';
161165
import { freeItemName, isNewMenuItemKind, saveAppMenuWithNewItem, type NewMenuItemKind } from './designModeMenuCreate.js';
162166
import { dashboardEditArrival } from './designModeArrival.js';
167+
import { offerNewReportSlot, withdrawNewReportSlot, type NewReportSlot } from './designModeReportSlot.js';
163168

164169
/**
165170
* The group label's icon-mode hiding, as the sidebar's own labels declare it
@@ -417,6 +422,83 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
417422
return true;
418423
};
419424

425+
// objectstack#36364 (report half) — 「New report…」: a report cannot be
426+
// made from a name (the spec wants `dataset` and `values`), so the place
427+
// stays held and the report builder opens at `reports/new`. The builder
428+
// saves through the slot offered here (`designModeReportSlot`): the report
429+
// is created in the menu's package and its entry saved in the held place
430+
// with every other staged change, in one act; nothing is written before.
431+
// The builder's Close drops the place. Resolves `false` when nothing was
432+
// saved (the mode has said why); the builder stays open for another try.
433+
const [buildingReport, setBuildingReport] = React.useState(false);
434+
const saveNewReport = async (name: string, label: string, body: Record<string, unknown>): Promise<boolean> => {
435+
if (!addAt) return false;
436+
// A report entry with no label shows its machine name (only an object,
437+
// view or dashboard entry inherits its target's label), so the entry
438+
// carries the name the reader gave the report.
439+
const entry = { ...entryFor('report', name, newEntryId([...menu, ...(storedMenu ?? [])])), label };
440+
const itemTexts = {
441+
...texts,
442+
itemPendingDraft: t('designMode.menu.newItemPendingDraft', {
443+
defaultValue: 'A draft with this name is already pending. Try again.',
444+
}),
445+
itemLeft: t('designMode.menu.newReportLeft', {
446+
defaultValue: 'The new report "{{name}}" could not be removed again; remove it in Studio.',
447+
name: label,
448+
}),
449+
};
450+
const saved = await saveWith(insertEntry(menu, addAt.parentId, addAt.index, entry), (navigation) =>
451+
saveAppMenuWithNewItem(
452+
{ appName, packageId, served, navigation, item: { kind: 'report', name, label, body } },
453+
itemTexts,
454+
consoleAppMenuDoors(client as never),
455+
),
456+
);
457+
if (!saved) return false;
458+
setAddAt(null);
459+
setBuildingReport(false);
460+
return true;
461+
};
462+
// The builder's address the held place waits on.
463+
const newReportPath = `${basePath}/reports/new`;
464+
const saveNewReportRef = React.useRef(saveNewReport);
465+
React.useLayoutEffect(() => {
466+
saveNewReportRef.current = saveNewReport;
467+
});
468+
React.useEffect(() => {
469+
if (!buildingReport) return;
470+
const slot: NewReportSlot = {
471+
path: newReportPath,
472+
save: (name, label, body) => saveNewReportRef.current(name, label, body),
473+
cancel: () => {
474+
setBuildingReport(false);
475+
setAddAt(null);
476+
},
477+
};
478+
offerNewReportSlot(slot);
479+
// Withdrawn when the place is no longer held, and when the menu unmounts
480+
// (the design mode ended): the builder then saves on its own, off the menu.
481+
return () => withdrawNewReportSlot(slot);
482+
}, [buildingReport, newReportPath]);
483+
// Leaving the builder another way than its Save or Close (a menu link, the
484+
// browser's Back) drops the place too, so no held row waits for a builder
485+
// that is gone. Read once the builder has been reached.
486+
const { pathname } = useLocation();
487+
const [reachedBuilder, setReachedBuilder] = React.useState(false);
488+
const onBuilder = pathname === newReportPath || pathname.endsWith(newReportPath);
489+
if (buildingReport && onBuilder && !reachedBuilder) setReachedBuilder(true);
490+
if (!buildingReport && reachedBuilder) setReachedBuilder(false);
491+
if (buildingReport && reachedBuilder && !onBuilder) {
492+
setBuildingReport(false);
493+
setReachedBuilder(false);
494+
setAddAt(null);
495+
}
496+
const startNewReport = () => {
497+
if (!addAt) return;
498+
setBuildingReport(true);
499+
navigate(newReportPath);
500+
};
501+
420502
const renderLeaf = (entry: MenuEntry, depth: number) => {
421503
const id = String(entry.id);
422504
const place = placeOf(menu, id);
@@ -456,7 +538,7 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
456538
const renderEntries = (entries: Menu, parentId: string | null, depth: number): React.ReactNode[] => {
457539
const rows: React.ReactNode[] = [];
458540
entries.forEach((entry, index) => {
459-
if (addAt && addAt.parentId === parentId && addAt.index === index) rows.push(<Placeholder key="placeholder" depth={depth} />);
541+
if (addAt && addAt.parentId === parentId && addAt.index === index) rows.push(<Placeholder key="placeholder" depth={depth} buildingReport={buildingReport} />);
460542
if (isGroup(entry)) {
461543
const gid = String(entry.id);
462544
rows.push(
@@ -477,7 +559,7 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
477559
rows.push(renderLeaf(entry, depth));
478560
}
479561
});
480-
if (addAt && addAt.parentId === parentId && addAt.index >= entries.length) rows.push(<Placeholder key="placeholder" depth={depth} />);
562+
if (addAt && addAt.parentId === parentId && addAt.index >= entries.length) rows.push(<Placeholder key="placeholder" depth={depth} buildingReport={buildingReport} />);
481563
rows.push(
482564
<AddRow
483565
key="add"
@@ -516,13 +598,14 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
516598
</SortableContext>
517599
</DndContext>
518600
</SidebarGroupContent>
519-
{addAt && (
601+
{addAt && !buildingReport && (
520602
<MenuItemPicker
521603
packageId={packageId}
522604
inMenu={menuTargets(menu)}
523605
onClose={() => setAddAt(null)}
524606
onPick={(kind, name, link) => pick(entryFor(kind, name, newEntryId([...menu, ...(storedMenu ?? [])]), link))}
525607
onCreate={createItem}
608+
onNewReport={startNewReport}
526609
language={language}
527610
/>
528611
)}
@@ -612,12 +695,14 @@ function MenuLeaf({
612695
);
613696
}
614697

615-
function Placeholder({ depth }: { depth: number }) {
698+
function Placeholder({ depth, buildingReport }: { depth: number; buildingReport?: boolean }) {
616699
const { t } = useObjectTranslation();
617700
return (
618701
<li className="list-none" style={indent(depth)} data-testid="design-menu-placeholder">
619702
<div className="mx-0.5 flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-sm text-sidebar-foreground/60">
620-
{t('designMode.menu.placeholder', { defaultValue: 'Choose a menu item…' })}
703+
{buildingReport
704+
? t('designMode.menu.newReport', { defaultValue: 'New report…' })
705+
: t('designMode.menu.placeholder', { defaultValue: 'Choose a menu item…' })}
621706
</div>
622707
</li>
623708
);
@@ -811,6 +896,7 @@ function MenuItemPicker({
811896
onClose,
812897
onPick,
813898
onCreate,
899+
onNewReport,
814900
language,
815901
}: {
816902
packageId: string;
@@ -819,6 +905,8 @@ function MenuItemPicker({
819905
onPick: (kind: MenuTargetKind, name: string, link?: { label: string; url: string }) => void;
820906
/** Create a new `kind` named `label`; `taken` is every name of that kind the picker lists. */
821907
onCreate: (kind: NewMenuItemKind, label: string, taken: readonly string[]) => Promise<boolean>;
908+
/** Build a new report for the held place, in the report builder. */
909+
onNewReport: () => void;
822910
language: string;
823911
}) {
824912
const { t } = useObjectTranslation();
@@ -943,6 +1031,19 @@ function MenuItemPicker({
9431031
</button>
9441032
</li>
9451033
)}
1034+
{kind === 'report' && (
1035+
<li>
1036+
<button
1037+
type="button"
1038+
onClick={onNewReport}
1039+
className="flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium text-primary hover:bg-accent"
1040+
data-testid="design-menu-picker-new-report"
1041+
>
1042+
<Plus className="h-4 w-4 shrink-0" aria-hidden="true" />
1043+
<span className="flex-1 truncate">{t('designMode.menu.newReport', { defaultValue: 'New report…' })}</span>
1044+
</button>
1045+
</li>
1046+
)}
9461047
{loading ? (
9471048
<li className="px-2 py-2 text-sm text-muted-foreground">{t('designMode.menu.loading', { defaultValue: 'Loading…' })}</li>
9481049
) : offered.length === 0 ? (

‎ui/packages/app-shell/src/layout/__tests__/DesignModeMenu-36363.test.tsx‎

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import '@testing-library/jest-dom/vitest';
1616
import * as React from 'react';
1717
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
1818
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';
19-
import { MemoryRouter, useLocation } from 'react-router-dom';
19+
import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom';
2020
import { SidebarProvider } from '@object-ui/components';
2121
import { NavigationRenderer } from '@object-ui/layout';
2222
import type { NavigationItem } from '@object-ui/types';
@@ -117,6 +117,7 @@ import { DesignModeBar } from '../DesignModeBar';
117117
import DesignModeMenu from '../DesignModeMenu';
118118
import { confirmUnsavedLeave } from '../../chrome/unsavedEdits';
119119
import { __resetDefaultLocale } from '../designModeMenuSave';
120+
import { newReportSlotFor } from '../designModeReportSlot';
120121

121122
const NAVIGATION = [
122123
{ id: 'home', type: 'report', reportName: 'pipeline', label: 'Home' },
@@ -777,6 +778,147 @@ describe('a new dashboard from 「Add menu item」 (objectstack#36364)', () => {
777778
});
778779
});
779780

781+
/** 「Add menu item」 under Insights, then 「Reports」. */
782+
async function openReports() {
783+
fireEvent.click(screen.getByTestId('design-menu-add-insights'));
784+
const picker = await screen.findByTestId('design-menu-picker');
785+
fireEvent.click(within(picker).getByRole('button', { name: 'Reports' }));
786+
await flush();
787+
return picker;
788+
}
789+
790+
/** A link elsewhere in the app, as the sidebar would follow one. */
791+
function GoElsewhere() {
792+
const navigate = useNavigate();
793+
return (
794+
<button type="button" onClick={() => navigate('/apps/crm/object/crm_lead')}>
795+
go elsewhere
796+
</button>
797+
);
798+
}
799+
800+
function startOnBuilderPath() {
801+
render(
802+
<MemoryRouter initialEntries={['/apps/crm']}>
803+
<Harness />
804+
<Landing />
805+
<GoElsewhere />
806+
</MemoryRouter>,
807+
);
808+
fireEvent.click(screen.getByText('enter'));
809+
}
810+
811+
const REPORT_BODY = {
812+
label: 'Payment analysis',
813+
type: 'summary',
814+
dataset: 'invoice_metrics',
815+
values: ['invoice_count'],
816+
chart: { type: 'metric', xAxis: '', yAxis: 'invoice_count' },
817+
};
818+
819+
describe('a new report from 「Add menu item」 (objectstack#36364, report half)', () => {
820+
it('「Reports」 lists 「New report…」 first; it holds the place and opens the report builder, writing nothing', async () => {
821+
startOnBuilderPath();
822+
const picker = await openReports();
823+
const rows = within(within(picker).getByTestId('design-menu-picker-rows')).getAllByRole('button').map((b) => b.textContent);
824+
// The report the menu already opens (Home → pipeline) is not offered again.
825+
expect(rows).toEqual(['New report…']);
826+
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-report'));
827+
await flush();
828+
expect(screen.queryByTestId('design-menu-picker')).toBeNull();
829+
expect(screen.getByTestId('landing')).toHaveTextContent('/apps/crm/reports/new null');
830+
// The place stays held, saying what it waits for.
831+
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', ['…']]]);
832+
expect(screen.getByTestId('design-menu-placeholder')).toHaveTextContent('New report…');
833+
expect(newReportSlotFor('/apps/crm/reports/new')).not.toBeNull();
834+
expect(newReportSlotFor('/apps/hr/reports/new')).toBeNull();
835+
expect(written).toEqual([]);
836+
});
837+
838+
it('the builder\'s Save: the report, then the menu with its entry in the held place and every other staged edit; the mode is left', async () => {
839+
startOnBuilderPath();
840+
await act_on('accounts', 'Move up'); // another staged edit, saved with it
841+
const picker = await openReports();
842+
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-report'));
843+
await flush();
844+
const slot = newReportSlotFor('/apps/crm/reports/new')!;
845+
let saved: boolean | undefined;
846+
await act(async () => {
847+
saved = await slot.save('payment_analysis', 'Payment analysis', { ...REPORT_BODY, name: 'payment_analysis' });
848+
});
849+
await flush();
850+
851+
expect(saved).toBe(true);
852+
expect(written.map(([verb, type, name]) => `${verb} ${type} ${name}`)).toEqual([
853+
'save report payment_analysis',
854+
'publish report payment_analysis',
855+
'save app crm',
856+
'publish app crm',
857+
]);
858+
expect(written[0][3]).toEqual({ ...REPORT_BODY, name: 'payment_analysis' });
859+
expect(written[0][4]).toEqual({ mode: 'draft', ifNoneMatch: '*', packageId: 'com.acme.crm' });
860+
const navigation = (written[2][3] as { navigation: Array<{ id: string; children?: unknown[] }> }).navigation;
861+
expect(navigation[1].children!.map((c) => (c as { id: string }).id)).toEqual(['accounts', 'leads']);
862+
expect(navigation[2].children).toEqual([
863+
{ id: 'nav_item_1', type: 'report', reportName: 'payment_analysis', label: 'Payment analysis' },
864+
]);
865+
expect(screen.queryByTestId('design-mode-bar')).toBeNull();
866+
expect(newReportSlotFor('/apps/crm/reports/new')).toBeNull();
867+
});
868+
869+
it('a refused menu removes the new report; the mode, the held place and the other staged edits stay', async () => {
870+
server.appSave = new Error('the app was refused');
871+
startOnBuilderPath();
872+
await act_on('accounts', 'Move up');
873+
const picker = await openReports();
874+
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-report'));
875+
await flush();
876+
let saved: boolean | undefined;
877+
await act(async () => {
878+
saved = await newReportSlotFor('/apps/crm/reports/new')!.save('payment_analysis', 'Payment analysis', { ...REPORT_BODY, name: 'payment_analysis' });
879+
});
880+
await flush();
881+
882+
expect(saved).toBe(false);
883+
expect(written.map(([verb, type, name, opt]) => `${verb} ${type} ${name} ${verb === 'reset' ? JSON.stringify(opt) : ''}`.trim())).toEqual([
884+
'save report payment_analysis',
885+
'publish report payment_analysis',
886+
'save app crm',
887+
'reset report payment_analysis {"packageId":"com.acme.crm"}',
888+
]);
889+
expect(toastError).toHaveBeenCalledWith('Some changes were not saved: the app was refused');
890+
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
891+
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', ['…']]]);
892+
expect(newReportSlotFor('/apps/crm/reports/new')).not.toBeNull();
893+
});
894+
895+
it('the builder\'s Close drops the held place and writes nothing; the mode and its other edits stay', async () => {
896+
startOnBuilderPath();
897+
await act_on('accounts', 'Move up');
898+
const picker = await openReports();
899+
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-report'));
900+
await flush();
901+
act(() => newReportSlotFor('/apps/crm/reports/new')!.cancel());
902+
await flush();
903+
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
904+
expect(newReportSlotFor('/apps/crm/reports/new')).toBeNull();
905+
expect(written).toEqual([]);
906+
expect(screen.getByTestId('design-mode-save')).toBeEnabled();
907+
});
908+
909+
it('leaving the builder another way drops the held place too', async () => {
910+
startOnBuilderPath();
911+
const picker = await openReports();
912+
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-report'));
913+
await flush();
914+
fireEvent.click(screen.getByText('go elsewhere'));
915+
await flush();
916+
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
917+
expect(newReportSlotFor('/apps/crm/reports/new')).toBeNull();
918+
expect(written).toEqual([]);
919+
});
920+
});
921+
780922
// ── objectstack#36591 ─────────────────────────────────────────────────────────
781923

782924
/**

0 commit comments

Comments
 (0)