Skip to content

Commit 6e643cc

Browse files
feat(plugin-dashboard): a drill opens a centred dialog over the standard list, and a report's chart marks drill (#36461)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbD5gxSWeWGswbZYVzNvtqNM)_ Part of #36256 Fixes #36550 This PR lands the drill dialog. One piece stays open on the card, carried by #36507: a labelled chip for a relationship-path condition (plugin-list `readViewConditions` / `viewChipText`, nested-relation form). Clause-②: yes (widening) — additive members only, among them the new `PageRegionPostureReset` export of `@object-ui/components`; nothing is removed or renamed Metadata-protocol: none ## 维护者速读 - 用户在仪表盘或报表上点一个数字(柱子、扇区、折线点、指标卡、汇总行),原来从右侧滑出一个整高抽屉,现在在页面中央弹出一个约七成宽、六成半高的窗口,背后不变暗,里面就是对象列表页那张标准列表。 - 为什么做:这是仪表盘下钻体验改进的那张卡,维护者已批准的八点要求——条件变成可改可删的筛选标签、默认只显示名称和分组、度量字段、点名称进完整记录页并能上下翻、窗口里的操作都不保存。 - 出错会怎样:最坏是下钻窗口里列出的记录或默认列不对、或记录页的翻页顺序不对;什么都不写入,关掉窗口即复原,回退本合并即回到旧抽屉。 - 要你做什么:无。 ## What changes - **Centred dialog (items 1, 7).** On a desktop, a dashboard or dataset-report drill now opens a non-modal Radix dialog sized `w-[70vw] h-[65vh]`, using the shared dialog surface (#35980). Because it is non-modal, Radix draws no overlay: nothing behind it is dimmed or blurred. The header keeps the title and 「Open in list」, which is unchanged. On a phone (`useIsMobile`) the side drawer stays, with the same list inside. - **The body is the standard list (item 5).** The new `DrillRecordList` mounts the registry's `list-view` (the block the object list page uses) through `SchemaRenderer`, bound with `dataSource: { object }`. It is read-only: `userActions` turns off inline edit, add record, row colour and grouping; `showViewSwitcher={false}`; and the dialog never receives a save-view, add, bulk, edit, delete, sort-change or filter-change callback. When `list-view` is not registered, the drill falls back to the dashboard's data table, and its rows no longer open a stacked record panel. - **Conditions as the list's own chips (item 3).** The new `drillConditions.ts` splits the composed drill filter (widget filter, global filters, clicked bucket, measure scope) into the list's `initialFilters` rows, which are ordinary chips that can be edited and removed. Anything a chip row cannot say (a relationship path, `$or`, an unknown operator) stays the list's base `filter`, ANDed. A filter that is not the object form is lowered first. Examples are a page block's authored rule array `[{ field, operator, value }]` and an AST node. The lowering goes through the drill's own composition, `composeDrillFilter` in `@object-ui/core` (`mergeFilterNodes`, then the spec's `parseFilterAST`), and is not a new normaliser. A shape that cannot be lowered stays the list's base `filter` exactly as it arrived: one the conversion refuses (`FilterOperatorError`), and a non-empty one it answers nothing for (an array that is neither rules nor AST, a rule with a blank or missing field, a valid rule beside such an element). A string or number filter, which no list can read, lists nothing: the drawer shows its existing 「can't be listed from here」 notice and sends no read. No condition is ever dropped, and no drill reads every record. A condition stated twice is drawn once. On date fields, `$lt` and `$gt` are written as the list's own `before` and `after`, which lower to the same less-than and greater-than comparisons. - **Default columns (item 4).** The defaults are the object's name field, then the grouped fields, then the range fields, then the measured fields. A relationship-path dimension or range field (`crm_account.industry`) shows its lookup field (`crm_account`) instead. The grid has no dotted-column support, so the lookup column (the account's name) stands in for the related value. This applies to the dashboard widget and the dataset report alike. The measured fields are read from the answer's `drillScopes` (`{field: {$null: false}}`). An authored `drillDown.columns` still wins. 「View settings → Add column」 adds any other field. Added columns and column calculations live only in the dialog's state. - **Record name opens its full page (item 6).** `DrillNavigationContext` gains an optional `openRecord(objectName, id, {siblings, total})`. The app-shell hook implements it by navigating to the record page with history state `from = {pathname, label, siblings, total}`, the same shape a list hands the page it opens. The record page's existing stepper then reads 「1 of 3 · Pipeline Dashboard」, walks the drill rows, and its way back is the dashboard or report. `RecordDetailView` is unchanged. - **Report chart marks drill (item 2).** `DatasetReportChart` passed no `onChartClick`. A bar now maps through `findChartSeriesRow` to the summary line it stands for, and both go through one builder (`emitBucketDrill`), so the bar and its line open the same records with the same default `fields`. `drilldown: false` still offers no click. - **A host with no record page (page blocks).** The `object-metric` and `object-pivot` page blocks mount the drill without a `DrillNavigationProvider`, so there is no `openRecord`. There, a drilled row opens its record in a dialog (`RecordDetailDrawer`, `target: 'dialog'`), from both the standard list and the data-table fallback. Dashboard and report hosts are unchanged and open the record page. - The data-table fallback behaves exactly as on `main`. - The standard list reads only the fields it lists (`$select`). So its record dialog draws those fields, each with its value. It uses the authored `drillDown.columns` when given, as `ObjectDataTable` does. It does not list every field of the object with the unread ones shown as empty. - Values stay masked while the field types are unknown, through the drawer's `objectTypesPending` guard, as in the data table. - **Inside a page, the standard list too (#36550).** React context crosses the dialog's portal, so a page block's drill list used to take the posture of the region holding the block. On a region half the page or wider that is the capped list: no toolbar, no chips, no pager, and a 「View all N」 link. That link went to the object's default list with no drill condition (L1-e measured it on HotCRM's 销售主页: 「查看全部 8 条」 landed on 10 open deals). `DrillRecordList` now clears the posture for its subtree with the new `PageRegionPostureReset` (`@object-ui/components`, next to `PageRegionPostureProvider`). The drill therefore draws the standard list everywhere, with its chips, record count and pager, and no 「View all」 link. The page's own list blocks keep their posture. - **Nothing is written (item 8).** No view, no preference and no record write comes from the dialog. Measured in the browser and pinned in a test (see below). - **Two `measuredFieldsOf` copies, on purpose.** One lives in plugin-dashboard `drillConditions.ts`, the other in plugin-report `DatasetReportRenderer.tsx`, and no shared helper was added to `@object-ui/core`. Their predicates differ. The dashboard copy reads a measure scope that is already one record list, and takes a field only when its whole condition is `{$null: false}`. The report copy reads the answer's `drillScopes` per line, and takes every `$null: false` field it finds. A scope that adds other conditions on the same field gets a column in the report but not in the dashboard. This is a known edge. - **New optional members:** `DrillNavigationValue.openRecord`, the `DrillRecordOrigin` type (`@object-ui/react`), `DrillDownDrawerProps.defaultColumns` and `DatasetDrillArgs.fields`. **New export:** `PageRegionPostureReset` (`@object-ui/components`, a `patch` entry (Metadata-protocol: none)). ## Tests <details><summary>Unit and integration runs (head 0290ee5)</summary> All runs below are under `scripts/pm/os-verify-lock.sh`, on head `0290ee50d3`. - Drill suites, run from `ui/` with `pnpm exec vitest run --maxWorkers=2`, covering: - plugin-dashboard: drillConditions, DrillDownDialog, DrillDownDrawer*, DatasetWidget* - plugin-report: all tests - app-shell: useOpenRecordList*, drillDialogStandardList-36256, ReportView*, DashboardView* Result: `Test Files 103 passed (103)` · `Tests 919 passed | 7 skipped (926)` · vitest exit 0. - `pnpm --dir ui exec vitest run scripts/` (derived): `Test Files 172 passed | 2 skipped (174)` · `Tests 5127 passed | 2 skipped (5129)` · exit 0. - Reverse check on the rebuilt `.d.ts`: a probe passed `{ siblings: ['a'], bogus: 1 }` to `openRecord`. `tsc` turned red with `TS2353 ... 'bogus' does not exist in type 'DrillRecordOrigin'` (exit 2). The probe was then removed, and `git status` is clean. </details> <details><summary>Type-check (built closure)</summary> - Built `@objectstack/spec` first, then `pnpm --filter '@object-ui/app-shell^...' run build`. Both exit 0. - `type-check` (the script name was echoed) exits 0 for each of `@object-ui/react`, `@object-ui/plugin-dashboard`, `@object-ui/plugin-report` and `@object-ui/app-shell`. Each runs `tsc --noEmit` and then `tsc -p tsconfig.test.json`. - Derived gates: `dispatch-gates --ran` reads `38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero)`. - `check-platform-checklist --changed-from origin/main`: OK. - `overlap-check`: `VERDICT clean exit 0`. The check covers #36405 and #36420, and both merge cleanly. </details> <details><summary>CI fix round (head bd8af5c)</summary> Four reds on 0290ee5 and f8140a7, each reproduced locally and then shown green: - **Type Check UI** was failing `check:spec-symbols`: the drill's chip-split file declared a local type named like a spec export (`Scalar`, owned by `@objectstack/spec/data`). The fix inlines the union. The check exits 1 on the old tree and 0 on the fix, measured with `@objectstack/spec` built. The other steps of the same job (`check:action-forward-parity`, `check:designer-field-key-parity`, `check:icon-record-names`, `check:i18n-keys`, `check:i18n-drift`) exit 0, and `type-check` exits 0 for `@object-ui/plugin-dashboard` and `@object-ui/app-shell` on the merged head. - **Lint UI:** `react-hooks/globals` flagged the drill dialog test's stub, which wrote a module-level variable during render. The stub now reports its props through a `vi.fn` spy. `eslint` on the old file gives 1 error. `lint` exits 0 (0 errors) for `@object-ui/plugin-dashboard`, `@object-ui/plugin-report`, `@object-ui/react` and `@object-ui/app-shell`. - **Test UI (10/16)** was failing `components/src/__tests__/dialogViewportGutterCensus-12603.test.ts`. The dialog lifted the width cap (`sm:max-w-none`), which the census reads as a wide dialog with no viewport gutter. It now caps at `max-w-[70vw]`, so the size is unchanged (70vw by 65vh) and the dialog keeps its own margin. The census fails 2 tests on the old tree; on the fix, the census plus the drill dialog suites read 4 files and 22 tests passed. - **Test UI aggregate on 0290ee5:** its seven shards were cancelled mid-run, when the next push started the concurrency group's new run. None of them failed. - **Build and E2E UI** failed in `check:eager-closure` before any spec ran: a superseded `PER_CHUNK_GZIP_CEILINGS` (main moved it, and nothing had grown). Merging `origin/main` (37367f3) clears it, as the gate prescribes. Readings on the new head: - The sibling drill suites (all of plugin-dashboard, plugin-charts and plugin-report; app-shell drill*, ReportView*, DashboardView* and useOpenRecordList*; console drillDownReport*; types drill-down*): 382 files and 4043 tests passed. - After the merge: 28 files and 230 tests passed. - `vitest run scripts/`: 172 files passed. - `dispatch-gates --ran`: 38 derived, 38 run, 0 NOT-MEASURED. - `overlap-check`: clean. </details> <details><summary>Round 7 (no dropped filter, standard list inside a page)</summary> **M6, a non-empty filter the conversion answered nothing for.** `composeDrillFilter` answers `undefined` without throwing for an array that is neither rules nor AST, a rule with a blank or missing field, and a valid rule beside such an element. `drillListConditions` read that as no filter, so the drill listed every record. Now a non-empty input (anything but `undefined`, `null`, `[]` or `{}`) whose conversion comes back empty is kept as the list's base filter, the same as the throwing path. - Measured with the real plugin-list over `ValueDataSource`: each such array reaches the read as `$filter` (a server refuses it as malformed), and the open deal is never listed. - A string or a number cannot be kept that way. The list's own `toFilterNode` reads a non-object as no filter, so the read went out with no `$filter` and listed 3 of 3 rows. `DrillDownDrawer` now shows its existing `unavailable` notice for such a filter and mounts no list, so no read is sent. This adds no new copy. **#36550, the page region's posture inside the drill.** `DrillRecordList` wraps its subtree in the new `PageRegionPostureReset`. As L1-e found, the capped list's 「View all N」 link inside the drill came from the host's `compactListDestination`: the object's default view, with no drill condition. That link is no longer drawn there. **Pins, red on 942e9c2's `drillConditions.ts`, `DrillDownDrawer.tsx` and `DrillRecordList.tsx`, then green.** Red: `12 failed | 15 passed (27)`. Green: `27 passed (27)`. Restored with `git checkout HEAD --`, then checked: `git diff HEAD` empty and the blob hashes match. - `drillConditions-36256.test.ts`: six inputs the conversion answers nothing for (an array of a bare object, a blank field, no field, a valid rule beside a malformed one, a string, a number) stay the base filter as they arrived. `undefined`, `null`, `[]` and `{}` are still no filter. N8: an `and` node lowers to chips; an `or` node, and a rule array's any-of group, go to the base filter as `$or`. The N8 cases are green on both sides, because they pin behaviour that already held. - `app-shell/.../pageBlockDrillFilter-36256.test.tsx`: the three arrays above, each with every read carrying `$filter` and the open deal not listed. The string and the number show the `unavailable` notice and send no read. - `app-shell/.../pageBlockDrillPosture-36550.test.tsx`: the real page renderer, `object-metric` and `list-view`, with the region widths stubbed. The drill in the `main` region (856 of 1200 px) shows the chip `filter-chip-stage`, 「2 records」, no capped table and no 「View all」 link. CONTROL: the page's own `list-view` block in the same region stays capped (3 capped rows and 「View all 3」). Red: no chip in the dialog. **Live re-check on HotCRM 销售主页.** Branch Console at de4dfdf456 over HotCRM `origin/main` (689166c). The same local-only `drillDown` was added to `kpi_revenue_won`; it was not committed and was reverted afterwards. - The tile reads 1,290,000. The drill dialog draws the standard list: the toolbar, the chip 「阶段:成交」, the columns 商机名称 / 所属客户 / 金额 / 预计成交日期, 8 rows and 「8 条记录」. - No 「查看全部」 link and no capped table inside the dialog. The page's own list blocks stay capped (3 capped tables on the page). - The 8 rows are exactly HotCRM's 8 `closed_won` opportunities out of 23. - The read: `/api/v1/data/crm_opportunity?populate=crm_account&top=25&select=id,name,crm_account,amount,close_date,stage&filter=["stage","=","closed_won"]`. - Shot: project files `repo-objectstack-7/card-36256/hotcrm-r7-sales-home-drill.png`. **Runs on de4dfdf456.** That tree was pushed as 8e8c3bf, which differs only in a reworded trailer. a9d781d then changes only the changeset's `@object-ui/components` grade from `minor` to `patch`, as the `Check Changeset` level axis requires under `Metadata-protocol: none` (run offline with this body as the event: exit 0). plugin-dashboard + plugin-report: 251 files, 2425 passed / 13 skipped. components: 505 files (1 skipped), 4914 passed / 24 skipped. app-shell drill and page-block suites plus plugin-list's three posture pins: 15 files, 168 passed. type-check exit 0 for components, plugin-dashboard, plugin-report and app-shell. lint 0 errors for components, plugin-dashboard and app-shell. `overlap-check`: `VERDICT clean exit 0`, with 0 open PR heads sharing a file, the components index included. </details> <details><summary>Round 6 (page-block drill filter)</summary> **The defect.** Found live by L1-e, on HotCRM's 销售主页 tile 总收入(全部期间). - The tile is an `object-metric` block whose `filter` is the spec's rule array, `[{ field: 'stage', operator: 'equals', value: 'closed_won' }]`. - The drill list split only an object-form filter, so it received neither chips nor a base filter. It listed all 23 opportunities where the tile counts 8. - **Main kept the filter.** On main the drill went to the data table, which handed the array to `$filter` as written. The adapter lowers it. - Measured on origin/main a3ee862 with the same object-metric fixture over an in-memory matcher. The read's `$filter` was `[{"field":"stage","operator":"equals","value":"closed_won"}]`, and the rows were the 2 won deals only. - So this PR introduced the regression, and round 6 fixes it. **Pins, each run red on b91ec49's `drillConditions.ts` and `DrillRecordList.tsx`, then green.** Red: `4 failed | 7 passed (11)`. Green: 11/11. - `plugin-dashboard/__tests__/pageBlockDrillFilter-36256.test.tsx`: - An `object-metric` block with the HotCRM rule array: the drill list gets the chip `stage equals closed_won`. Red: `expected { chips: [], base: undefined }`. - An `object-pivot` block with the same rule array: the drill list gets the block's condition and the clicked cell's. This one is green on both sides, because the pivot composes through `composeDrillFilter` before the drill. - `app-shell/src/views/pageBlockDrillFilter-36256.test.tsx`: the real `@object-ui/plugin-list` over `ValueDataSource`. The drill lists exactly the won records the tile sums, never the open one, and its read's `$filter` carries `closed_won`. Red: the open deal was listed. - `drillConditions-36256.test.ts`: - A rule array lowers to a chip, and so does an AST node. - A shape the spec refuses (`[['stage', 'in', 'won']]`) stays the base filter exactly as it arrived. **Live re-check on HotCRM.** Branch Console, HotCRM `origin/main` on 18.6.0. A local-only `drillDown` (`{ enabled: true, target: 'dialog', columns: ['name','crm_account','amount','close_date'] }`) was added to `kpi_revenue_won`; it was not committed and was reverted afterwards. - The tile reads 1,290,000, and the drill lists 8 rows. - Those rows are exactly HotCRM's 8 `closed_won` opportunities (out of 23), each with stage `closed_won`. - The read: `/api/v1/data/crm_opportunity?populate=crm_account&top=25&select=id,name,crm_account,amount,close_date,stage&filter=["stage","=","closed_won"]`. - Shot: project files `repo-objectstack-7/card-36256/hotcrm-r6-sales-home-drill.png`. </details> <details><summary>Round 5 (S3, S4, N4; head b91ec49)</summary> All runs are under `scripts/pm/os-verify-lock.sh`, from `ui/` with `pnpm exec vitest run --maxWorkers=2`. - **S3 pin** (`ObjectMetricWidget.drillOpensRecord-36256`, a new case). The list stub answers with the record projected to its listed columns, the way the list's `$select` read does. The object has 5 fields, and the drill lists 3. - Red: `DrillRecordList.tsx` at c59a3fc gives `1 failed | 2 passed (3)`, with `expected [ 'Name', 'Stage', 'Amount', …(2) ] to deeply equal [ 'Name', 'Stage', 'Amount' ]`. - Green: restored with `git checkout HEAD --` and `git diff HEAD` empty, giving 3/3. - **S4.** - The `openRecord` jsdoc now reads "Absent ⇒ the drill opens the record in a dialog." - DELIBERATE CORRECTION of `.changeset/36256-drill-dialog-standard-list.md`. Its last sentence now reads: "A renderer without `@object-ui/plugin-list` registered lists the drilled records in the dashboard's data table. A host that gives no `openRecord` (a page block's metric or pivot) opens the drilled record in a dialog, from either body." - **N4.** `range.field` takes its first segment in both `DatasetWidget` and `emitBucketDrill`. Other readings on b91ec49: - plugin-dashboard + plugin-report in full: `Test Files 250 passed (250)` · `Tests 2411 passed | 13 skipped (2424)` · exit 0. - `type-check` exits 0 for plugin-dashboard, plugin-report and react, after the closure build. `lint` gives 0 errors for all three. - `vitest run scripts/`: 172 files passed. - `dispatch-gates --ran`: 38 derived, 38 run, 0 NOT-MEASURED. - `overlap-check`: clean. </details> <details><summary>Round 4 (head 5af2f6e)</summary> All runs are under `scripts/pm/os-verify-lock.sh`, from `ui/` with `pnpm exec vitest run --maxWorkers=2`. - Red, then green, with the round-4 source reverted to the round-3 head (0a48051) and then restored (byte-compared with `cmp`, and the marker `grep -c` read 0 then 1): - The path-column pins: red 2 failed / 2 passed (4), green 4/4. Covers `DatasetWidget` and `DatasetReportRenderer.chartMarkDrill-36256`. - The S1, S2 and N2 pins: red 3 failed / 9 passed (12), green 12/12. - The red reasons: `expected [ 'amount' ] to deeply equal [ 'crm_account', 'amount' ]`, and `Unable to find [data-testid="record-detail-body"]` (twice). - The N2 phone pin, by mutation through `scripts/ablation-replace.mjs` (`&& !phone` removed): `1 failed | 6 passed (7)`. The restore was verified as blob equal to HEAD with an empty `git diff HEAD`. - The full plugin-dashboard + plugin-report run: `Test Files 250 passed (250)` · `Tests 2410 passed | 13 skipped (2423)` · exit 0. - The app-shell drill suites (9 files): 132/132. - `type-check` (the script name was echoed, and it chains `tsc -p tsconfig.test.json`) exits 0 for `@object-ui/plugin-dashboard` and `@object-ui/plugin-report`, after building the `^...` closure. - `lint` exits 0 for both, with 0 errors. </details> New card-named tests: - `plugin-dashboard/src/__tests__/drillConditions-36256.test.ts`: chip rows versus the base filter, de-duplication, date bound wording, and measured fields. - `plugin-dashboard/src/__tests__/DrillDownDialog-36256.test.tsx`: - The dialog is centred and sized, with no overlay. - The list schema is read-only. - The chips, the default columns, and that added columns and calculations stay in local state. - The record name calls `openRecord` with the shown rows and closes the drill. - Phone keeps the drawer: `useIsMobile` is mocked true, and a mutation of the phone branch turns it red. Without `list-view` registered, no panel is stacked. - `app-shell/src/views/drillDialogStandardList-36256.test.tsx`: the real `@object-ui/plugin-list`. The chips are removable, and a removal re-reads without the condition. There are zero `create/update/delete/bulk` calls, no non-GET fetch and no `localStorage.setItem`. Columns lead with Name, then the drilled fields. - `app-shell/src/views/useOpenRecordList.drillRecordPage-36256.test.tsx`: `openRecord` drives `useRecordPageReturn`, giving the stepper 2 of 3, next to 3 of 3, and back to the dashboard URL including its query. - `plugin-report/src/__tests__/DatasetReportRenderer.chartMarkDrill-36256.test.tsx`: a bar and its summary line emit the same `objectFilter` and `fields`. `drilldown: false` offers no click. A `crm_account.industry` line drills on the nested condition with fields `['crm_account', 'amount']`. - `plugin-dashboard/src/__tests__/DatasetWidget.drillDialog-36256.test.tsx`: `DatasetWidget` itself opens the dialog (`target="dialog"`, `open`), with these default columns: - A chart mark (`onSegmentClick`): the grouped field, then the range field, then `measuredFieldsOf(scope)`, which gives `['stage', 'close_date', 'amount']`. - A metric tile: `measuredFieldsOf(readMeasureDrillScope(...))`, which gives `['amount']`. - A `crm_account.industry` slice: `['crm_account', 'amount']`. - `plugin-dashboard/src/__tests__/ObjectMetricWidget.drillOpensRecord-36256.test.tsx`: an `object-metric` block with no provider opens the drilled record in a dialog, from the standard list and from the data-table fallback. Changed tests: - `DrillDownDrawer.chain.test.tsx` is split by host: with a record page, the fallback rows are inert; with no record page, they stay drill-to-record. - `summarySubtotals-27975` now expects `fields: ['owner_id']` on the subtotal drill. ## Acceptance notes **HotCRM walk (round 4).** Branch Console at 5af2f6e's source, against HotCRM booted from the published 18.6.0 packages. Desktop at 1440×1000, zh-CN. The executive dashboard (高管总览) and the 各阶段商机 report. - **行业收入分布, slice 科技.** The dialog opens with 3 records. The columns are 商机名称, 所属客户 and 金额, so the lookup column stands in for the industry. The industry condition is a locked chip reading 「所属客户:= [object Object]」. That is the remainder carried by #36507. It does not read "View filter". ![industry slice](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-industry-slice.png) - **收入趋势, month 2026年8月.** 1 record. The chips are the 12-month window plus the bucket: 预计成交日期 ≥ 2026-08-01 and 早于 2026-09-01. The columns are 商机名称, 预计成交日期 and 金额. - **年度累计收入 tile (1,290,000).** 8 records. The chips are 阶段:成交, the date bounds and 金额. The columns are 商机名称 and 金额. - **各阶段商机 report.** The 谈判 bar and its summary cell 1,294,000 open the same 2 records, with identical names in the same order: Wayne Enterprise License and Vertex Enterprise Rollout. The chips and the columns (商机名称, 阶段, 金额) are the same for both. - **Global filter.** - Set to 上季度, the only date-bound widget (阶段管道分布) is empty in HotCRM's data. Its query asks for close_date 2026-07-01..2026-09-30 and returns `[]`, so there is no mark to drill. ![last quarter empty](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-last-quarter-empty.png) - The count match therefore uses 今年 instead, the nearest range that has data. The 需求分析 bar reads 93,000 in the chart's answer. The dialog carries the date condition as chips (预计成交日期 ≥ 2026-01-01 and ≤ 2026-12-31) and lists 1 record, whose amount sums to 93,000. ![this year drill](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-this-year-drill.png) - **Record name.** Clicking Wayne Enterprise License opens its record page, reading 「第 1 条,共 2 条 · 各阶段商机」. ![record stepper](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-record-stepper.png) - More shots: [month](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-revenue-month.png) · [YTD tile](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-ytd-tile.png) · [report bar](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-stage-bar.png) · [report cell](https://raw.githubusercontent.com/objectstack-ai/objectstack/5290b53bed7b42c0dbbd1a3c1dc23b4a36d4c512/hotcrm-stage-cell.png). The images live on the `claude/issue-36256-shots` branch, which holds no code. - **Writes:** none from the dialog. The only non-GET requests were `PATCH sys_user_preference` (the dashboard's recent-visit entry) and the record page's own `POST .../page` read. Browser walk on `examples/app-crm` (Pipeline dashboard), desktop at 1440×900. The screenshots are in the project files under `repo-objectstack-7/card-36256/`: - `1-bar-dialog.png`: the bar 「Closed Won」. The dialog box measured 1008×585 px, which is exactly 70% × 65%. The overlay count is 0. Chips: Expected Close ≥ / ≤ (from the widget), Stage: Closed Won, Expected Close before 2027-01-01. Columns: Opportunity Name, Stage, Expected Close. 3 records. - `2-donut-dialog.png`: the donut slice 「Prospecting」. Chips: Stage is none of Closed Won, Closed Lost; Deal Value is_not_null; Stage: Prospecting. Columns: Name, Stage, Deal Value. - `3-line-dialog.png`: a line point 「2026-10」. Chips: the 12-month window plus the month bucket. - `4-kpi-dialog.png`: the tile 「Won This Quarter」. Columns: Name, Deal Value. - `5-chip-removed.png`: Stage: Closed Won removed. The list re-read and showed 6 records. Closing and reopening restores the original chips. - `6-added-column.png`: View settings → Add column → Deal Value is added as a 4th column. - `7-record-page-1-of-3.png` and `8-record-page-2-of-3.png`: clicking a record name opens its full page reading 「1 of 3 · Pipeline Dashboard」, with no dialog left open. Next goes to 「2 of 3」. 「Pipeline Dashboard」 returns to the dashboard URL. - `9-phone-drawer.png`: at 390 px wide the drawer keeps the phone list, with a filter badge of 5 and 3 records. - **Writes:** - During the open, sort, add-column, chip-removal and close/reopen phases, zero non-GET `/api/` requests were captured, apart from the dataset reads. - The single `PATCH sys_user_preference` seen was the dashboard's own recent-visit entry (`type: dashboard`), fired on page load. A second one came from the record page's recent-visit entry. Neither comes from the dialog. - **Known edges, each with its carrier:** - Raw operator ids on chips. HotCRM measured 「金额:is_not_null」 on every drill whose measure scope is `$null: false`, and 「阶段:not_equals 失败」 on the report drill (from `$ne`). The cause is plugin-list `quickOperatorLabel`, which has no words for `not_equals`, `greater_than`, `less_than`, `is_null` or `is_not_null` and prints the stored id. The drill does not swap in a near-synonym. Carrier: #36462. - A string or number drill filter lists nothing, with the drawer's existing `unavailable` notice and no read (a deviation from the round-7 recipe, accepted by the seat): no list can carry such a filter, and the list's own `toFilterNode` would read it as no filter and list every record. - The relationship-path chip. A slice grouped by `crm_account.industry` lists the right records, but its locked chip reads 「所属客户:= [object Object]」 (see the industry shot above). Carrier: #36507. - Other conditions a chip row cannot say also stay in the locked base filter, worded by the list. Measured with the real plugin-list: an `$or` reads 「View filter」, while an operator the rows have no id for (`$startsWith`) reads 「Owner: startswith A」. - A long chip row is cut at the dialog's right edge; the list's own chip bar decides this. - The line bucket title shows the raw key (「2026-10」), as before. - The drill's matched total does not reach the record page (found in round 7). Carrier: #36554. `ListViewBlock` hands `ListView` its own `onTotalChange={reportTabCount}` after spreading the props, so the drill's `onTotalChange` is replaced (by `undefined` outside a `page:tabs` panel). Measured with the real list over a source answering `total: 40` for 2 rows: `openRecord` received `{ siblings: ['d1','d2'] }` and no `total`. So the stepper's M is the rows on screen, not the match count, once a drill holds more rows than one page. A fix needs a plugin-list edit, which is outside this PR. By the same code read, not measured: a drill opened from inside a `page:tabs` panel would report its count to that tab's badge. - **Dataset-report chart mark:** app-crm ships no dataset report, so it was not walked there. It is now walked on HotCRM's 各阶段商机 report (above), and it is also covered by the plugin-report test. - Desktop and phone viewports were measured. Tablet was not. - **Deviations:** - `ui/packages/react/src/context/DrillNavigationContext.tsx` (the optional `openRecord` member) is outside the declared file surface. - The claim was amended to `Clause-②: yes (widening)` on the built `.d.ts` closure reading (the four new optional members above); the declaration line above and the changeset follow it. - `pnpm dev:crm` refused on `check-dev-prereqs` (missing dists), so the walk ran `objectstack dev` directly in `examples/app-crm`. - The inline HotCRM shots are served from a separate code-free branch, `claude/issue-36256-shots`. It holds one orphan commit with 8 PNGs and went up in the same `git push` as this branch. GitHub has no other host for an agent-written body's images. ## Verification Read first: 1. `ui/packages/plugin-dashboard/src/drillConditions.ts`: the filter-to-chip split. If a condition is dropped or mis-worded, the list shows the wrong records. 2. `ui/packages/plugin-dashboard/src/DrillRecordList.tsx`: the read-only schema and the `openRecord` set. 3. `ui/packages/plugin-report/src/DatasetReportRenderer.tsx`: `emitBucketDrill`, now shared by the summary line and the chart mark. Two-minute check: run `pnpm dev:crm`, open Analytics → Pipeline and click the 「Closed Won」 bar. Expect a centred dialog with nothing dimmed behind it, the Stage: Closed Won chip, and 3 records. Click 「Initech — Pilot」 and expect the record page to read 「1 of 3 · Pipeline Dashboard」. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jREBdDtYvSLn38xUCg <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jREBdDtYvSLn38xUCg --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent d7411fa commit 6e643cc

24 files changed

Lines changed: 1864 additions & 80 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/plugin-dashboard': patch
3+
'@object-ui/plugin-report': patch
4+
'@object-ui/react': patch
5+
'@object-ui/app-shell': patch
6+
'@object-ui/components': patch
7+
---
8+
9+
feat(plugin-dashboard): a dashboard or report drill opens a centred dialog over the standard list, and a report's chart marks drill
10+
11+
Clause-②: yes (widening) — additive members only, among them the new `PageRegionPostureReset` export of `@object-ui/components`; nothing is removed or renamed
12+
Metadata-protocol: none
13+
14+
Clicking a number on a dashboard (a chart mark, a metric tile, a table cell) or on a dataset report used to open a full-height side drawer whose table listed every field of the object, with no sort, no filter and no word on which conditions selected the records; a row stacked a second record panel on top. The drill now opens a dialog about 70% wide and 65% tall that dims and blurs nothing behind it, and its body is the standard list the object list page draws (`list-view`): the same row height, column-header sort, filter chips, added columns, record count and column calculations. The drill's conditions (the clicked bucket, the widget's filter, the measure's scope) are the list's own chips and can be changed or removed; a condition no chip can say (a relationship path, an `$or`) still filters the list. The default columns are the record's name, the grouped fields and the measured fields. Nothing done in the dialog is saved, and it writes nothing. A record's name opens the record's full page, whose 「N of M」 stepper walks the drill's rows and whose way back is the dashboard or report; no second panel is stacked. 「Open in list」 is unchanged. On a phone the drill keeps the side drawer, with the same list.
15+
16+
A dataset report's chart marks now drill too: a bar opens the same records as the summary line it stands for.
17+
18+
Additive members: `DrillNavigationValue.openRecord` and the `DrillRecordOrigin` type (`@object-ui/react`), `DrillDownDrawerProps.defaultColumns` (`@object-ui/plugin-dashboard`), `DatasetDrillArgs.fields` (`@object-ui/plugin-report`), `PageRegionPostureReset` (`@object-ui/components`). A renderer without `@object-ui/plugin-list` registered lists the drilled records in the dashboard's data table. A host that gives no `openRecord` (a page block's metric or pivot) opens the drilled record in a dialog, from either body.
19+
20+
Inside a page the drill draws the same standard list: the page region's posture (the compact or capped list a page block draws) is cleared for the drill's dialog by the new `PageRegionPostureReset` (`@object-ui/components`), so a page block's metric or pivot drill shows its chips, its record count and its pager, and no 「View all」 link to a list without the drill's condition. A drill whose filter names no condition any read can carry (a string, a number) lists nothing and says so, instead of listing every record.

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ type DashboardRefreshState = Parameters<
110110
// ---------------------------------------------------------------------------
111111

