Repository navigation
Expand file tree
/
Copy pathObjectGantt.harness.test.tsx
More file actions
2356 lines (2113 loc) · 101 KB
/
Copy pathObjectGantt.harness.test.tsx
File metadata and controls
2356 lines (2113 loc) · 101 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* ObjectUI
* Copyright (c) 2024-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* ObjectGantt's shared harness: the pins that render the real `ObjectGantt`
* over a stand-in bar canvas and a stubbed record drawer, folded into one file
* (objectstack#29469, the rollout of objectstack#25911's pilot).
*
* Each block below was its own file, named in its `describe`, with the same
* three mocks: `sonner`'s toast, `./GanttView`, and `@object-ui/plugin-detail`
* with `RecordDetailDrawer` and `deriveRecordPageHref` stubbed out. Only the
* `GanttView` stand-in differed, in which task attributes it writes to the
* DOM. Under the `dom` project's `isolate: true`, each of those files paid the
* whole module graph's import again, and the import was nearly all of a file's
* time. Here the graph loads once, and each block installs its own stand-in in
* a `beforeEach`, through the `standIns` slot the `./GanttView` mock reads.
* Every block keeps its fixtures, hooks and assertions as they were, and its
* issue number in its `describe`.
*
* Isolation between blocks:
* - React Testing Library's `cleanup()` runs after every test (the `dom`
* setup registers it).
* - Every fixture, adapter and call log is declared inside its block, so no
* block reads another's.
* - `sonner`'s mock is the union of the blocks' mocks: `error` and `success`.
* - `./index` is imported once, for the blocks that render through
* `SchemaRenderer`: it registers `object-gantt` in the `ComponentRegistry`
* for the whole file. No block asserts that key absent.
*
* A new `ObjectGantt` pin that renders over these three mocks joins this file
* as its own top-level `describe`, and installs its `GanttView` stand-in the
* same way.
*/
import React from 'react';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, waitFor, act, cleanup } from '@testing-library/react';
import {
GANTT_ROW_CEILING,
NON_GRID_ROW_CEILING,
nonGridRowCeilingQuery,
ValueDataSource,
} from '@object-ui/core';
import { SchemaRendererProvider, SchemaRenderer, notifyDataChanged } from '@object-ui/react';
import { I18nProvider } from '@object-ui/i18n';
import type { DataSource, DeclaredNode, ObjectGanttBlockNode } from '@object-ui/types';
import { safeValidateSchema } from '@object-ui/types/zod';
import { ObjectGantt } from './ObjectGantt';
import { GANTT_FETCH_STEP } from './ganttRowWalk';
// Module scope, not a hook: this import IS the registration (AGENTS.md
// test-discipline section).
import './index';
/**
* The `GanttView` stand-in the running block installed; the `./GanttView` mock renders it.
* Typed `(props: never)` so a block's stand-in keeps its own props annotation.
*/
const standIns = vi.hoisted(() => ({
ganttView: null as null | ((props: never) => unknown),
}));
// `success` is the `ObjectGantt.invalidationRefetch-10035` block's; no block asserts on a toast.
vi.mock('sonner', () => ({ toast: { error: vi.fn(), success: vi.fn() } }));
vi.mock('./GanttView', () => ({
GanttView: (props: Record<string, unknown>) => {
if (!standIns.ganttView) {
throw new Error('ObjectGantt.harness: the running block installed no GanttView stand-in in its beforeEach.');
}
return standIns.ganttView(props as never);
},
}));
vi.mock('@object-ui/plugin-detail', async (importOriginal) => ({
...(await importOriginal<typeof import('@object-ui/plugin-detail')>()),
RecordDetailDrawer: () => null,
deriveRecordPageHref: () => null,
}));
// ── ObjectGantt.fetchGate-7225 ──────────────────────────────────────────────────
/**
* objectui#7225 ask 2 — the gantt's DUPLICATE query is gated (maintainer
* ruling B, 2026-09-02; objectui#6482's undischarged gating half).
*
* Before this, `reload` listed `objectSchema` in its dependency list, so a
* mount issued TWO `find` calls: one before the object schema settled, with
* `buildExpandFields` seeing no fields and therefore NO `$expand` at all, and
* one after. Measured on this component with an instrumented adapter over
* three latency profiles — invariably 2 `find` and 1 `getObjectSchema` per
* load, expand sets `[null, ['owner']]`.
*
* ⭐ Why gating pays HERE, per #6482's own per-component standard (it measured
* three profiles and found the cost differs by component, so the table is not
* an argument on its own): the gantt is not the mild kanban-style "round trip
* bought and thrown away". Whenever the metadata read is the slower of the two
* — the common case on a cold `MetadataCache` — the user sees the full
* THREE-STEP PAINT: raw foreign-key ids, back to the loading placeholder, then
* the expanded rows.
*
* ⛔ GATING IS NOT CAPPING. objectui#7210's ruling a' put a row ceiling on
* these queries and that is a different change on the same lines; this file
* asserts only HOW MANY queries go out and whether the first one carries its
* expansion. The ceiling has its own pin
* (the `ObjectGantt.rowCeiling-7210` block in this file).
*
* ⚠️ The gate is only safe because the schema resolution now SETTLES ON EVERY
* EXIT (objectui#7232): the component's own effect used to return without
* settling on `!effectiveDataSource`, on `!resource` and in its `catch`, which
* cost nothing while nothing waited on it — and would hold a gated query open
* FOREVER. `useSettledSchema` settles on all three, and the last two cases
* below are that trap, pinned: a chart that never loads is the failure this
* file exists to make impossible.
*
* REVERSE VERIFICATION — prediction MISSED, reported rather than adjusted.
* Predicted before running: deleting
* `if (recordQueryDerivesExpand && !objectSchemaReady) return;` from
* `ObjectGantt` turns the first two cases red and leaves the two
* settle-on-every-exit cases green — 2 failed / 3 passed. OBSERVED:
* **4 failed / 1 passed**. Direction as predicted, magnitude higher, and the
* reason is worth writing down: the prediction assumed the second query came
* from `objectSchema`'s identity changing, so a definition that settles as
* `null` (no `getObjectSchema`, or a read that threw) would still produce one
* query. It does not. The second query comes from `objectSchemaReady` being in
* the effect's DEPENDENCY LIST — it flips `false` to `true` on every path,
* including both settle-with-nothing paths, so with the early return deleted
* the effect re-runs and reloads a second time in all four adapter cases. The
* inline-`value` case is the one that stays green, since it never queries at
* all. The gate line and the dependency are two halves of one mechanism, and
* the ablation only removed one of them.
*/
describe('ObjectGantt.fetchGate-7225', () => {
beforeEach(() => {
standIns.ganttView = ({ tasks }: any) => (
<div data-testid="gantt-view" data-task-count={String(tasks.length)} />
);
});
const ROWS = [
{ id: '1', subject: 'Renewal', owner: 'u1', visible_from: '2026-01-01', due_date: '2026-01-05' },
];
/** A definition with a lookup, so a gated query has a real `$expand` to carry. */
const OBJECT_DEF = {
name: 'task',
fields: {
id: { name: 'id', type: 'text' },
subject: { name: 'subject', type: 'text' },
owner: { name: 'owner', type: 'lookup', reference: 'user' },
visible_from: { name: 'visible_from', type: 'date' },
due_date: { name: 'due_date', type: 'date' },
},
};
function makeAdapter(getObjectSchema?: any) {
return {
find: vi.fn(async () => ({ data: ROWS, total: ROWS.length })),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
...(getObjectSchema === undefined ? {} : { getObjectSchema }),
} as any;
}
const schema: any = {
type: 'object-gantt',
objectName: 'task',
gantt: { titleField: 'subject', startDateField: 'visible_from', endDateField: 'due_date' },
};
/** The expand sets of every issued query, in order. */
function expandSets(adapter: any): Array<unknown> {
return adapter.find.mock.calls.map(([, params]: [string, any]) => params?.$expand ?? null);
}
describe('objectui#7225 ask 2 — the gantt waits for the object schema instead of querying twice', () => {
it('issues ONE query per load, and it already carries the expansion', async () => {
const adapter = makeAdapter(vi.fn(async () => OBJECT_DEF));
render(<ObjectGantt schema={schema} dataSource={adapter} />);
await waitFor(() => expect(screen.getByTestId('gantt-view')).toBeTruthy());
await waitFor(() => expect(adapter.find).toHaveBeenCalledTimes(1));
// The old regime's signature was `[null, ['owner']]`. One expanded call.
expect(expandSets(adapter)).toEqual([['owner']]);
expect(adapter.getObjectSchema).toHaveBeenCalledTimes(1);
});
it('never issues an UNEXPANDED query for an object that declares a lookup', async () => {
const adapter = makeAdapter(vi.fn(async () => OBJECT_DEF));
render(<ObjectGantt schema={schema} dataSource={adapter} />);
await waitFor(() => expect(adapter.find).toHaveBeenCalled());
// The discarded round trip — and the raw-id frame it painted — is the
// thing gating removes. Not "fewer" unexpanded calls: none.
for (const params of adapter.find.mock.calls.map(([, p]: [string, any]) => p)) {
expect(params.$expand).toEqual(['owner']);
}
});
it('still queries when the adapter exposes NO `getObjectSchema` — the gate is on SETTLED, not on truthy', async () => {
// objectui#7232's trap: an exit that returns without settling would hold
// this query open forever, and the chart would never load.
const adapter = makeAdapter(undefined);
render(<ObjectGantt schema={schema} dataSource={adapter} />);
await waitFor(() => expect(screen.getByTestId('gantt-view')).toBeTruthy());
expect(adapter.find).toHaveBeenCalledTimes(1);
// Nothing to derive an expand set from, so the query is unexpanded — which
// is the same query this case produced before the gate.
expect(expandSets(adapter)).toEqual([null]);
});
it('still queries when the definition read REJECTS', async () => {
const adapter = makeAdapter(
vi.fn(async () => {
throw new Error('metadata endpoint down');
}),
);
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
try {
render(<ObjectGantt schema={schema} dataSource={adapter} />);
await waitFor(() => expect(screen.getByTestId('gantt-view')).toBeTruthy());
expect(adapter.find).toHaveBeenCalledTimes(1);
expect(expandSets(adapter)).toEqual([null]);
expect(String(error.mock.calls[0]?.[0] ?? '')).toContain('[useSettledSchema]');
} finally {
error.mockRestore();
}
});
it('an inline `value` data set paints without waiting for any metadata read', async () => {
const inline: any = {
...schema,
data: { provider: 'value', items: ROWS },
};
const adapter = makeAdapter(vi.fn(async () => OBJECT_DEF));
render(<ObjectGantt schema={inline} dataSource={adapter} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe('1'),
);
expect(adapter.find).not.toHaveBeenCalled();
});
});
});
// ── ObjectGantt.rowCeiling-7210 ─────────────────────────────────────────────────
/**
* objectui#7210, half 2 — maintainer ruling a′ (2026-09-02), on the gantt.
* The ceiling the gantt applies is its own, `GANTT_ROW_CEILING`, since
* objectstack#32421 (ruling B); the mechanism and the footnote are a′'s.
*
* The ruling, and the pin it names: a non-grid visualisation may fetch the
* whole FILTERED result set, because a truthful range needs all of it, but the
* fetch carries a platform-level hard ceiling expressed as a named constant in
* the renderer, not an authorable view key. Past the ceiling the visualisation
* draws the first N rows and shows a LOUD FOOTNOTE naming both N and M.
* Below it: no footnote, and the full set draws.
*
* ⛔ The direction the ruling calls dangerous is SILENT truncation — "a cut-off
* schedule still looks like a schedule". That is precisely what these cases
* exist to make impossible to reintroduce: the first one would still pass if
* the footnote were deleted and only the cap kept, so it asserts the note's
* text and BOTH numbers, not merely the row count.
*
* ⛔ This is the CAP, not the gate. objectui#7225's half gates the gantt's
* DUPLICATE schema-driven query; nothing here is about that, and the two are
* separate commits on this branch for that reason.
*
* REVERSE VERIFICATION — MEASURED, and corrected from what this docblock used
* to predict (objectui#7507). Removing `...nonGridRowCeilingQuery(…)` from
* `ObjectGantt`'s reload turns the truncation case red at the **`$top`
* assertion**; the below-ceiling case stays green. ⚠️ The pass/fail TALLY that
* used to be quoted here is deliberately gone: objectui#8769 changed how many
* cases this file has, and a stale count reads as a measurement.
*
* ⚠️ It does NOT go red at the footnote. The prediction that it would — "no
* probe row ⇒ `truncated` false ⇒ no note" — reads the mechanism backwards,
* and a wrong mechanism in a docblock is worse than none, because the next
* reader trusts it while deciding what an edit is safe to break. What actually
* happens: an adapter with no `$top` answers with the WHOLE filtered set, so
* `applyNonGridRowCeiling` sees far more rows than the ceiling, slices to it,
* and reports `truncated` from the rows in hand. The drawn count stays at the ceiling
* and the note still names both numbers. The probe row bounds the RESPONSE; it
* is not what makes truncation detectable once an unbounded one has arrived.
* So in this file the `$top` is graded by the `$top` assertion and by nothing
* else — which is the reason that assertion is not redundant with the note.
*/
describe('ObjectGantt.rowCeiling-7210', () => {
beforeEach(() => {
// The bar canvas is irrelevant here — every assertion is about how many rows
// reached the chart and what the component says about them. Same stub the
// sibling ObjectGantt tests use, for the same reason.
standIns.ganttView = ({ tasks }: any) => (
<div data-testid="gantt-view" data-task-count={String(tasks.length)} />
);
});
/** The whole filtered result set the store holds — past the gantt's ceiling. */
const TOTAL_ROWS = GANTT_ROW_CEILING + 321;
function makeRows(n: number) {
return Array.from({ length: n }, (_, i) => ({
id: String(i + 1),
subject: `Task ${i + 1}`,
visible_from: '2026-01-01',
due_date: '2026-12-31',
}));
}
let calls: Array<Record<string, any>> = [];
/**
* An adapter that HONOURS `$top` and `$skip`, the way a real one does. With
* `maxPageSize` it also refuses a `$top` over it, before reading anything,
* the way a host with `OS_DATA_MAX_PAGE_SIZE` set does (hosted: 5,000).
*/
function makeDataSource(storeSize: number, maxPageSize?: number) {
const store = makeRows(storeSize);
return {
find: vi.fn(async (_resource: string, params: any) => {
calls.push({ ...(params ?? {}) });
const top = typeof params?.$top === 'number' ? params.$top : store.length;
if (maxPageSize !== undefined && top > maxPageSize) {
throw new Error(
`Query parameter 'top' asks for ${top} rows; this deployment's maximum page size is ${maxPageSize}. `
+ `The query was not run. Ask for at most ${maxPageSize} rows and page with offset.`,
);
}
const skip = typeof params?.$skip === 'number' ? params.$skip : 0;
return { data: store.slice(skip, skip + top), total: store.length };
}),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
getObjectSchema: vi.fn(async () => ({
name: 'duly_task',
fields: {
id: { name: 'id', type: 'text' },
subject: { name: 'subject', type: 'text' },
visible_from: { name: 'visible_from', type: 'date' },
due_date: { name: 'due_date', type: 'date' },
},
})),
} as any;
}
const schema: any = {
type: 'object-gantt',
objectName: 'duly_task',
gantt: {
titleField: 'subject',
startDateField: 'visible_from',
endDateField: 'due_date',
},
};
describe('objectui#7210 ruling a′ — the gantt draws at most the platform ceiling, loudly', () => {
beforeEach(() => {
calls = [];
});
it('above the ceiling: draws exactly N rows and names BOTH N and M', async () => {
const dataSource = makeDataSource(TOTAL_ROWS);
render(<ObjectGantt schema={schema} dataSource={dataSource} />);
await waitFor(() => expect(screen.getByTestId('gantt-view')).toBeTruthy());
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(
String(GANTT_ROW_CEILING),
),
);
// The first read came back full, so the set was walked from the top
// under a unique order. The walk read one probe row past the ceiling —
// that is what makes the cut a fact about the rows in hand rather than a
// guess — and asked no single read for more than one step (a hosted
// maximum page size refuses a `$top` of 10,001).
const wanted = nonGridRowCeilingQuery(GANTT_ROW_CEILING).$top;
expect(calls[0].$top).toBe(GANTT_FETCH_STEP);
const walk = calls.slice(1);
const tops = walk.map((params) => params.$top);
expect(tops.reduce((sum, top) => sum + top, 0)).toBe(wanted);
for (const top of tops) expect(top).toBeLessThanOrEqual(GANTT_FETCH_STEP);
expect(walk.map((params) => params.$skip ?? 0)).toEqual(
tops.map((_, i) => tops.slice(0, i).reduce((sum, top) => sum + top, 0)),
);
for (const params of walk) expect(params.$orderby).toEqual({ id: 'asc' });
// ⭐ The half the ruling cares about: the truncation is NOT silent.
const note = await screen.findByRole('note');
expect(note.getAttribute('data-row-ceiling-note')).toBe('non-grid');
expect(note.textContent).toContain(String(GANTT_ROW_CEILING));
expect(note.textContent).toContain(String(TOTAL_ROWS));
expect(note.textContent).toMatch(/narrow the filter/i);
});
/**
* objectstack#32421, ruling B — the gantt left the shared ceiling. A
* result set past the shared 2,000 and inside the gantt's own ceiling is
* the card's production case (a 4,999-row schedule): every row draws, and
* there is no footnote, because nothing was cut.
*/
it('between the shared and the gantt ceiling: every row draws and there is NO footnote', async () => {
const between = 4999;
expect(between).toBeGreaterThan(NON_GRID_ROW_CEILING);
expect(between).toBeLessThan(GANTT_ROW_CEILING);
const dataSource = makeDataSource(between);
render(<ObjectGantt schema={schema} dataSource={dataSource} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(
String(between),
),
);
expect(calls.length).toBeGreaterThan(0);
for (const params of calls) {
expect(params.$top).toBe(GANTT_FETCH_STEP);
}
expect(screen.queryByRole('note')).toBeNull();
});
/**
* objectstack — the hosted refusal. A host with a maximum page size (the
* hosted plane sets `OS_DATA_MAX_PAGE_SIZE` to 5,000) refuses a `$top`
* over it before running the query, so a single read of the ceiling plus
* its probe row (10,001) put the refusal in place of the chart, on an
* EMPTY object as on a full one.
*
* REVERSE VERIFICATION: sending `...nonGridRowCeilingQuery(GANTT_ROW_CEILING)`
* as one read again turns all three of these red at the drawn count, with
* the refusal on screen.
*/
describe('a host with a maximum page size of 5,000', () => {
const HOSTED_MAX_PAGE_SIZE = 5000;
it('draws an empty object instead of the refusal', async () => {
render(<ObjectGantt schema={schema} dataSource={makeDataSource(0, HOSTED_MAX_PAGE_SIZE)} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe('0'),
);
expect(screen.queryByText(/maximum page size/)).toBeNull();
expect(calls).toHaveLength(1);
});
it('draws a set larger than one host page, every row', async () => {
const rows = HOSTED_MAX_PAGE_SIZE + 1234;
render(<ObjectGantt schema={schema} dataSource={makeDataSource(rows, HOSTED_MAX_PAGE_SIZE)} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(String(rows)),
);
expect(screen.queryByRole('note')).toBeNull();
for (const params of calls) expect(params.$top).toBeLessThanOrEqual(HOSTED_MAX_PAGE_SIZE);
});
it('past the gantt ceiling: draws the ceiling and still says so', async () => {
render(<ObjectGantt schema={schema} dataSource={makeDataSource(TOTAL_ROWS, HOSTED_MAX_PAGE_SIZE)} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(
String(GANTT_ROW_CEILING),
),
);
const note = await screen.findByRole('note');
expect(note.textContent).toContain(String(GANTT_ROW_CEILING));
expect(note.textContent).toContain(String(TOTAL_ROWS));
});
});
/**
* Ruling B keeps ruling a′'s "not authorable": an authored
* `pagination.pageSize` (or `limit`) does not reach the gantt's query in
* either direction — a small one does not cap it, a large one does not
* lift it past the constant.
*/
it('an authored `pagination.pageSize` changes nothing, small or large', async () => {
for (const pageSize of [50, 50000]) {
calls = [];
const dataSource = makeDataSource(4999);
const { unmount } = render(
<ObjectGantt schema={{ ...schema, pagination: { pageSize }, limit: pageSize }} dataSource={dataSource} />,
);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe('4999'),
);
for (const params of calls) {
expect(params.$top).toBe(GANTT_FETCH_STEP);
}
expect(screen.queryByRole('note')).toBeNull();
unmount();
}
});
it('below the ceiling: the full set draws and there is NO footnote', async () => {
const dataSource = makeDataSource(7);
render(<ObjectGantt schema={schema} dataSource={dataSource} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe('7'),
);
expect(screen.queryByRole('note')).toBeNull();
});
/**
* ⚠️ THIS CASE WAS INVERTED (objectui#8769). It used to read "an inline
* `value` data set is never capped by us, and never footnoted", and it was
* green because `reload` returned before the query — the same short-circuit
* that dropped an authored `filter` on that provider. It pinned the
* SHORT-CIRCUIT, not ruling a′: the ruling's budget is measured in DOM
* ELEMENTS PER RECORD, its own measurement table was taken over "real child
* views, inline `value` provider", and its text carves out no provider. An
* inline row costs the browser exactly what a fetched row costs.
*
* The inline provider's own three-key pin lives in
* the `ObjectGantt.inlineQueryKeys-8769` block in this file; this one stays here so the
* ceiling's own file states the exemption boundary in one place.
*/
it('an inline `value` data set IS capped, and says so', async () => {
const total = nonGridRowCeilingQuery(GANTT_ROW_CEILING).$top + 500;
const inline: any = {
...schema,
data: { provider: 'value', items: makeRows(total) },
};
render(<ObjectGantt schema={inline} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(
String(GANTT_ROW_CEILING),
),
);
const note = await screen.findByRole('note');
expect(note.textContent).toContain(String(GANTT_ROW_CEILING));
expect(note.textContent).toContain(String(total));
});
/**
* The exemption that REMAINS, and the reason the case above is not a
* contradiction: rows a HOST component hands down through the `data` prop
* are not ours to cap — we did not issue the query that produced them and
* have no `total` to name in a footnote.
*/
it('a host `data` prop is still never capped, and never footnoted', async () => {
const rows = makeRows(nonGridRowCeilingQuery(GANTT_ROW_CEILING).$top + 500);
render(<ObjectGantt schema={schema} {...({ data: rows } as any)} />);
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe(
String(rows.length),
),
);
expect(screen.queryByRole('note')).toBeNull();
});
});
});
// ── ObjectGantt.hostDataProp-7210 ───────────────────────────────────────────────
/**
* objectui#7210 — the registered `object-gantt` renderer draws its OWN query,
* not the host's rows.
*
* This is the measured basis for the paging-chrome correction one package over
* (`plugin-list/src/ListView.tsx`, `surfaceDrawsFetchedRows`): a host that
* fetches a page and hands it down as `data` — `ListView` does exactly that,
* for every view type — does not thereby feed the chart. `ObjectGanttRenderer`
* (`./index`) destructures `{ schema }` and renders
* `< ObjectGantt schema={bound} dataSource={dataSource} / >`, forwarding no
* other prop, so `ObjectGantt.reload`'s `rest.data` short-circuit is never
* reached from the registry path and the component queries for itself. The
* sibling wrappers (`object-grid`, `object-kanban`, `object-calendar`,
* `object-map`, `object-tree`) all spread `{...props}`; this one is the outlier.
*
* Two facts are pinned, because the footer correction rests on both:
*
* 1. the rows drawn are the ADAPTER's, not the host `data` prop's;
* 2. the query's `$top` is the PLATFORM CEILING — so its row count is not the
* host's page size and cannot be made to be by authoring
* `pagination.pageSize`.
*
* ⛔ Do not "fix" (1) by spreading `{...props}` in the renderer. That caps the
* chart at the host's page — a complete schedule silently becomes a truncated
* one that still looks like a schedule.
*
* ⚠️ Case (2) changed shape when objectui#7210's half 2 was RULED (a′,
* 2026-09-02) and kept its point. When this file was written the answer was
* open and the query carried no `$top` at all; the ruling settled it — a
* non-grid view may fetch the whole filtered set up to a PLATFORM CEILING
* expressed as a named constant in the renderer, and past it must say so
* loudly. So the assertion moves from "no cap" to "the cap is the platform's",
* which is what still separates it from the forbidden direction: `pageSize: 2`
* is on this schema and the query is not 2 rows wide. The pin that the host's
* page cannot bound the chart is unchanged; only the reason the number is not
* the host's has been written down.
*
* REVERSE VERIFICATION — direction and counts predicted before running: add
* `{...props}` to the `ObjectGanttRenderer` children callback and BOTH
* assertions in the first case flip (5 rows → 2, host rows drawn), while the
* `$top` case stays green because the component never gets as far as querying.
*/
describe('ObjectGantt.hostDataProp-7210', () => {
beforeEach(() => {
standIns.ganttView = ({ tasks }: any) => (
<div data-testid="gantt-view" data-task-count={String(tasks.length)}>
{tasks.map((t: any) => (
<div key={t.id} data-testid={`gv-task-${t.id}`}>{t.title}</div>
))}
</div>
);
});
/** What the adapter answers with — the whole result set. */
const ADAPTER_ROWS = Array.from({ length: 5 }, (_, i) => ({
id: String(i + 1),
subject: `Adapter task ${i + 1}`,
visible_from: '2026-01-01',
due_date: '2026-01-10',
}));
/** What a paging host hands down as `data` — one page of it. */
const HOST_PAGE = ADAPTER_ROWS.slice(0, 2).map(r => ({ ...r, subject: `Host task ${r.id}` }));
const schema: any = {
type: 'object-gantt',
objectName: 'duly_task',
gantt: {
titleField: 'subject',
startDateField: 'visible_from',
endDateField: 'due_date',
},
};
let calls: Array<Record<string, any>> = [];
function makeDataSource() {
return {
find: vi.fn(async (_resource: string, params: any) => {
calls.push({ ...(params ?? {}) });
return { data: ADAPTER_ROWS, total: ADAPTER_ROWS.length };
}),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
getObjectSchema: vi.fn(async () => ({
name: 'duly_task',
fields: {
id: { name: 'id', type: 'text' },
subject: { name: 'subject', type: 'text' },
visible_from: { name: 'visible_from', type: 'date' },
due_date: { name: 'due_date', type: 'date' },
},
})),
} as any;
}
describe('objectui#7210 — object-gantt ignores a host `data` prop', () => {
beforeEach(() => {
calls = [];
});
it('draws the adapter rows, not the page the host handed down', async () => {
const dataSource = makeDataSource();
render(
<SchemaRendererProvider dataSource={dataSource}>
<SchemaRenderer schema={schema} data={HOST_PAGE} />
</SchemaRendererProvider>,
);
await waitFor(() => expect(screen.getByTestId('gantt-view')).toBeTruthy());
await waitFor(() =>
expect(screen.getByTestId('gantt-view').getAttribute('data-task-count')).toBe('5'),
);
// The host's two rows are nowhere on screen; all five adapter rows are.
expect(screen.queryByText('Host task 1')).toBeNull();
expect(screen.getByText('Adapter task 5')).toBeTruthy();
expect(calls.length).toBeGreaterThan(0);
});
it('issues its query at the PLATFORM ceiling — the host page size cannot bound it', async () => {
const dataSource = makeDataSource();
render(
<SchemaRendererProvider dataSource={dataSource}>
<SchemaRenderer schema={schema} data={HOST_PAGE} pagination={{ pageSize: 2 }} />
</SchemaRendererProvider>,
);
await waitFor(() => expect(calls.length).toBeGreaterThan(0));
for (const params of calls) {
// Not `pagination.pageSize` (2), and not absent either: the walk's
// first step toward the platform ceiling. Five rows answer it short,
// so it is the only read.
expect(params.$top).not.toBe(2);
expect(params.$top).toBe(GANTT_FETCH_STEP);
expect(params.$skip).toBeUndefined();
}
});
});
});
// ── ObjectGantt.emptyHostData-7333 ──────────────────────────────────────────────
/**
* objectui#7333 — an EMPTY host `data` array is "no host rows yet", not "the
* host owns zero rows".
*
* `ObjectGantt` read a host `data` prop at two sites, and both took `[]` as an
* authoritative answer: `reload`'s short-circuit (`data && Array.isArray(data)`
* — `[]` is truthy) adopted it and returned before the chart's own query, and
* the gating flag (`Array.isArray(data)`) switched off the object-schema gate
* and the invalidation subscription that belong to that query. So a gantt whose
* `data` names its own source painted an EMPTY chart the moment a host handed
* it an array it had not filled yet.
*
* Both sites now read one predicate, `hostRows` in `ObjectGantt.tsx`: a
* non-empty host array is adopted as it always was, and an empty one leaves the
* chart reading from its own source, exactly as with no host array at all.
*
* ⚠️ Reach: the registered `object-gantt` renderer forwards no host prop, which
* the `ObjectGantt.hostDataProp-7210` block in this file pins, and `ObjectGanttProps` does
* not declare `data`. So every case here renders `ObjectGantt` directly and
* spreads the prop in, as a direct caller would have to.
*
* Cases 1 and 4 are the pins; 2 and 3 are their controls, and 5 is the "yet":
* 1. own source + host `[]` ⇒ the source is read and its rows paint;
* 2. own source + host rows ⇒ those rows paint, the source is never read;
* 3. own source + no host `data` ⇒ the source is read;
* 4. object provider + host `[]` ⇒ the query waits for the object schema and
* goes out ONCE, already expanded (the gating flag's half);
* 5. host rows that arrive after an empty first render are adopted.
*
* Cases 1–3 and 5 used to name an `api`-provider gantt's endpoint as its own
* source. The view-level `api` data source is retired in `@objectstack/spec`
* (objectstack#23082) and ObjectGantt builds no adapter from it
* (objectui#12325), so the own source here is the bound object, read through
* the context adapter — the predicate under test does not depend on which
* provider supplies it.
*/
describe('ObjectGantt.emptyHostData-7333', () => {
beforeEach(() => {
standIns.ganttView = ({ tasks }: any) => (
<div data-testid="gantt-view" data-task-count={String(tasks.length)}>
{tasks.map((t: any) => (
<div key={t.id} data-testid={`gv-task-${t.id}`}>{t.title}</div>
))}
</div>
);
});
/** What the gantt's own source (the bound object) answers with. */
const SOURCE_ROWS = [
{ id: 'e1', name: 'Source task 1', start_date: '2026-01-01', end_date: '2026-01-05' },
{ id: 'e2', name: 'Source task 2', start_date: '2026-01-02', end_date: '2026-01-06' },
];
/** What a host hands down as `data` when it DOES have rows. */
const HOST_ROWS = [
{ id: 'h1', name: 'Host task 1', start_date: '2026-02-01', end_date: '2026-02-03' },
];
function ownSourceSchema(): any {
return {
type: 'object-gantt',
objectName: 'tasks',
gantt: { titleField: 'name', startDateField: 'start_date', endDateField: 'end_date' },
};
}
function makeSource() {
return {
find: vi.fn(async () => ({ data: SOURCE_ROWS, total: SOURCE_ROWS.length })),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
getObjectSchema: vi.fn(async () => ({ name: 'tasks', fields: {} })),
} as any;
}
/** Renders an object-bound gantt, spreading `hostProps` in as a direct caller would. */
function renderOwnSourceGantt(source: ReturnType<typeof makeSource>, hostProps: Record<string, unknown>) {
const tree = (props: Record<string, unknown>) => (
<ObjectGantt schema={ownSourceSchema()} dataSource={source} {...(props as any)} />
);
const utils = render(tree(hostProps));
return { ...utils, rerenderWith: (props: Record<string, unknown>) => utils.rerender(tree(props)) };
}
const taskCount = () => screen.getByTestId('gantt-view').getAttribute('data-task-count');
/** Lets every in-flight read settle, so a query that would follow is counted. */
const settle = () => act(() => new Promise<void>((resolve) => setTimeout(resolve, 100)));
describe('objectui#7333 — a gantt handed an EMPTY host array still reads its own source', () => {
it('host `data: []` ⇒ the source is read and its rows paint', async () => {
const source = makeSource();
renderOwnSourceGantt(source, { data: [] });
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
expect(taskCount()).toBe(String(SOURCE_ROWS.length));
expect(source.find).toHaveBeenCalledWith('tasks', expect.anything());
});
it('CONTROL — host `data` with rows ⇒ those rows paint and the source is never read', async () => {
const source = makeSource();
renderOwnSourceGantt(source, { data: HOST_ROWS });
await waitFor(() => expect(screen.getByTestId('gv-task-h1')).toBeTruthy());
await settle();
expect(taskCount()).toBe(String(HOST_ROWS.length));
expect(screen.queryByTestId('gv-task-e1')).toBeNull();
expect(source.find).not.toHaveBeenCalled();
});
it('CONTROL — no host `data` ⇒ the source is read', async () => {
const source = makeSource();
renderOwnSourceGantt(source, {});
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
expect(source.find).toHaveBeenCalledWith('tasks', expect.anything());
});
it('host rows that arrive after an empty first render are adopted', async () => {
const source = makeSource();
const { rerenderWith } = renderOwnSourceGantt(source, { data: [] });
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
rerenderWith({ data: HOST_ROWS });
await waitFor(() => expect(screen.getByTestId('gv-task-h1')).toBeTruthy());
expect(taskCount()).toBe(String(HOST_ROWS.length));
expect(screen.queryByTestId('gv-task-e1')).toBeNull();
});
});
describe('objectui#7333 — an EMPTY host array does not switch off the object-schema gate', () => {
/** A definition with a lookup, so the gated query has a real `$expand` to carry. */
const OBJECT_DEF = {
name: 'task',
fields: {
id: { name: 'id', type: 'text' },
subject: { name: 'subject', type: 'text' },
owner: { name: 'owner', type: 'lookup', reference: 'user' },
visible_from: { name: 'visible_from', type: 'date' },
due_date: { name: 'due_date', type: 'date' },
},
};
const OBJECT_ROWS = [
{ id: '1', subject: 'Renewal', owner: 'u1', visible_from: '2026-01-01', due_date: '2026-01-05' },
];
const objectSchema: any = {
type: 'object-gantt',
objectName: 'task',
gantt: { titleField: 'subject', startDateField: 'visible_from', endDateField: 'due_date' },
};
it('host `data: []` on an object-bound gantt ⇒ ONE query, issued after the schema settles, already expanded', async () => {
const adapter = {
find: vi.fn(async () => ({ data: OBJECT_ROWS, total: OBJECT_ROWS.length })),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
getObjectSchema: vi.fn(async () => OBJECT_DEF),
} as any;
render(<ObjectGantt schema={objectSchema} dataSource={adapter} {...({ data: [] } as any)} />);
await waitFor(() => expect(taskCount()).toBe(String(OBJECT_ROWS.length)));
await waitFor(() => expect(adapter.find).toHaveBeenCalled());
await settle();
// Ungated, the first query goes out before the definition lands and
// carries no expansion, and a second follows once it does: `[null,
// ['owner']]` — the signature the `ObjectGantt.fetchGate-7225` block
// records for the ungated regime.
const expandSets = adapter.find.mock.calls.map(([, params]: [string, any]) => params?.$expand ?? null);
expect(expandSets).toEqual([['owner']]);
});
});
});
// ── ObjectGantt.inlineQueryKeys-8769 ────────────────────────────────────────────
/**
* objectui#8769 — a `provider: 'value'` gantt honours the three query keys the
* fetching path honours: `filter`, `sort`, and the objectui#7210 row ceiling.
*
* ## What was wrong
*
* `reload` short-circuited the inline provider (`setData(dataItems)`; return)
* BEFORE `effectiveDataSource.find(...)`, which is the ONE site that lowers
* `schema.filter` to `$filter`, `schema.sort` to `$orderby` and the ceiling to
* `$top`. An authored `filter` therefore reached nothing and every inline row
* was charted — the fail-OPEN direction: the key that was ignored is the key
* that NARROWS, so the author saw MORE rows than declared, with no diagnostic.
*
* ⛔ Not a data-exposure boundary. The rows are already in the authored schema;
* what is wrong is that the chart answers a question nobody asked.
*
* ## The two-sided reading is the finding
*
* A one-sided reproduction cannot tell "the filter was ignored" from "the
* filter matched everything", so the first case renders the SAME rows and the
* SAME filter twice — once inline, once through a context adapter — and reads
* the DISAGREEMENT. The adapter is a `ValueDataSource` over the same rows, so
* the matcher is literally the same object on both sides and the only variable
* left is which branch of `reload` ran.
*
* ## ORDER: filter first, ceiling second (objectui#7210 ruling a′)
*
* The ceiling is applied to the FILTERED set, matching the fetching path
* exactly — there `$filter` and `$top` travel in one query and every backend
* filters before it limits. `ceilingOrder` pins it from the observable side: a
* set that is over the ceiling BEFORE filtering and under it after draws every
* matching row and shows NO footnote. A ceiling-then-filter implementation
* would draw at most 2,000 rows there and would still footnote.
*
* ## The `never capped by us` case this file replaces
*
* The `ObjectGantt.rowCeiling-7210` block in this file asserted that an inline set is never
* capped and never footnoted. That case pinned the SHORT-CIRCUIT's behaviour,
* not ruling a′: the ruling's own budget is measured in DOM ELEMENTS PER
* RECORD (its table was measured over "real child views, inline `value`
* provider"), and an inline row costs the browser exactly what a fetched row
* costs. Nothing in the ruling text carves the provider out. So the exemption
* moves here, inverted, with the triage ruling on objectui#8769 as its
* authority — and `ceilingNote` below is what makes the cut loud rather than
* silent, which is the half ruling a′ actually protects.
*
* ## Live adjacency, measured (objectui#9001 / PR objectui#9049)
*
* That card makes core's `convertFiltersToAST` THROW `FilterOperatorError` for
* an `$icontains` comparand that is not a non-empty string. This repair does
* NOT inherit it: the inline provider resolves to `ValueDataSource`, whose
* matcher is local and refuses by EXCLUDING the row and logging once. Since
* objectui#10767 that adapter does reach the converter — its array arm lowers
* a spec `ViewFilterRule[]` through `toFilterNode` before matching — but a
* refusal the lowering raises is re-seated as the same excluded-and-logged
* refusal, never rethrown from `find`; an AST tuple like the one below is
* passed through the sink untouched and judged by the matcher's own comparand
* door. `refusedComparandDoesNotThrow` pins the consequence from the outside
* either way: a render, not a throw.
*
* REVERSE VERIFICATION — direction predicted BEFORE running, from the committed
* fix, by restoring the short-circuit: `twoSidedFilter`, `inlineSort`,
* `staticDataSpelling`, `ceilingCap`, `ceilingNote` and `ceilingOrder` go RED;
* `control` and `refusedComparandDoesNotThrow` stay GREEN (the control draws
* the same rows in the same order either way, which is what makes it a
* control).
*/
describe('ObjectGantt.inlineQueryKeys-8769', () => {
beforeEach(() => {
// The bar canvas is irrelevant here — every assertion is about WHICH rows
// reached the chart and in WHAT ORDER. Same stub the sibling ObjectGantt pins
// use, widened by the id list because `sort` is unreadable from a count.
standIns.ganttView = ({ tasks }: any) => (
<div
data-testid="gantt-view"
data-task-count={String(tasks.length)}
data-task-ids={tasks.map((t: any) => String(t.id)).join(',')}
/>
);
});
const ROWS = [
{ id: '1', subject: 'Alpha', status: 'open', rank: 30, visible_from: '2026-01-01', due_date: '2026-01-31' },
{ id: '2', subject: 'Bravo', status: 'closed', rank: 10, visible_from: '2026-02-01', due_date: '2026-02-28' },
{ id: '3', subject: 'Charlie', status: 'open', rank: 40, visible_from: '2026-03-01', due_date: '2026-03-31' },
{ id: '4', subject: 'Delta', status: 'closed', rank: 20, visible_from: '2026-04-01', due_date: '2026-04-30' },
{ id: '5', subject: 'Echo', status: 'open', rank: 50, visible_from: '2026-05-01', due_date: '2026-05-31' },