Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 3fbdd4a

Browse files
os-justinclaude
andauthored
test(plugin-list): date the two query-absence controls to a settle window, not to mount (objectui#8705) (#8742)
* test(plugin-list): date the two query-absence controls to a settle window, not to mount (objectui#8705) `ListView.objectProviderBinding-7477.test.tsx` asserts at two sites that no query is started: the `object` provider that names no object must invent no binding, and the `value` provider must never gain an `objectName`. Both `expect(dataSource.find).not.toHaveBeenCalled()` reads sat straight after a `waitFor` that is satisfied on the FIRST commit, so the absence was dated to mount. An implementation strictly worse than the bug — one that fires `dataSource.find` 50ms after every mount — passed both of them. No anchor is available on either path: the `value` provider leaves `loading` false from the first commit and never settles, and the object-provider-without- object path only flips `loading` from the same branch a query would start from, which cannot postdate a deferred one. The absence is watched over a bounded 250ms window instead — larger than the macrotask RTL's `asyncWrapper` already drains for free, so a `setTimeout(…, 0)` regression can no longer hide inside the pre-existing window. The assertions themselves are unchanged; what they claim is objectui#7477's contract. The other three absence reads in this file were swept and measured to be a different shape — `dataSource.find` has already been called when each of them runs, because `ListView` withholds the view spy behind its loading skeleton until the query resolves — so they are left untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S * chore(changeset): declare the settle-window repair as releasing nothing (objectui#8705) `check-changeset-presence.mjs` scores the edited test file as published source of `@object-ui/plugin-list`; the change is test-only, so it declares an EMPTY frontmatter — the gate's explicit exemption, not a workaround. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S * test(plugin-list): record the measured mount-dating, not the inferred one (objectui#8705) The file's own account of why the two pins were vacuous now cites the measurement rather than the mechanism: in both tests the kanban spy has already recorded two props entries by the time `render` returns, so the `waitFor` never yields. The `loading` transition on the object-provider-without-object path is labelled as what it is — read from the `useState` initializer — and its role is narrowed to what it can actually date: a synchronous query, never a deferred one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 5e96b45 commit 3fbdd4a

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
---
3+
4+
Date the two query-absence controls in
5+
`ListView.objectProviderBinding-7477.test.tsx` to a bounded settle window
6+
rather than to mount (objectui#8705). Both `not.toHaveBeenCalled()` pins sat
7+
straight after a `waitFor` that is satisfied on the first commit, so an
8+
implementation that starts a query 50ms after mount passed them; under the
9+
repair that same forced implementation turns them red. Test only; no published
10+
behaviour changes and no package is released by this change.

‎packages/plugin-list/src/__tests__/ListView.objectProviderBinding-7477.test.tsx‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,44 @@
4848
* handed `objectName: undefined` and nothing is fetched; without the
4949
* `specType` leg the page renders `object-grid` instead of `object-kanban`.
5050
* The `provider: 'value'` case is the control that stays green either way.
51+
*
52+
* ## Dating the two query-absence controls (objectui#8705)
53+
*
54+
* `invents NO binding …` and `leaves the value provider alone …` each assert
55+
* that NO query is started. Read straight after their `waitFor`, that absence
56+
* was dated to MOUNT rather than to a settled load. Measured, not assumed: in
57+
* BOTH of those tests the kanban spy has already recorded two props entries by
58+
* the time `render` returns, so `waitFor` is satisfied without ever yielding
59+
* and `not.toHaveBeenCalled()` was evaluated before a deferred query could
60+
* have run. Both pins stayed
61+
* GREEN against an implementation strictly worse than the bug — one line in
62+
* `ListView.tsx` that fires `dataSource.find` 50ms after every mount — so they
63+
* could not tell "starts no query" from "starts a query a tick later", which
64+
* is exactly the regression shape that would reach them.
65+
*
66+
* There is no anchor to prefer here, and that was checked before reaching for
67+
* a timer. An anchor needs a positive signal the implementation must emit
68+
* AFTER any query would have started. On the `value` path nothing settles at
69+
* all: `loading` is false from the first commit and never flips. On the
70+
* `object`-provider-without-object path the one transition that exists —
71+
* `loading` going false, per the `useState` initializer in `ListView.tsx` — is
72+
* set from the very branch a query would start from, and the measurement above
73+
* shows it has already happened before `render` returns. It postdates a
74+
* SYNCHRONOUS query and never a deferred one, which is the shape at issue. The
75+
* absence is therefore watched over a bounded window; see `ABSENCE_SETTLE_MS`.
76+
*
77+
* The other three absence reads in this file are NOT this shape, and that is
78+
* measured, not assumed: at `expect(gridProps).toHaveLength(0)` and at both
79+
* `expect(kanbanProps).toHaveLength(0)` sites, `dataSource.find` has ALREADY
80+
* been called when the line runs. Those three cases bind an object, and
81+
* `ListView` withholds the view spy behind its loading skeleton
82+
* (`loading && data.length === 0`) until the query resolves — so they are
83+
* already dated to a resolved query and are left exactly as they were.
5184
*/
5285

5386
import React from 'react';
5487
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
55-
import { render, waitFor, cleanup } from '@testing-library/react';
88+
import { render, waitFor, cleanup, act } from '@testing-library/react';
5689
import { ComponentRegistry } from '@object-ui/core';
5790
import { SchemaRenderer, SchemaRendererProvider, AdapterCtx } from '@object-ui/react';
5891
// Registers the page renderers (`type:'page'` / `'home'`), which dispatch
@@ -140,6 +173,29 @@ function renderListView(schema: Record<string, any>) {
140173
return dataSource;
141174
}
142175

176+
/**
177+
* How long a query-absence is watched before it is believed.
178+
*
179+
* REAL time, on purpose, and deliberately larger than any deferral the test
180+
* environment drains for free: RTL's `asyncWrapper` already flushes one
181+
* macrotask before `waitFor` returns, so a `setTimeout(…, 0)` regression sits
182+
* INSIDE the pre-existing window and a 0ms settle would prove nothing at all.
183+
* objectui#8705's forced leg defers its query by 50ms; this window is 5x that
184+
* and still an order of magnitude inside vitest's 5s default test timeout.
185+
*/
186+
const ABSENCE_SETTLE_MS = 250;
187+
188+
/**
189+
* Advance past `ABSENCE_SETTLE_MS` of real time so a deferred query has run
190+
* before an absence is read. Wrapped in `act` so that a regression which does
191+
* land state during the window is flushed into React rather than warned about.
192+
*/
193+
async function settleAbsenceWindow(): Promise<void> {
194+
await act(async () => {
195+
await new Promise((resolve) => setTimeout(resolve, ABSENCE_SETTLE_MS));
196+
});
197+
}
198+
143199
beforeEach(() => {
144200
kanbanProps = [];
145201
gridProps = [];
@@ -201,6 +257,11 @@ function Page() {
201257
const dataSource = renderListView({ data: { provider: 'object' }, specType: 'kanban' });
202258

203259
await waitFor(() => expect(kanbanProps.length).toBeGreaterThan(0));
260+
// Both reads below are ABSENCES, and the props above arrive on the first
261+
// commit — so date them to the end of a settle window, not to mount
262+
// (objectui#8705). A late `objectName` would push a fresh props entry and
263+
// a deferred query would have called `find` by the time this returns.
264+
await settleAbsenceWindow();
204265
expect(kanbanProps[kanbanProps.length - 1].schema.objectName).toBeUndefined();
205266
expect(dataSource.find).not.toHaveBeenCalled();
206267
});
@@ -214,6 +275,10 @@ function Page() {
214275
});
215276

216277
await waitFor(() => expect(kanbanProps.length).toBeGreaterThan(0));
278+
// Same dating as the control above, and this is the path with NO settle of
279+
// its own: an inline-items provider leaves `loading` false from the first
280+
// commit, so without this window the absence is dated to mount.
281+
await settleAbsenceWindow();
217282
expect(kanbanProps[kanbanProps.length - 1].schema.objectName).toBeUndefined();
218283
expect(dataSource.find).not.toHaveBeenCalled();
219284
});

0 commit comments

Comments
 (0)