mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Test DataGrid schema-pending loading skeleton.
Cover both the pre-schema shimmer and the per-column skeleton path once columns are discovered. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6e67b6a2b1
commit
f0b32c28f9
@ -611,3 +611,60 @@ describe("DataGrid horizontal scrolling", () => {
|
||||
expect((bodyScroll as HTMLElement).scrollLeft).toBe(120);
|
||||
});
|
||||
});
|
||||
|
||||
describe("DataGrid loading skeleton", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("ResizeObserver", MockResizeObserver);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("shows a full-width shimmer when loading before any columns are known", () => {
|
||||
function SchemaPendingHarness() {
|
||||
const [state, setState] = useState(() => createDefaultDataGridState([]));
|
||||
return (
|
||||
<DataGrid<Row>
|
||||
columns={[]}
|
||||
rows={[]}
|
||||
getRowId={(row) => row.id}
|
||||
state={state}
|
||||
onChange={setState}
|
||||
isLoading
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const { container } = render(<SchemaPendingHarness />);
|
||||
|
||||
const skeleton = container.querySelector("[data-data-grid-schema-pending-skeleton]");
|
||||
expect(skeleton).toBeInstanceOf(HTMLElement);
|
||||
// Five placeholder columns × 10 rows → visible shimmer cells, not an empty pane.
|
||||
expect(skeleton?.querySelectorAll("[role='row']").length).toBe(10);
|
||||
});
|
||||
|
||||
it("uses per-column skeleton rows once the schema is known", () => {
|
||||
function KnownSchemaHarness() {
|
||||
const [state, setState] = useState(() => createDefaultDataGridState(columns));
|
||||
return (
|
||||
<DataGrid<Row>
|
||||
columns={columns}
|
||||
rows={[]}
|
||||
getRowId={(row) => row.id}
|
||||
state={state}
|
||||
onChange={setState}
|
||||
isLoading
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const { container } = render(<KnownSchemaHarness />);
|
||||
|
||||
expect(container.querySelector("[data-data-grid-schema-pending-skeleton]")).toBeNull();
|
||||
const rowsClip = container.querySelector("[data-data-grid-rows-clip]");
|
||||
expect(rowsClip?.querySelectorAll("[role='row']").length).toBe(8);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user