Skip to content

Commit 4e10d4b

Browse files
feat(studio): 概览 package overview page — Info and Pending tabs, ⋯ menu in its header (#37546)
repo:objectstack#5 · os-bill · session_01Utp6CbL6Nn3scsU8yvLyU4 <!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgTC1DCWJ4MisoLdbUU1V1sb)_ Fixes #37454 Clause-②: no Metadata-protocol: none ## 维护者速读 用户能看到什么变化:在 Studio 里打开一个软件包,左侧菜单第一行变成「概览」,有待发布的修改时旁边显示数量,点数量直接进入待发布。概览页头显示包名、「系统自带/可写」「使用中/已停用」两个标记和包的描述,下面有「信息」「待发布」两栏;原来顶栏左侧的「⋯」软件包菜单搬到了这页页头的右侧。 为什么做:这是 App Studio 改版的第一步(精简的软件包概览)。包的基本信息和等着发布的修改都集中到这一页,不用再去顶栏和设置里分头找。 出错会怎样:在 Studio 里管理软件包的人会碰到。最可能的问题是待发布数字和实际不符,或者从概览发布的结果和顶栏发布不一样;顶栏的发布按钮仍然保留,可以照常用。这个改动可以直接撤回,不涉及数据。 要你做什么:无 ## What changes - **New page `StudioPackageOverviewPage`**, reached at `/studio/PACKAGE/overview` (ADR-0084 § 概览 Overview, amendment 2026-11-26). It is drawn in an item page's frame: `StudioItemHeader` plus `StudioTab`. - **Header**: the app mark (or the package icon), the name, and two chips: 系统自带 with a lock on a read-only package or 可写; and 使用中 or 已停用. Both chips come from the package list row's own `writable` / `enabled`; a row that does not say draws no chip. The description is the header's note, and the ⋯ menu sits in the header's actions. - **信息 Info**: read-only rows for name, description, source, version and the package's app (a link that opens it). A read-only package says so beside its source. The id, namespace and type are folded under 技术信息. While the row is read, the card holds an announced loading row (`role=status`); a failed read says so in place of the fields. - **待发布 Pending** (`?tab=pending`): the existing `DraftChangesPanel` drawn in place. Its tab carries the pending count only while something is pending. - **`DraftChangesPanel`** gains two optional props. Without them it behaves exactly as before; the body hunk is re-indented, so read it with `-w`. - `embedded` draws the same header notes and body in a `section` instead of a `Sheet`, and does not dismiss toasts on open. - `reloadKey` re-reads the drafts when it moves. - **`StudioDesignSurface`** - Renders the overview branch with the panel wired prop for prop like the top bar's sheet: `doPublish` (or `undefined` when `publishReadOnly`), `draftScope`, `renderPublishRefusal`, the pair's `customizationOf`, and `publishing`. - `StudioPendingDraftsContext.Provider` now wraps the menu and pillars row, so the menu can read the count. - The top bar's Changes / Publish stays; ADR-0084 keeps it until a later card. - **⋯ `StudioPackageMenu`** left `StudioBackToApp` (its `menu` prop is removed) and now lives in the overview header. Its six rows are unchanged, and it opens aligned to the end. Disable, enable and delete stay in Setup (question 1 ruled B). - **`StudioMenu`**: the first row of a package's menu, above the groups and under no group's label, is 概览 (a package cube icon). While drafts wait it carries their count as an amber badge, a link of its own beside the row, which opens `?tab=pending`. A search lists the row when its name matches. `~org` and `~all` draw no such row. The menu reads the count from `StudioPendingDraftsContext`. - **Address and menu model** - Address: `studioPackageOverviewPath` and `studioOverviewTab` in `studioOverviewAddress.ts`. The open tab rides the console's reserved `tab` key (`RECORD_DETAIL_TAB_PARAM`, `urlParams.ts`; ui AGENTS rule #8), which Studio's item pages already read through `ITEM_TOOL_TAB_PARAM`; no Studio constant restates it. The builder sits beside `studioAddress.ts` rather than in it because `urlParams.ts` imports `studioAddress.ts`, so the reverse import would be a cycle. `studioAddressTable.ts` gains the `overview` family, and its `tab` row describes the shared key: an item page's tab, and `pending` on the overview. - Menu model: `studioMenuOverviewEntry` (no entry outside a package; a badge only above zero), `studioMenuOverviewMatches`, and `studioMenuCurrentKey` answering `overview`. - **Package REST read**: `ListedPackageManifest` now carries `enabled` and `source` from the row of `GET /api/v1/packages`. There is no `package` metadata type. - **i18n (en, zh)**: `engine.studio.menu.overview`, `engine.studio.menu.overviewPending` with its singular `engine.studio.menu.overviewPendingOne` (the catalogue's `…One` form: "1 change waits for a publish"; zh reads the same either way), and `engine.studio.overview.*`. - **Changeset**: patch for `@object-ui/app-shell` and `@object-ui/i18n`. **Read first (by risk):** 1. `StudioDesignSurface.tsx`, the overview branch's `DraftChangesPanel` props. The Pending tab must publish exactly like the top bar. 2. `DraftChangesPanel.tsx`, the `embedded` return and the `reloadKey` effect deps. 3. `StudioMenu.tsx`, `renderOverview()` and its call above the groups: the badge is a sibling link, not nested in the row's link. ## Tests The broad run, typecheck and gates are on the final head 29bb079. Earlier rounds' ablations ran on 06830bf (page, Pending tab) and 618c0cf (menu row). - **New `StudioPackageOverview-37454.test.tsx`** (the real surface; the panel probe records the props given to the sheet and to the embedded panel). It covers: - the header chips in en and zh, read-only 系统自带 with a lock, and 已停用; - the menu in the header and not in the top bar, and no menu without `manage_metadata`; - the Info fields with the technical section folded, and the read-only source sentence; - the Pending count and the `?tab=pending` URL, with no count when nothing is pending; - embedded props identical to the sheet's, and `onPublish` undefined on both for a read-only package; - the branch order: a failed row read says so in place of the fields with the header kept; a read still on the wire shows the announced loading row and neither a failure nor fields, then the fields once it answers; an unknown package at its overview address lands on the not-found state; `~org/overview` redirects to the scope's area, read once through the route as the console mounts it and once with the surface alone. - **New `StudioMenu.overview-37454.test.tsx`** (real provider, sidebar primitive and router). It covers: - 概览 is the first link, above every group and under none; it opens the overview, reads 概览 in zh, and is current on the overview including the Pending tab; - CONTROL: `~org` and `~all` draw no row; - the badge reads 3 with its aria-label, and one draft reads in the singular ("1 change waits for a publish"); CONTROL: a ledger of 0 and an unknown ledger draw no badge; - one click on the badge lands on `/overview?tab=pending`, and the row lands on the Info tab; - a search lists the row on `over` but not on `flow`. - **`StudioMenu.test.tsx`**: the 常用 listing case now asserts that 概览 leads the menu before the 常用 types. Its #37452 cases (chevrons, active pill, graphite accent) pass unchanged. - **Re-pointed, not weakened**: `StudioDesignSurface.publishCount-11807.test.tsx` now runs every case twice, from the top bar and from the Pending tab (`describe.each`). `StudioPackageMenu-37139.test.tsx` now opens the menu from the overview header and asserts that the top bar has none. Its no-menu check on `~org` and `~all` now asks at the overview's own address on each scope, where the menu would be, instead of on pages that never drew it. - **Extended**: `DraftChangesPanel.posture-12517.test.tsx` covers the embedded panel: no dialog, publish with no options, no toast dismiss (control: the sheet dismisses), a `reloadKey` re-read (control: an unmoved key reads nothing more), and nothing drawn when closed. `studioMenuModel.test.ts` covers the overview entry, the badge, the matcher and the current key. `studioAddress.test.ts` covers the builder, the tab and the table lists. - **Broad run** over `studio-design/`, `preview/` and `packages/i18n/` on 29bb079: 449 files, 4720 passed and 13 skipped; lock VERDICT command-exit 0. - **Typecheck**: app-shell `tsc --noEmit` and `tsc -p tsconfig.test.json` both exit 0 (the test project at an 8 GB heap). - **Ablation** (each leg went red, and each restore is proven: blob equals HEAD and `git diff HEAD` is empty): - A1: Pending tab `onPublish` set to undefined. 6 red: 5 Pending-tab publish cases and the prop-parity case. - A2: embedded panel dismisses toasts. 1 red. - A3: `reloadKey` dropped from the effect deps. 1 red. - A4: `embedded` branch disabled. 1 red. - A5: read-only chip forced off. 3 red. - A6: badge drawn at zero in the model. 1 red. - B1: the menu row moved below the groups. 1 red (the first-row pin). - B2: the badge drawn whatever the count. 2 red (the zero and unknown controls). - B3: the badge linked to the row's own address. 1 red (the badge-click pin). - C1: the page's failure branch off. 1 red (the load-failure pin). - C2: the page's loading branch off. 1 red (the loading pin). - C3: the surface lets an unknown package through to the overview. 1 red (the not-found pin). - C4a: the surface's own `~org` redirect off. 1 red (the surface-alone case). - C4b, the control: only the pillar redirect's `~org` branch lets the overview through. It stays green because the surface's guard behind it catches the address. - C4c: both doors off. 2 red (both cases). - C5: the singular label never chosen. 1 red (the one-draft pin). <details> <summary>Ablation log (ablation-replace verdicts)</summary> ```text LEG A1-pending-onPublish :: exit 1 :: Test Files 2 failed (2) Tests 6 failed | 24 passed (30) LEG A2-embedded-toast :: exit 1 :: Test Files 1 failed (1) Tests 1 failed | 9 passed (10) LEG A3-reloadKey :: exit 1 :: Test Files 1 failed (1) Tests 1 failed | 9 passed (10) LEG A4-embedded-inplace :: exit 1 :: Test Files 1 failed | 1 passed (2) Tests 1 failed | 23 passed (24) LEG A5-readonly-chip :: exit 1 :: Test Files 1 failed (1) Tests 3 failed | 11 passed (14) LEG A6-badge-zero :: exit 1 :: Test Files 1 failed (1) Tests 1 failed | 31 passed (32) RESTORE diff-HEAD-bytes=0 status=0 ; hash-ok on all four mutated files LEG B1-first-row :: exit 1 :: Test Files 1 failed (1) Tests 1 failed | 9 passed (10) LEG B2-badge-always :: exit 1 :: Test Files 1 failed (1) Tests 2 failed | 8 passed (10) LEG B3-badge-target :: exit 1 :: Test Files 1 failed (1) Tests 1 failed | 9 passed (10) RESTORE diff-HEAD-bytes=0 status=0 ; hash-ok StudioMenu.tsx LEG C1-load-failed :: exit 1 :: Tests 1 failed | 3 passed | 14 skipped (18) LEG C2-loading :: exit 1 :: Tests 1 failed | 3 passed | 14 skipped (18) LEG C3-unknown-package :: exit 1 :: Tests 1 failed | 3 passed | 14 skipped (18) LEG C5-singular :: exit 1 :: Tests 1 failed | 10 passed (11) LEG C4a-surface-guard :: exit 1 :: Tests 1 failed | 1 passed | 17 skipped (19) LEG C4b-pillar-only :: exit 0 :: Tests 2 passed | 17 skipped (19) (control: the guard behind it holds) LEG C4c-both-doors :: exit 1 :: Tests 2 failed | 17 skipped (19) RESTORE diff-HEAD-bytes=0 status=0 ; hash-ok on every mutated file os-verify-lock: VERDICT command-exit 0 (every batch) ``` </details> ## Acceptance notes - The claim's file surface was amended to add `StudioMenu.tsx` for the 概览 row and its badge only. `studio-tokens.ts`, `studioAccent.ts`, `studioTitleRow.tsx` and `PageShell.tsx` are untouched. - The row is drawn in `StudioMenu.tsx` and not through `buildStudioMenu`, which builds only the domain groups: adding a kind there would change the per-kind records the menu keys on. The row reuses the sidebar primitive's `SidebarMenuButton`, so its active state is the same graphite pill as every entry. In the real browser the current-row background reads `rgba(53, 57, 64, 0.1)` in light and `rgba(208, 210, 216, 0.18)` in dark, the same on the 流程 entry and on the 概览 row, and the 5 group chevrons are drawn. - The icon is a package cube (`Package`). A first cut used `LayoutDashboard`, which the browser showed to be indistinguishable from 应用's `LayoutGrid`. - **Mockup 4 comparison.** - Header, chips, description, tabs, the Info card and the folded 技术信息 match. - Not in this card's governing text: the standalone 导出 button (export stays a ⋯ row, six rows unchanged) and the 发布历史 tab. - The source line shows the row's own `source` (代码。只读:不能直接修改。). The mockup's pair-aware sentence (你的修改会单独保存…) is copy for a later pass. - The overview's `?tab=` is the console's reserved key from `urlParams.ts` (ui AGENTS rule #8), not a Studio constant. Its builder lives in `studioOverviewAddress.ts` and not in `studioAddress.ts`: `urlParams.ts` imports `studioAddress.ts` and lists its `STUDIO_RETURN_PARAM` at module scope, so a back-import would be a cycle whose load order decides whether that list reads an uninitialised binding. - `reloadKey` is a prop added to the load effect's deps and not a `key=` bump, following ui AGENTS rule #8 on forced reloads. - The top-bar Publish is unchanged and stays until the card ADR-0084 names for its removal. ## Verification Two-minute check: run the showcase example and open `/studio/com.example.showcase/overview`. Expect: - the header with ObjectStack Showcase, 系统自带 with a lock, 使用中 and the description, with ⋯ at the right; - 信息 with 基本信息 and a folded 技术信息; - 待发布 listing any drafts, with 全部发布 at the bottom. **Real browser**: Chromium at deviceScaleFactor 2, light and dark, on the showcase with 3 AI-style view drafts in its customization pair. - Shots taken: the Info tab, the Info tab with 技术信息 open, the ⋯ menu open with its six rows, the Pending tab with a count of 3, the Pending tab after publishing, the menu with 概览 first and its badge (full page and close-up), and a badge click landing on the Pending tab. - In the menu, the first links are 概览, its badge (3, `3 项修改待发布`), then 对象. Clicking the badge lands on `/studio/com.example.showcase/overview?tab=pending` with the Pending tab open and 概览 current. - Clicking 全部发布 in the Pending tab sent `POST /api/v1/packages/com.example.showcase.custom/publish-drafts`. `_drafts` then read empty and the tab count disappeared. <details> <summary>Derived gates (dispatch-gates --ran)</summary> ```text Run reconciliation — 39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN. ✓ dispatch-gates --ran: 39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero — all 39 recorded an exit code and none of them is 3). every one of the 39 :: exit 0 (incl. check:nul-bytes, check:published-files, check:type-check-coverage, check:test-source-alias, check:cross-package-test-inputs, check-adr-0087-registration, check-empty-changeset, check-changeset-no-major) pnpm --dir ui exec vitest run scripts/ :: Test Files 172 passed | 2 skipped (174) · Tests 5130 passed | 2 skipped · lock VERDICT command-exit 0 check-platform-checklist --changed-from origin/main: OK — 2 anchor(s) judged, 0 lost ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CbL6Nn3scsU8yvLyU4)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1afb6d4 commit 4e10d4b

23 files changed

Lines changed: 1931 additions & 440 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(studio): a package's 概览 Overview page, with its Info and Pending tabs, and the package's ⋯ menu in its header
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Studio has a page for the open package itself, 概览 Overview, at `/studio/<package>/overview` (ADR-0084, amended 2026-11-26). It is drawn in the frame an item's page has, a header and a row of tabs:
12+
13+
- The header shows the package's name, a chip that reads 系统自带 (Built-in, with a lock) on a read-only package or 可写 (Writable), a chip that reads 使用中 (In use) or 已停用 (Disabled), and the description. The chips come from the package list's own answer (`writable`, `enabled`); a row that does not say draws no chip.
14+
- The ⋯ package menu moved here from the top bar's left end. Its six rows are unchanged: edit info, export, duplicate, revert to last publish, adopt loose items, and Manage in Setup…. Disabling, enabling and deleting a package stay in Setup → Packages.
15+
- 信息 Info lists the name, description, source, version and the package's app, read-only. The id, namespace and type are folded under 技术信息 (Technical details).
16+
- 待发布 Pending (`?tab=pending`) is the pending-changes panel drawn in place, with its Publish all. It publishes through the same request, with the same review, notes, refusals and read-only rule as the top bar's Publish, which stays for now. Its tab shows how many drafts wait.
17+
18+
The Studio menu's first row, above its groups, is 概览 Overview. While drafts wait for a publish it carries their count as a badge, and one click on the badge opens the Pending tab. A search lists it when its name matches.
19+
20+
`DraftChangesPanel` takes two optional props, `embedded` (draw the panel in place instead of as a sheet) and `reloadKey` (read the drafts again when it changes); without them it behaves as before. New locale keys in the studio catalogue (en, zh): `engine.studio.menu.overview`, `engine.studio.menu.overviewPending` with its singular `engine.studio.menu.overviewPendingOne`, and `engine.studio.overview.*`.

‎ui/packages/app-shell/src/preview/DraftChangesPanel.tsx‎

Lines changed: 402 additions & 353 deletions
Large diffs are not rendered by default.

‎ui/packages/app-shell/src/preview/__tests__/DraftChangesPanel.posture-12517.test.tsx‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
* The CONTROL is the mount the Home page, `DraftPreviewBar` and
1818
* `CommitTimeline` use: no `posture` prop at all. It must read exactly as the
1919
* review posture does.
20+
*
21+
* objectstack#37454 — the same panel drawn in place (`embedded`), as Studio's
22+
* package overview's Pending tab: the same list and Publish all with no sheet,
23+
* no toast cleared on opening, and a fresh read whenever `reloadKey` moves.
2024
*/
2125

2226
import '@testing-library/jest-dom/vitest';
@@ -34,6 +38,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
3438
}),
3539
}));
3640

