Skip to content

Commit ac8fede

Browse files
feat(app-shell): a row-table page block lists the rows a page api binding answers (#31883)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBueky5afd2NHME9E1M7DVw)_ Fixes #31856 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: none — skills/ teaches no product block (git grep tile-grid|usage-bar skills/ = 0) ## 维护者速读 - **改了什么**:控制台新增一个页面块 `row-table`,把页面 `api` 绑定读到的一组数据画成表格:列在元数据里声明(字段路径、标题、格式:文本 / 日期时间 / 枚举标签),每一行都画,没有数据时显示空状态文字。 - **为什么改**:云端的 AI 员工页(cloud#4073)和 AI 调用追踪页(cloud#4058)要列出接口返回的多行数据,现在只能用固定条数的文字行凑合;这个块让它们按真实行数显示。 - **风险与回滚**:纯新增,没有页面在用,现有块和页面不变;不改 `@objectstack/spec`,SDUI 清单不动。回滚即还原本 PR。 - **先看**:`ui/packages/app-shell/src/console/blocks/productBlocks.tsx`(`readRowTable` 的拒收判定与 `rowTableCell`)、`ui/packages/types/src/zod/product-blocks.zod.ts`(`RowTableColumnSchema` 的严格校验)、`ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts`(命名空间计数 306→307)。 - **两分钟验证**:`pnpm --dir ui exec vitest run packages/app-shell/src/console/blocks/__tests__/rowTable-31856.test.tsx packages/types/src/__tests__/product-block-arms-12197.test.ts`,预期两个文件全绿。 - **需要你做的**:无,席位落地。 ## What changes - **`@object-ui/app-shell`: the `row-table` block**, the sixth product-page block beside `hero`, `stat`, `usage-bar`, `checklist` and `tile-grid`, registered under the `app-shell` namespace with the bare `row-table` as its authorable key and the same `API_BINDING_INPUT`. - `rows`: a list, or one whole `${…}` hole naming a list in the bound `data`, as `tile-grid`'s `items`. Every row is drawn, in order, with no cap. - `columns`: `{ path, label, format?, enum? }`, drawn in the order written. The keys are `resultDialog.fields`' vocabulary (`path` / `label` / `format`, `text` shared); `datetime` and `enum` are this block's own formats. `path` is read per row with `selectElementApiPath` (`@object-ui/react`), the binding's own path reader. - `text` draws as written (an object as compact JSON); `datetime` goes through `formatDateTime(value, { locale: useDisplayLocale(), style: 'compact' })` from `@object-ui/core`, the `datetime` field cell's face, in the display zone the host declared, else the viewer's; `enum` draws the label `enum: { value: label }` names, and a value the map does not name as written. - A field the row lacks, `null` or `''` draws `—`. An empty list draws `emptyLabel`, else the existing `table.noRows` key. No new i18n key. - A `rows` hole that resolves to anything but a list, or a column the block cannot draw (no `path`, an unknown `format`, `enum` with no map), draws an error face with the binding's own title (`element.component.apiUnreadable`) and a sentence naming the input. Never the empty state. - **`@object-ui/types`: its arm.** `RowTableBlockSchema` and `RowTableColumnSchema`, with the TS twins `RowTableBlockSchema`, `RowTableBlockProps` and `RowTableColumn`, joining `ProductBlockComponentSchema`, so `objectui validate` claims the type. The arm is strict: an unknown `format`, an `enum` column with no map, a map on a column that is not `enum`, a `path` that is not a dotted path, an undeclared key (the card's prose word `header` included) and an empty `columns` are refused. `dataSource` is the spec's `ElementApiDataSourceSchema`, by reference. The mirror-parity pin registers both pairs (199 → 201) as spec-derived. - **`@object-ui/cli`**: `known-schema-types.ts` regenerated (`row-table`, `app-shell:row-table`). The 10859 ratchet's namespaced count moves 306 → 307 for `app-shell:row-table`, a named stopgap raise of that one key, written beside the objectui#13301 raise it follows: the namespaced twin is refused at `type` by design so the bare key stays the one authorable spelling. Both `productBlocks-namespace-13301` lists (app-shell and cli) gain `row-table`. - **Docs**: the app-shell README block table and a `row-table` example, `content/docs/frontend/data-source.mdx` and `content/docs/ui/pages.mdx` (the block lists that take the `api` binding). - **No `@objectstack/spec` change.** The type parses through `PageComponentSchema.type`'s open string arm, and `component-type-unknown` claims only colon namespaces. The SDUI manifest does not move: `@object-ui/app-shell` is not one of the manifest generator's registry modules (`node scripts/check-sdui-manifest.mjs`: exit 0, 106 components). ## Tests - `rowTable-31856.test.tsx` (new, eight cases, through the real `SchemaRenderer` and the host `apiFetch`): the registration's inputs; every bound row in authored column order; enum labels and an unnamed value drawn raw; datetime in a pinned display zone (`Asia/Tokyo`) equal to `formatDateTime`'s face; `—` for a missing and a `null` field; the authored empty label and the bundle's; a non-list hole draws the error face and not the empty state; an unknown format draws the error face. - `product-block-arms-12197.test.ts`: the `row-table` fixture joins the shared accept / content-channel / undeclared-prop loop, plus six `row-table` cases (literal rows, unknown format, enum without a map and a map without enum, a non-dotted path, `header`, empty columns and a partial hole). <details><summary>Runs (branch on 1ff1d45; head 5e6d804 merges main a57a007, which moves no `packages/spec` or `ui/packages` file, so the runs below stand)</summary> - `pnpm --dir ui exec vitest run packages/app-shell/src/console/blocks/`: `Test Files 4 passed (4)`, `Tests 39 passed (39)` (re-run after the last source commit). - `pnpm --dir ui exec vitest run packages/app-shell/src/console/`: `Test Files 267 passed (267)`, `Tests 2038 passed (2038)`. - `pnpm --dir ui exec vitest run packages/types/`: `Test Files 389 passed (389)`, `Tests 10489 passed (10489)`; `pnpm --filter @object-ui/types run type-check` (the mirror-parity type legs): exit 0. - `pnpm --dir ui exec vitest run packages/cli/`: `Test Files 31 passed (31)`, `Tests 420 passed (420)`. - `pnpm --filter @object-ui/app-shell run type-check` (`tsc --noEmit` and `tsc -p tsconfig.test.json`, test files included): exit 0. - `pnpm --dir ui exec vitest run scripts/`: `Test Files 170 passed | 2 skipped (172)`, `Tests 5027 passed | 2 skipped`. - ui censuses, each exit 0: `check:spec-symbols`, `check:component-surface-parity`, `check:element-data-source-declaration`, `check:registry-bare-names`, `check:doc-types`, `check:doc-snippets` (537 of 537 blocks), `check:doc-examples`, `check:i18n-keys`, `check:i18n-drift`, `check:new-line-citations`, `check:control-bytes`. - `dispatch-gates --commands`: 69 families derived, 69 run, each exit 0 (`--ran`: 0 NOT-MEASURED, 0 UNRUN; the list is identical after the merge of main). `check:skill-examples` first answered exit 3 (client SDK unbuilt) and was re-run green after building it; `check:query-options-erasure` was re-run green with a longer timeout. </details> <details><summary>Ablation (scripts/ablation-replace.mjs, restored to the HEAD blob)</summary> - `const rows = props.rows;` → `const rows = Array.isArray(props.rows) ? props.rows : [];` (the non-array guard made an empty list): exactly "refuses a hole that resolves to a non-list with the error panel, never the empty state" goes red, `1 failed | 7 passed`; restored, `git diff HEAD` empty. </details> ## Acceptance notes - **Consumers:** cloud#4073 (the AI workforce page, which replaces its capped `element:text` rows with this block) and cloud#4058 (the AI call trace page). Neither is in this repo; no page here places the block yet. - **`os validate` does not judge the block's `properties`**, as for every product block: there is no `ComponentPropsMap` row, so the strict arm is judged by `objectui validate` / `safeValidateSchema`. The seat ruled this a family question for all six blocks, not this card's. - **The error face is drawn by the block, not by `ElementDataSourceErrorPanel`**: that panel marks a consumer of the object-binding gate (`check:element-data-source-declaration` refused the first draft), which an `api`-bound product block is not. It uses the same classes, `role="alert"` and the binding's own title key. - **NOT MEASURED locally: `check:sdui-registration-pins`** (it weighs a built console bundle; CI's Build & E2E UI builds it). `check:type-check-debt` ran under the verify lock: exit 0. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f159aaa commit ac8fede

17 files changed

Lines changed: 570 additions & 26 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/types': minor
3+
'@object-ui/app-shell': patch
4+
'@object-ui/cli': patch
5+
---
6+
7+
feat(app-shell): a `row-table` page block lists the rows a page `api` binding answers, as a table
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: added
11+
12+
- **`@object-ui/app-shell`: the `row-table` block**, the sixth product-page block beside `hero`, `stat`, `usage-bar`, `checklist` and `tile-grid`, registered under the `app-shell` namespace with the bare `row-table` as its authorable key. `rows` is a list, or one whole `${…}` hole naming a list in the bound `data` (`rows: '${data.actors}'`); every row is drawn, with no cap. `columns` declares, in order, `{ path, label, format?, enum? }`: `path` is a dotted path into one row, `label` a string or an inline locale map, and `format` is `text` (the default, drawn as written), `datetime` (an instant in the viewer's display locale and time zone, through the `datetime` field cell's `formatDateTime`) or `enum` (the label `enum: { value: label }` names; a value the map does not name is drawn as written). A field the row lacks, `null` or empty draws `—`. An empty list draws `emptyLabel`, else the bundle's "No rows to display". A `rows` hole that resolves to anything but a list, or a column the block cannot draw, draws the binding's error panel, never the empty state.
13+
- **`@object-ui/types`: its arm**, `RowTableBlockSchema` with `RowTableColumnSchema` (and the TS twins `RowTableBlockSchema`, `RowTableBlockProps`, `RowTableColumn`), a member of `ProductBlockComponentSchema`, so `objectui validate` claims the type. The arm is strict: an unknown `format`, an `enum` column with no label map, a label map on a column that is not `enum`, a `path` that is not a dotted path, an undeclared key and an empty `columns` are refused. The `dataSource` is the spec's `ElementApiDataSourceSchema`, by reference.
14+
- **`@object-ui/cli`:** `known-schema-types.ts` regenerated with `row-table` and `app-shell:row-table`.
15+
16+
No `@objectstack/spec` change: the type parses through `PageComponentSchema.type`'s open string arm, and `component-type-unknown` claims only colon namespaces. The SDUI manifest does not move (`@object-ui/app-shell` is not one of its registry modules).

‎content/docs/frontend/data-source.mdx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ the same URL make one request, even when the entry's read settled first:
324324
Outside such a scope nothing is kept beyond the request in flight: a page that
325325
mounts again reads again.
326326

327-
The console's product-page blocks — `hero`, `stat`, `usage-bar`, `checklist` and
328-
`tile-grid` — accept this binding in their arms; see the `@object-ui/app-shell`
329-
README.
327+
The console's product-page blocks — `hero`, `stat`, `usage-bar`, `checklist`,
328+
`tile-grid` and `row-table` — accept this binding in their arms; see the
329+
`@object-ui/app-shell` README. `row-table` draws every row of a list in the
330+
answer as a table: `rows: '${data.actors}'` names the list, and each column
331+
declares a `path` into one row, a `label`, and a `format` of `text`, `datetime`
332+
or `enum`.

‎content/docs/ui/pages.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ The API binding's rules:
399399
- **Same-origin only.** `read.url` must open with a single `/`. An absolute URL of any scheme (`https:`, `mailto:`, `javascript:`, …), a protocol-relative `//host`, a backslash the browser reads as a slash, a space or control character, and a relative path such as `./home` are all refused when the page is parsed (`definePage()`, `os validate`, `os build`), with the reason.
400400
- **No credentials in metadata.** The console reads the endpoint with its own signed-in fetch, so the read block has no `headers`, and a credential key such as `headers`, `credentials` or `token` is refused.
401401
- **Reads only.** `read.method` is optional and accepts `GET` alone; there is no `write` block.
402-
- **Rendered by the console.** The console reads the binding on every page element and binds the selected value as `data`: in the element's expression holes (`${data.used}`), in its `visibleWhen`, and in every element nested inside it. The console's generic `hero`, `stat`, `usage-bar`, `checklist` and `tile-grid` blocks are built to take it as their `dataSource`. While the read is in flight the element shows a loading panel, and a refused binding or a failed read shows an error panel instead.
402+
- **Rendered by the console.** The console reads the binding on every page element and binds the selected value as `data`: in the element's expression holes (`${data.used}`), in its `visibleWhen`, and in every element nested inside it. The console's generic `hero`, `stat`, `usage-bar`, `checklist`, `tile-grid` and `row-table` blocks are built to take it as their `dataSource`; `row-table` lists the rows of an array in the answer as a table, with declared columns (`path`, `label`, and a `format` of `text`, `datetime` or `enum`). While the read is in flight the element shows a loading panel, and a refused binding or a failed read shows an error panel instead.
403403

404404
#### Saved views and the object binding
405405

‎ui/packages/app-shell/README.md‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ See the full table in [ADR-0059](../../docs/adr/0059-action-params-shared-field-
503503

504504
## Product-page blocks
505505

506-
Five generic blocks for the pages a product composes as metadata (a product's
506+
Six generic blocks for the pages a product composes as metadata (a product's
507507
welcome page, a CRM's sales home), registered by this package and named for
508508
what they draw. Each reads its props from the node's `properties`; copy is a
509509
string or an inline translation map (`{ en, "zh-CN" }`), resolved in the
@@ -516,6 +516,7 @@ viewer's language.
516516
| `usage-bar` | how much of a limit is used | `label`, `used`, `limit?` (absent or `0` = unlimited: no bar), `unit?` |
517517
| `checklist` | steps that tick as they are done | `items: [{ label, done, action? }]`, `collapsedWhenDone?` (draw nothing once every step is done) |
518518
| `tile-grid` | the console home's launcher tiles | `items: [{ label, href, icon?, caption? }]`, `addTile?: { label, href }` |
519+
| `row-table` | the rows a bound list holds, as a table | `rows` (a list, or a `${…}` hole naming one), `columns: [{ path, label, format?, enum? }]`, `emptyLabel?` |
519520

520521
Any of them can carry the spec's API binding, and then read values from the
521522
answer through `${…}` holes:
@@ -528,6 +529,32 @@ answer through `${…}` holes:
528529
}
529530
```
530531

532+
`row-table` draws every row, its columns in the order written. A column's
533+
`path` is a dotted path into one row (`owner.name`), its `label` the heading,
534+
and its `format` one of `text` (the default, drawn as written), `datetime` (an
535+
instant in the viewer's display locale and time zone, the `datetime` field
536+
cell's face) or `enum` (the label `enum: { value: label }` names; a value the
537+
map does not name is drawn as written). A field the row lacks, `null` or empty
538+
draws `—`; an empty list draws `emptyLabel` ("No rows to display" when
539+
omitted). A `rows` hole that resolves to anything but a list, or a column the
540+
block cannot draw, draws the binding's error panel instead of an empty table:
541+
542+
```json
543+
{
544+
"type": "row-table",
545+
"dataSource": { "provider": "api", "read": { "url": "/api/v1/ai/actors" }, "path": "data" },
546+
"properties": {
547+
"rows": "${data.actors}",
548+
"columns": [
549+
{ "path": "name", "label": { "en": "Name", "zh-CN": "名称" } },
550+
{ "path": "status", "label": "Status", "format": "enum", "enum": { "active": "Active", "paused": "Paused" } },
551+
{ "path": "lastRun.at", "label": "Last run", "format": "datetime" }
552+
],
553+
"emptyLabel": { "en": "No agents yet" }
554+
}
555+
}
556+
```
557+
531558
The read, its loading and error states, and the `data` root are
532559
`SchemaRenderer`'s (see "Binding a page element to an API endpoint" in the data
533560
source guide). `ConnectedShell` keeps one open's reads (`ElementApiOpenScope`,

‎ui/packages/app-shell/src/console/blocks/__tests__/productBlocks-namespace-13301.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const warnings = vi.hoisted(() => {
3939

4040
import '../productBlocks';
4141

42-
const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid'] as const;
42+
// `row-table` (#31856) joined the five, registered the same way.
43+
const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid', 'row-table'] as const;
4344

4445
const DEPRECATED = /Registering component "([^"]+)" without a namespace is deprecated/;
4546

@@ -49,7 +50,7 @@ afterAll(() => {
4950
});
5051

5152
describe('console home blocks register under `app-shell` (objectui#13301)', () => {
52-
it('logs no deprecation line for the five blocks when the module loads', () => {
53+
it('logs no deprecation line for the blocks when the module loads', () => {
5354
const named = warnings.seen
5455
.map((line) => DEPRECATED.exec(line)?.[1])
5556
.filter((type): type is string => Boolean(type));
@@ -94,6 +95,7 @@ describe('a page authoring the bare key still draws each block (objectui#13301)'
9495
['usage-bar', { type: 'usage-bar', properties: { label: 'Storage', used: 256, limit: 1024 } }, 'Storage'],
9596
['checklist', { type: 'checklist', properties: { items: [{ label: 'Create an environment', done: false }] } }, 'Create an environment'],
9697
['tile-grid', { type: 'tile-grid', properties: { items: [{ label: 'CRM', href: '/apps/crm' }] } }, 'CRM'],
98+
['row-table', { type: 'row-table', properties: { rows: [{ name: 'Ada' }], columns: [{ path: 'name', label: 'Name' }] } }, 'Ada'],
9799
];
98100

99101
it.each(pages)('`%s`', (_block, schema, text) => {
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* `row-table` (#31856): the rows a page `api` binding answers, as a table,
11+
* rendered through the real `SchemaRenderer` with the binding read through the
12+
* host fetch on `SchemaRendererContext.apiFetch`.
13+
*/
14+
15+
import { afterEach, describe, expect, it, vi } from 'vitest';
16+
import { cleanup, render, screen, waitFor, within } from '@testing-library/react';
17+
import React from 'react';
18+
import { MemoryRouter } from 'react-router-dom';
19+
import { ComponentRegistry, formatDateTime, setDisplayTimeZone } from '@object-ui/core';
20+
import { I18nProvider } from '@object-ui/i18n';
21+
import { SchemaRenderer, SchemaRendererContext } from '@object-ui/react';
22+
import type { DeclaredNode } from '@object-ui/types';
23+
import '../productBlocks';
24+
25+
const ACTORS = {
26+
success: true,
27+
data: {
28+
actors: [
29+
{ name: 'Ada', status: 'active', lastRun: { at: '2026-11-09T08:30:00Z' } },
30+
{ name: 'Grace', status: 'paused', lastRun: null },
31+
{ name: 'Linus', status: 'retired' },
32+
],
33+
none: [],
34+
summary: { count: 3 },
35+
},
36+
};
37+
38+
const BINDING = { provider: 'api', read: { url: '/api/v1/ai/actors' }, path: 'data' } as const;
39+
40+
const COLUMNS = [
41+
{ path: 'name', label: { en: 'Name', 'zh-CN': '名称' } },
42+
{ path: 'status', label: 'Status', format: 'enum', enum: { active: { en: 'Active' }, paused: 'Paused' } },
43+
{ path: 'lastRun.at', label: 'Last run', format: 'datetime' },
44+
];
45+
46+
function renderTable(properties: Record<string, unknown>, bound = true) {
47+
const apiFetch = vi.fn(async () => new Response(JSON.stringify(ACTORS), { status: 200 }));
48+
const schema = { type: 'row-table', ...(bound ? { dataSource: BINDING } : {}), properties } as unknown as DeclaredNode;
49+
render(
50+
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false }}>
51+
<MemoryRouter>
52+
<SchemaRendererContext.Provider value={{ dataSource: null, apiFetch }}>
53+
<SchemaRenderer schema={schema} />
54+
</SchemaRendererContext.Provider>
55+
</MemoryRouter>
56+
</I18nProvider>,
57+
);
58+
return apiFetch;
59+
}
60+
61+
/** The cell texts of one body row. */
62+
function cells(row: number): string[] {
63+
return within(screen.getByTestId(`row-table-row-${row}`))
64+
.getAllByRole('cell')
65+
.map((cell) => cell.textContent ?? '');
66+
}
67+
68+
afterEach(() => {
69+
cleanup();
70+
setDisplayTimeZone(undefined);
71+
});
72+
73+
describe('row-table (#31856)', () => {
74+
it('registers with declared inputs and the API binding input', () => {
75+
const config = ComponentRegistry.getConfig('row-table');
76+
const names = (config?.inputs ?? []).map((input) => input.name);
77+
expect(names).toEqual(['rows', 'columns', 'emptyLabel', 'dataSource']);
78+
for (const input of config?.inputs ?? []) expect(input.description, input.name).toBeTruthy();
79+
});
80+
81+
it('draws every row the binding answers, its columns in authored order', async () => {
82+
const apiFetch = renderTable({ rows: '${data.actors}', columns: COLUMNS });
83+
await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument());
84+
expect(apiFetch).toHaveBeenCalledTimes(1);
85+
expect(screen.getAllByRole('columnheader').map((head) => head.textContent)).toEqual(['Name', 'Status', 'Last run']);
86+
expect(cells(0)[0]).toBe('Ada');
87+
expect(cells(1)[0]).toBe('Grace');
88+
expect(cells(2)[0]).toBe('Linus');
89+
});
90+
91+
it('draws an enum value through its label map, and a value the map does not name as written', async () => {
92+
renderTable({ rows: '${data.actors}', columns: COLUMNS });
93+
await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument());
94+
expect(cells(0)[1]).toBe('Active');
95+
expect(cells(1)[1]).toBe('Paused');
96+
expect(cells(2)[1]).toBe('retired');
97+
});
98+
99+
it('draws a datetime as an instant in the display time zone', async () => {
100+
setDisplayTimeZone('Asia/Tokyo');
101+
renderTable({ rows: '${data.actors}', columns: COLUMNS });
102+
await waitFor(() => expect(screen.getByTestId('row-table-row-0')).toBeInTheDocument());
103+
const shown = cells(0)[2];
104+
// The one date-display path, in the declared zone: 08:30Z is 17:30 in Tokyo.
105+
expect(shown).toBe(formatDateTime('2026-11-09T08:30:00Z', { locale: 'en', style: 'compact' }));
106+
expect(shown).toMatch(/17:30|5:30/);
107+
expect(shown).not.toMatch(/08:30|8:30/);
108+
});
109+
110+
it('draws "—" for a field the row lacks or holds null', async () => {
111+
renderTable({ rows: '${data.actors}', columns: COLUMNS });
112+
await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument());
113+
expect(cells(1)[2]).toBe('—');
114+
expect(cells(2)[2]).toBe('—');
115+
});
116+
117+
it('draws the authored empty label for an empty list, else the bundle\'s', async () => {
118+
renderTable({ rows: '${data.none}', columns: COLUMNS, emptyLabel: { en: 'No agents yet' } });
119+
expect((await screen.findByTestId('row-table-empty')).textContent).toBe('No agents yet');
120+
cleanup();
121+
renderTable({ rows: [], columns: COLUMNS }, false);
122+
expect(screen.getByTestId('row-table-empty').textContent).toBe('No rows to display');
123+
});
124+
125+
it('refuses a hole that resolves to a non-list with the error panel, never the empty state', async () => {
126+
renderTable({ rows: '${data.summary}', columns: COLUMNS, emptyLabel: 'No agents yet' });
127+
const panel = await screen.findByTestId('row-table-datasource-error');
128+
expect(panel).toHaveAttribute('role', 'alert');
129+
expect(panel.textContent).toContain('rows resolved to an object');
130+
expect(screen.queryByTestId('row-table-empty')).toBeNull();
131+
});
132+
133+
it('refuses a column format it does not draw with the error panel', () => {
134+
renderTable({ rows: [{ name: 'Ada' }], columns: [{ path: 'name', label: 'Name', format: 'currency' }] }, false);
135+
const panel = screen.getByTestId('row-table-datasource-error');
136+
expect(panel.textContent).toContain('columns[0].format "currency"');
137+
expect(screen.queryByTestId('row-table-block')).toBeNull();
138+
});
139+
});

0 commit comments

Comments
 (0)