Skip to content

Commit a115ac5

Browse files
os-warrenclaude
andauthored
fix(plugin-form): the print row-cap test loads the line grid's body before its first render (#36640) (#36656)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8PC4syDJ8bPonzN7bL9mdeU)_ Fixes #36640 Also the cause of #36649 (main's 4-hourly full run red at `e9fa6b5d06`); that card closes when the next full run is green. ## What changes `ui/packages/plugin-form/src/__tests__/lineItemsPrintRowCap-11958.test.tsx` loads the line grid's body at module scope (`await preloadGridField()`), before any test renders. No assertion is changed, removed, relaxed or retried; no timeout is touched; the file is not moved into `heavyDomTests`. Test-only: no product code moves, so no changeset (needs `skip-changeset`). ## Why Root cause, read from both failure logs and confirmed with a probe: - Both reds fail at **line 100** (`expected +0 to be 2`), the single row count read right after `waitFor` sees the row-ceiling note: the merge-queue run on PR #36461 (reading 7092248222) and main's 4-hourly run 45135779472, job 137562669352 (`Test UI (3/16)`, `lineItemsPrintRowCap-11958.test.tsx:100:58`). Lines 112 and 118 never failed. - The note and the rows commit together (`setRowCap` and `setRows` are set in the same load callback in `LineItemsPanel.tsx`), but the grid's body is split out and loads on first use (objectstack#36102, `ui/packages/fields/src/widgets/GridField.ts`). `LineItemsPanel` starts that load at mount with `preloadGridField()` but does not wait for it, so a grid mounted before the load settles draws its loading face (`data-testid="grid-field-loading"`, no table) while the note is already in the DOM. - Probe at line 100 on unmodified `main` (`3cf6a44b`): `loadingFace=true tbody=false`. The count of 0 is the loading face, not a missing or extra row. This is the case `ui/AGENTS.md` § 测试纪律 names: an assertion that lands behind a dynamic `import()` loads that module at module scope, where the cost is outside every test window. Three sibling tests in this package already do exactly this (`ModalForm.untypedRepeater.test.tsx`, `masterDetailSectionMembers-8071.test.tsx`, `deriveMasterDetail.declaredSpelling.test.tsx`). Product side, considered and not changed: in the browser the note can sit under the grid's loading face only until the chunk that `preloadGridField()` already requested arrives, and printing is a user-triggered `window.print()`, so no printed page carries the note without its rows. The row cap and the note are unchanged. ## Verification All counts on `objectstack-ai/objectstack`, the 6-test file run alone with `npx vitest run --maxWorkers=2 packages/plugin-form/src/__tests__/lineItemsPrintRowCap-11958.test.tsx` from `ui/`, 20 runs each, under load (one busy loop per core on a 4-core container, so the file runs against 4 CPU stressors): | Tree | Red runs | Failing test | |---|---|---| | before: `main` `3cf6a44b` | **20 / 20** | `draws the cap’s rows…`, line 100, `expected +0 to be 2` | | after: this branch `0c621d36` | **0 / 20** | none; every run `Tests 6 passed (6)` | Run cold, as each fresh vitest run is, the load always loses the race; in CI's full run it loses only when the chunk's transform is slow, which is why the queue and the 4-hourly run saw it intermittently. Also on `0c621d36`: the whole `plugin-form` package under `--maxWorkers=2`, 245 files / 2766 tests passed, 1 skipped (pre-existing); `eslint` on the changed file clean. Clause-②: no Metadata-protocol: none ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. (no names added) - [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the changed file) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (test-only, publishes nothing) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent d076975 commit a115ac5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎ui/packages/plugin-form/src/__tests__/lineItemsPrintRowCap-11958.test.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ import { describe, it, expect, vi, afterEach } from 'vitest';
2626
import { render, cleanup, waitFor } from '@testing-library/react';
2727
import React from 'react';
2828
import { SchemaRenderer, SchemaRendererProvider, PrintPageProvider } from '@object-ui/react';
29+
import { preloadGridField } from '@object-ui/fields';
2930
// Registers `record:line_items`.
3031
import '../index';
3132

33+
// The line grid renders behind `@object-ui/fields`' lazy face (objectstack#36102);
34+
// load its body before the first render, as the record forms' mount-time
35+
// preload does in the console. The panel's own mount-time preload is not
36+
// awaited, so without this the cut-off note can commit while the grid still
37+
// draws its loading face, and a row count read beside the note sees no table.
38+
await preloadGridField();
39+
3240
const COLUMNS = [{ name: 'qty', label: 'Qty', type: 'number' as const }];
3341
const LIMIT = 2;
3442

0 commit comments

Comments
 (0)