112112
export function DashboardView({ dataSource }: { dataSource?: any }) {
113-
// Drill "escape hatch": lets the drill drawers open an object's full list page.
114-
const drillNavigation = useRecordListDrillNavigation();
115113
const { dashboardName } = useParams<{ dashboardName: string }>();
116114
// Setup's own System Overview (`platform-objects`' `system_overview`).
117115
const isSystemOverview = useInSetupApp() && dashboardName === 'system_overview';
@@ -235,6 +233,12 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
235233
const missedName = !dashboard && dashboardsSettled && !previewDrafts && dashboardName ? dashboardName : null;
236234
const access = useMetaItemRefusal('dashboard', missedName);
237235

236+
// Drill navigation: the drill list's 「Open in list」 and its record pages,
237+
// which name this dashboard as their way back (objectstack-ai/objectstack#36256).
238+
const drillNavigation = useRecordListDrillNavigation(
239+
dashboard ? resolveKeyedI18nLabel(dashboard.label, t) || dashboard.name : undefined,
240+
);
241+
238242
// ---- Runtime capability gate --------------------------------------------
239243
// Hide widgets whose `requiresObject` is not registered (mirrors
240244
// NavigationItem.requiresObject for nav entries). Defaults to widget.object

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
105105
// Drill-through (ADR-0021 D2): clicking an aggregated row/cell opens the
106106
// underlying records in an in-place drawer (peek without leaving the report),
107107
// with an "Open in list →" escape hatch to the full object list page.
108-
const drillNavigation = useRecordListDrillNavigation();
109-
const [drill, setDrill] = useState<{ object: string; filter: Record<string, unknown>; title: string } | null>(null);
108+
const drillNavigation = useRecordListDrillNavigation(
109+
metadataText(reportData?.title, language) ?? metadataText(reportData?.label, language),
110+
);
111+
const [drill, setDrill] = useState<{ object: string; filter: Record<string, unknown>; title: string; fields?: string[] } | null>(null);
110112

111113
const getFieldsForObject = useCallback(
112114
(objName: string | undefined) => {
@@ -152,7 +154,7 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
152154
// dim (the drill lands on a superset rather than filtering wrongly)
153155
// - granularity-bucketed dates → need a range, not equality; skip too
154156
const handleDatasetDrill = useCallback(
155-
async ({ dataset, groupKey, object, objectFilter }: DatasetDrillArgs) => {
157+
async ({ dataset, groupKey, object, objectFilter, fields }: DatasetDrillArgs) => {
156158
try {
157159
// Drawer header: the clicked group's display values (e.g. "West / Q3"),
158160
// else the report's label in the viewer's language (objectui#13470).
@@ -165,7 +167,7 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
165167
// server's drillRawRows — correct for select/lookup dims (a stored
166168
// value, not a display label) with NO dataset-definition round-trip.
167169
if (object && objectFilter) {
168-
setDrill({ object, filter: objectFilter, title });
170+
setDrill({ object, filter: objectFilter, title, fields });
169171
return;
170172
}
171173

@@ -602,15 +604,17 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
602604
/>
603605
</div>
604606
</div>
605-
{/* Drill-through drawer: peek the records behind a clicked group, then
606-
click a row to open a record, or use "Open in list →" to escalate to
607-
the full object list page. */}
607+
{/* Drill-through dialog: the records behind a clicked group or bar in the
608+
standard list; a record's name opens its page, 「Open in list」 the
609+
object's list page (objectstack-ai/objectstack#36256). */}
608610
<DrillDownDrawer
609611
open={!!drill}
610612
onClose={() => setDrill(null)}
611613
title={drill?.title ?? ''}
612614
objectName={drill?.object ?? ''}
613615
filter={drill?.filter}
616+
defaultColumns={drill?.fields}
617+
target="dialog"
614618
dataSource={dataSource as any}
615619
/>
616620
</DrillNavigationProvider>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* objectstack-ai/objectstack#36256 items 3, 5 and 8 — the drill dialog draws
3+
* the REAL standard list (`@object-ui/plugin-list`'s `list-view`): the
4+
* drill's conditions are the list's own chips, removable; the default
5+
* columns are the record's name and the drilled fields; and nothing the
6+
* reader does in it writes anything — no record write through the data
7+
* source, no request that is not a read, no stored preference.
8+
*/
9+
import { describe, it, expect, vi, afterEach } from 'vitest';
10+
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
11+
import '@testing-library/jest-dom';
12+
import React from 'react';
13+
import { DrillNavigationProvider, SchemaRendererProvider } from '@object-ui/react';
14+
import { DrillDownDrawer } from '@object-ui/plugin-dashboard';
15+
import '@object-ui/plugin-list';
16+
17+
const DEFINITION = {
18+
name: 'deal_36256',
19+
label: 'Deal',
20+
nameField: 'name',
21+
fields: {
22+
name: { type: 'text', label: 'Name' },
23+
stage: {
24+
type: 'select',
25+
label: 'Stage',
26+
options: [
27+
{ value: 'proposal', label: 'Proposal' },
28+
{ value: 'negotiation', label: 'Negotiation' },
29+
],
30+
},
31+
amount: { type: 'number', label: 'Amount' },
32+
owner: { type: 'text', label: 'Owner' },
33+
},
34+
};
35+
36+
function mount() {
37+
const ds = {
38+
find: vi.fn().mockResolvedValue({ data: [{ id: 'd1', name: 'Acme', stage: 'negotiation', amount: 3 }], total: 1 }),
39+
findOne: vi.fn(),
40+
create: vi.fn(),
41+
update: vi.fn(),
42+
delete: vi.fn(),
43+
bulk: vi.fn(),
44+
getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)),
45+
};
46+
const fetchSpy = vi.fn(async () => ({ ok: true, json: async () => ({}) }));
47+
vi.stubGlobal('fetch', fetchSpy);
48+
const setItem = vi.spyOn(Storage.prototype, 'setItem');
49+
const openRecord = vi.fn();
50+
render(
51+
<SchemaRendererProvider dataSource={ds as any}>
52+
<DrillNavigationProvider value={{ openRecord }}>
53+
<DrillDownDrawer
54+
open
55+
target="dialog"
56+
onClose={vi.fn()}
57+
title="Negotiation"
58+
objectName="deal_36256"
59+
filter={{ stage: 'negotiation', amount: { $null: false } }}
60+
defaultColumns={['stage', 'amount']}
61+
dataSource={ds}
62+
/>
63+
</DrillNavigationProvider>
64+
</SchemaRendererProvider>,
65+
);
66+
return { ds, fetchSpy, setItem, openRecord };
67+
}
68+
69+
afterEach(() => {
70+
cleanup();
71+
vi.unstubAllGlobals();
72+
vi.restoreAllMocks();
73+
});
74+
75+
describe('the drill dialog draws the standard list (#36256)', () => {
76+
it('shows the drill conditions as removable chips, and removing one re-reads without writing', async () => {
77+
const { ds, fetchSpy, setItem } = mount();
78+
const dialog = await screen.findByTestId('drill-down-dialog');
79+
const chip = await within(dialog).findByTestId('filter-chip-stage');
80+
expect(chip).toHaveTextContent('Stage: Negotiation');
81+
await waitFor(() => expect(ds.find).toHaveBeenCalled());
82+
const firstQuery = JSON.stringify(ds.find.mock.calls.at(-1));
83+
expect(firstQuery).toContain('negotiation');
84+
85+
const reads = ds.find.mock.calls.length;
86+
await act(async () => fireEvent.click(within(dialog).getByTestId('filter-chip-remove-stage')));
87+
await waitFor(() => expect(ds.find.mock.calls.length).toBeGreaterThan(reads));
88+
expect(JSON.stringify(ds.find.mock.calls.at(-1))).not.toContain('negotiation');
89+
90+
for (const write of [ds.create, ds.update, ds.delete, ds.bulk]) expect(write).not.toHaveBeenCalled();
91+
for (const [, init] of fetchSpy.mock.calls as unknown as Array<[unknown, { method?: string } | undefined]>) {
92+
expect((init?.method ?? 'GET').toUpperCase()).toBe('GET');
93+
}
94+
expect(setItem).not.toHaveBeenCalled();
95+
});
96+
97+
it("leads with the record's name, then the drilled fields", async () => {
98+
mount();
99+
const dialog = await screen.findByTestId('drill-down-dialog');
100+
await within(dialog).findByText('Acme');
101+
const headers = within(dialog).getAllByRole('columnheader').map((h) => h.textContent?.trim()).filter(Boolean);
102+
expect(headers.slice(0, 3)).toEqual(['Name', 'Stage', 'Amount']);
103+
});
104+
});
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* objectstack-ai/objectstack#36256 — a page block's drill lists the records
3+
* its number counts.
4+
*
5+
* HotCRM's 销售主页 KPI tile is an `object-metric` block whose `filter` is the
6+
* spec's rule-array form, `[{ field: 'stage', operator: 'equals', value:
7+
* 'closed_won' }]`, handed to the drill as written. The drill draws the REAL
8+
* standard list (`@object-ui/plugin-list`) over an in-memory matcher
9+
* (`ValueDataSource`), so the read it sends is judged as a server would judge
10+
* it. The tile counts the won deals. The drill must read with that condition
11+
* and list exactly those deals, never every record of the object.
12+
*/
13+
import { describe, it, expect, vi, afterEach } from 'vitest';
14+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
15+
import '@testing-library/jest-dom';
16+
import React from 'react';
17+
import { SchemaRenderer, SchemaRendererProvider } from '@object-ui/react';
18+
import { ValueDataSource } from '@object-ui/core';
19+
import '@object-ui/plugin-dashboard';
20+
import '@object-ui/plugin-list';
21+
22+
const DEFINITION = {
23+
name: 'opp_36256',
24+
label: 'Opportunity',
25+
nameField: 'name',
26+
fields: {
27+
name: { type: 'text', label: 'Name' },
28+
stage: { type: 'text', label: 'Stage' },
29+
amount: { type: 'number', label: 'Amount' },
30+
},
31+
};
32+
33+
const ROWS = [
34+
{ id: 'o1', name: 'Initech Phase 1', stage: 'closed_won', amount: 90000 },
35+
{ id: 'o2', name: 'Wayne Q1 Expansion', stage: 'closed_won', amount: 380000 },
36+
{ id: 'o3', name: 'Apex Logistics Data Hub', stage: 'needs_analysis', amount: 93000 },
37+
];
38+
const WON = ROWS.filter((r) => r.stage === 'closed_won');
39+
40+
function mount(filter: unknown = [{ field: 'stage', operator: 'equals', value: 'closed_won' }]) {
41+
const matcher = new ValueDataSource({ items: ROWS });
42+
const ds = {
43+
find: vi.fn((object: string, params?: Record<string, unknown>) => matcher.find(object, params as never)),
44+
// The tile's own number: the won deals' sum.
45+
aggregate: vi.fn(async (_object: string, _params: Record<string, unknown>) => [{ amount_sum: WON.reduce((a, r) => a + r.amount, 0) }]),
46+
getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)),
47+
};
48+
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, json: async () => ({}) })));
49+
render(
50+
<SchemaRendererProvider dataSource={ds as never}>
51+
<SchemaRenderer
52+
schema={{
53+
type: 'object-metric',
54+
objectName: 'opp_36256',
55+
label: 'Revenue won',
56+
aggregate: { field: 'amount', function: 'sum' },
57+
filter,
58+
drillDown: { enabled: true, target: 'dialog', columns: ['name', 'stage', 'amount'] },
59+
} as never}
60+
/>
61+
</SchemaRendererProvider>,
62+
);
63+
return ds;
64+
}
65+
66+
afterEach(() => {
67+
cleanup();
68+
vi.unstubAllGlobals();
69+
vi.restoreAllMocks();
70+
});
71+
72+
describe("a page block's rule-array filter reaches its drill's read (#36256)", () => {
73+
it('lists exactly the records the tile counts, and the read carries the condition', async () => {
74+
const ds = mount();
75+
fireEvent.click(await screen.findByRole('button', { name: /revenue won|470,000/i }));
76+
const dialog = await screen.findByTestId('drill-down-dialog');
77+
for (const won of WON) expect(await within(dialog).findByText(won.name)).toBeInTheDocument();
78+
await waitFor(() => expect(within(dialog).queryByText('Apex Logistics Data Hub')).toBeNull());
79+
// The read the list sent, and the condition it carries.
80+
const reads = ds.find.mock.calls.filter(([object]) => object === 'opp_36256');
81+
expect(reads.length).toBeGreaterThan(0);
82+
expect(JSON.stringify(reads.at(-1)?.[1]?.$filter)).toContain('closed_won');
83+
});
84+
85+
it.each([
86+
['an array that is neither rules nor AST', [{ stage: 'closed_won' }]],
87+
['a rule with a blank field', [{ field: '', operator: 'equals', value: 'closed_won' }]],
88+
['a valid rule beside a malformed one', [{ field: 'stage', operator: 'equals', value: 'closed_won' }, { stage: 'x' }]],
89+
])('hands a filter the conversion answers nothing for to the list as its base filter, never an unfiltered read: %s', async (_, filter) => {
90+
const ds = mount(filter);
91+
fireEvent.click(await screen.findByRole('button', { name: /revenue won|470,000/i }));
92+
const dialog = await screen.findByTestId('drill-down-dialog');
93+
await waitFor(() => expect(ds.find.mock.calls.some(([object]) => object === 'opp_36256')).toBe(true));
94+
// Every read carries the filter (a server refuses it as malformed; it is
95+
// never read as no filter).
96+
for (const [object, params] of ds.find.mock.calls) {
97+
if (object === 'opp_36256') expect(params?.$filter).toBeDefined();
98+
}
99+
await waitFor(() => expect(within(dialog).queryByText('Apex Logistics Data Hub')).toBeNull());
100+
});
101+
102+
it.each([
103+
['a string', 'stage = closed_won'],
104+
['a number', 7],
105+
])('lists nothing for a filter no read can carry, and sends no read: %s', async (_, filter) => {
106+
const ds = mount(filter);
107+
fireEvent.click(await screen.findByRole('button', { name: /revenue won|470,000/i }));
108+
const dialog = await screen.findByTestId('drill-down-dialog');
109+
expect(within(dialog).getByTestId('drill-down-notice')).toHaveAttribute('data-notice', 'unavailable');
110+
await new Promise((r) => setTimeout(r, 50));
111+
expect(ds.find.mock.calls.filter(([object]) => object === 'opp_36256')).toEqual([]);
112+
});
113+
});

0 commit comments

Comments
 (0)