41+
import { toast } from 'sonner';
3742
import { DraftChangesPanel, type DraftChangesPosture } from '../DraftChangesPanel';
3843
// The source under test reaches a dynamic `import('@objectstack/lint')`: pay its load at
3944
// collection, never inside a case's clocked window (`check:test-source-alias`).
@@ -156,3 +161,63 @@ describe('objectui#12517 — the pending-changes sheet opens in a posture', () =
156161
expectReviewPosture();
157162
});
158163
});
164+
165+
describe('objectstack#37454 — drawn in place as the overview\'s Pending tab (`embedded`)', () => {
166+
const draftReads = () => fetchMock.mock.calls.filter(([input]) => String(input).includes('/_drafts')).length;
167+
168+
function Embedded({ reloadKey, onPublish = () => {} }: { reloadKey?: unknown; onPublish?: () => void }) {
169+
return (
170+
<DraftChangesPanel embedded open onOpenChange={() => {}} packageId="com.x" onPublish={onPublish} reloadKey={reloadKey} />
171+
);
172+
}
173+
174+
it('lists the drafts with Publish all, in place: no sheet, no dialog; its button publishes with no options', async () => {
175+
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
176+
const onPublish = vi.fn();
177+
render(<Embedded onPublish={onPublish} />);
178+
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
179+
expect(screen.getByTestId('draft-changes-panel')).toHaveAttribute('data-embedded');
180+
expect(screen.getByTestId('draft-changes-panel').tagName).toBe('SECTION');
181+
expect(screen.queryByRole('dialog')).toBeNull();
182+
fireEvent.click(screen.getByTestId('draft-changes-publish'));
183+
expect(onPublish).toHaveBeenCalledTimes(1);
184+
expect(onPublish).toHaveBeenCalledWith();
185+
});
186+
187+
it('CONTROL: the sheet is a dialog, and carries no embedded mark', async () => {
188+
await renderHost('review');
189+
expect(screen.getByRole('dialog')).toBeInTheDocument();
190+
expect(screen.getByTestId('draft-changes-panel')).not.toHaveAttribute('data-embedded');
191+
});
192+
193+
it('opening clears no toast; CONTROL: opening the sheet clears them', async () => {
194+
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
195+
const dismiss = vi.spyOn(toast, 'dismiss');
196+
render(<Embedded />);
197+
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
198+
expect(dismiss).not.toHaveBeenCalled();
199+
cleanup();
200+
render(<Host posture="review" />);
201+
await waitFor(() => expect(dismiss).toHaveBeenCalled());
202+
dismiss.mockRestore();
203+
});
204+
205+
it('reads the drafts again when `reloadKey` moves; CONTROL: an unmoved key reads nothing more', async () => {
206+
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
207+
const { rerender } = render(<Embedded reloadKey="a" />);
208+
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
209+
const first = draftReads();
210+
expect(first).toBe(1);
211+
rerender(<Embedded reloadKey="a" />);
212+
await act(async () => {});
213+
expect(draftReads()).toBe(first);
214+
rerender(<Embedded reloadKey="b" />);
215+
await waitFor(() => expect(draftReads()).toBe(first + 1));
216+
});
217+
218+
it('closed, it draws nothing', () => {
219+
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
220+
render(<DraftChangesPanel embedded open={false} onOpenChange={() => {}} packageId="com.x" />);
221+
expect(screen.queryByTestId('draft-changes-panel')).toBeNull();
222+
});
223+
});

‎ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
* Leaving asks first when a pillar holds unsaved work, like every other
3030
* header departure (`beforeNavigate`).
3131
*
32-
* objectstack#37139 — right of the name, the host may draw the package's 「⋯」
33-
* menu (`menu`, `StudioPackageMenu`): only where there is a current package and
34-
* only for a `manage_metadata` holder, which the host decides.
32+
* objectstack#37454 — the package's 「⋯」 menu, which sat right of the name
33+
* (objectstack#37139), moved to 概览 Overview's header (ADR-0084, amended
34+
* 2026-11-26).
3535
*/
3636

3737
import * as React from 'react';
@@ -88,7 +88,6 @@ export function StudioBackToApp({
8888
locale,
8989
beforeNavigate,
9090
navigate,
91-
menu,
9291
}: {
9392
/** The open package, or `null` in the package-less scope. */
9493
packageId: string | null;
@@ -104,8 +103,6 @@ export function StudioBackToApp({
104103
/** The header's unsaved-work veto: return false to stay in Studio. */
105104
beforeNavigate: () => boolean;
106105
navigate: (path: string) => void;
107-
/** objectstack#37139 — the package's 「⋯」 menu, drawn right of the name; absent draws none. */
108-
menu?: React.ReactNode;
109106
}): React.ReactElement {
110107
// Read once per visit: nothing in Studio is an app page, so the record
111108
// cannot change while the author is here.
@@ -153,7 +150,6 @@ export function StudioBackToApp({
153150
</span>
154151
</>
155152
)}
156-
{menu}
157153
<span aria-hidden="true" className="shrink-0 text-muted-foreground">
158154
·
159155
</span>

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
* `DraftChangesPanel`, reduced to the button that fires `onPublish` (the sheet
2727
* has its own tests, `../../preview/__tests__/`).
2828
*
29+
* objectstack#37454 — the package's publish has a second door, 概览
30+
* Overview's Pending tab (the panel drawn in place, `embedded`), wired to the
31+
* same publish: every package-batch case below runs through both doors, the
32+
* top bar's and the Pending tab's, with the same expectations.
33+
*
2934
* The expected sentences are read from the string table through the same
3035
* `tFormat` the surface calls, so what is pinned is which row and which count,
3136
* never the prose.
@@ -70,9 +75,13 @@ vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPan
7075
vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null }));
7176
vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null }));
7277
vi.mock('../../preview/DraftChangesPanel', () => ({
73-
DraftChangesPanel: ({ onPublish }: { onPublish?: () => void | Promise<void> }) =>
78+
DraftChangesPanel: ({ onPublish, embedded }: { onPublish?: () => void | Promise<void>; embedded?: boolean }) =>
7479
onPublish ? (
75-
<button type="button" data-testid="publish-all-drafts" onClick={() => void onPublish()}>
80+
<button
81+
type="button"
82+
data-testid={embedded ? 'publish-all-drafts-pending-tab' : 'publish-all-drafts'}
83+
onClick={() => void onPublish()}
84+
>
7685
publish
7786
</button>
7887
) : null,
@@ -159,7 +168,7 @@ afterEach(() => {
159168
vi.unstubAllGlobals();
160169
});
161170

162-
async function publishAt(path: string, expectPosts: number): Promise<void> {
171+
async function publishAt(path: string, expectPosts: number, button = 'publish-all-drafts'): Promise<void> {
163172
render(
164173
<MemoryRouter initialEntries={[path]}>
165174
<Routes>
@@ -168,10 +177,19 @@ async function publishAt(path: string, expectPosts: number): Promise<void> {
168177
</Routes>
169178
</MemoryRouter>,
170179
);
171-
fireEvent.click(await screen.findByTestId('publish-all-drafts'));
180+
fireEvent.click(await screen.findByTestId(button));
172181
await waitFor(() => expect(posts).toHaveLength(expectPosts));
173182
}
174183

184+
/**
185+
* objectstack#37454 — the two doors of the package's publish: the top bar's
186+
* Publish (its review sheet's button), and 概览 Overview's Pending tab.
187+
*/
188+
const PACKAGE_DOORS = [
189+
{ door: 'the top bar', path: `/studio/${PACKAGE_ID}/interfaces`, button: 'publish-all-drafts' },
190+
{ door: 'the overview\'s Pending tab', path: `/studio/${PACKAGE_ID}/overview?tab=pending`, button: 'publish-all-drafts-pending-tab' },
191+
] as const;
192+
175193
/** Every toast the publish raised, by kind. */
176194
function toasts() {
177195
return {
@@ -181,7 +199,7 @@ function toasts() {
181199
};
182200
}
183201

184-
describe('the package publish names how many items went live, and what was refused (objectui#11807)', () => {
202+
describe.each(PACKAGE_DOORS)('the package publish names how many items went live, and what was refused (objectui#11807) — from $door', ({ path, button }) => {
185203
it('two published items: the count row, with 2', async () => {
186204
batchBody = batch({
187205
outcome: 'published',
@@ -190,7 +208,7 @@ describe('the package publish names how many items went live, and what was refus
190208
published: published('repairs_repair_ticket', 'visit'),
191209
failed: [],
192210
});
193-
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
211+
await publishAt(path, 1, button);
194212
await waitFor(() => expect(toast.success).toHaveBeenCalled());
195213
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCount', 'en', { count: 2 })]);
196214
expect(toasts().error).toEqual([]);
@@ -204,7 +222,7 @@ describe('the package publish names how many items went live, and what was refus
204222
published: published('visit'),
205223
failed: [],
206224
});
207-
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
225+
await publishAt(path, 1, button);
208226
await waitFor(() => expect(toast.success).toHaveBeenCalled());
209227
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCountOne', 'en', { count: 1 })]);
210228
});
@@ -222,15 +240,15 @@ describe('the package publish names how many items went live, and what was refus
222240
failed: [],
223241
unregistered: [{ type: 'object', name: 'visit', rule: 'object-registry-refused' }],
224242
});
225-
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
243+
await publishAt(path, 1, button);
226244
await waitFor(() => expect(toast.success).toHaveBeenCalled());
227245
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCount', 'en', { count: 2 })]);
228246
expect(toasts().error).toEqual([]);
229247
});
230248

231249
it('nothing to publish: said as such, neither a success nor a failure', async () => {
232250
batchBody = batch({ outcome: 'nothing_to_publish', publishedCount: 0, failedCount: 0, published: [], failed: [] });
233-
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
251+
await publishAt(path, 1, button);
234252
await waitFor(() => expect(toast.info).toHaveBeenCalled());
235253
expect(toasts()).toEqual({ success: [], info: [t('engine.studio.publishNoneTitle', 'en')], error: [] });
236254
});
@@ -247,7 +265,7 @@ describe('the package publish names how many items went live, and what was refus
247265
published: [],
248266
failed: [{ type: 'object', name: 'visit', error: reason, code: 'SECURITY_OWD_UNSET' }],
249267
});
250-
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
268+
await publishAt(path, 1, button);
251269
await waitFor(() => expect(toast.error).toHaveBeenCalled());
252270
expect(toasts().success).toEqual([]);
253271
expect(toasts().info).toEqual([]);

0 commit comments

Comments
 (0)