Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/components-type-checks-its-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
---

chore(components): `@object-ui/components` type-checks its whole test tree.

No published code moves. The package gains a `tsconfig.test.json` chained from
`type-check`, its 34 code-tier test errors are fixed in the tests themselves,
and the narrow `tsconfig.typetests.json` — the rescue hatch for a package still
in `TEST_DEBT` — is retired now that the full project compiles the same file
(objectui#4040 tranche 4, under objectui#4291's ratchet). The remaining
`TEST_DEBT` counts for `core` and `app-shell` are corrected to the tranche-4
remeasurement.
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"prebuild": "pnpm --filter @object-ui/types build && pnpm --filter @object-ui/core build && pnpm --filter @object-ui/react build",
"pretest": "pnpm run prebuild",
"test": "vitest run",
"type-check": "tsc --noEmit && tsc -p tsconfig.typetests.json",
"type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
"lint": "eslint ."
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
* payload was still lost downstream.
*/

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { ComponentRegistry } from '@object-ui/core';
import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core';
import { ActionProvider } from '@object-ui/react';
import '../renderers/basic/elements';
import '../renderers/action/action-button';
Expand All @@ -42,7 +43,12 @@ function Registered({ type, schema }: { type: string; schema: any }) {
}

describe('bodyExtra survives the renderer forward whitelist', () => {
let api: ReturnType<typeof vi.fn>;
// Typed with the signature `ActionProvider`'s `handlers` prop declares, not
// `ReturnType<typeof vi.fn>` — that resolves to the un-instantiated
// `Mock<Procedure | Constructable>`, which no handler slot accepts and whose
// `mock.calls[0]` is the EMPTY tuple, so `dispatched()` below read `undefined`
// as far as the compiler was concerned (objectui#4040).
let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>>;

beforeEach(() => {
api = vi.fn(async () => ({ success: true }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
* the wrap was still dropped downstream.
*/

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { ComponentRegistry } from '@object-ui/core';
import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core';
import { ActionProvider } from '@object-ui/react';
import '../renderers/action/action-button';
import '../renderers/action/action-group';
Expand All @@ -54,7 +55,9 @@ function Registered({ type, schema }: { type: string; schema: any }) {
}

describe('bodyShape survives the declared-action renderer whitelists', () => {
let api: ReturnType<typeof vi.fn>;
// See action-bodyExtra-forward.test.tsx for why this is not
// `ReturnType<typeof vi.fn>` (objectui#4040).
let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>>;

beforeEach(() => {
api = vi.fn(async () => ({ success: true }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ const FIELDS = [
{ value: 'pinned', label: 'Pinned', type: 'boolean' },
];

function renderInForm(onSubmit: () => void, value?: any) {
// `React.FormEventHandler`, not `() => void`: every caller passes a spy that
// takes the event and calls `preventDefault()` on it, and a one-parameter
// function is not assignable to a zero-parameter one — the helper's declared
// type contradicted all three of its uses (objectui#4040).
function renderInForm(
onSubmit: React.FormEventHandler<HTMLFormElement>,
value?: any,
) {
return render(
<form onSubmit={onSubmit}>
<FilterBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import React from 'react';
import { ComponentRegistry } from '@object-ui/core';
import type { ConfirmationHandler, ToastHandler } from '@object-ui/core';
import { ActionProvider, RecordContextProvider } from '@object-ui/react';
import { I18nProvider, useObjectTranslation } from '@object-ui/i18n';

Expand Down Expand Up @@ -75,8 +76,12 @@ function BundleLoader({ bundle, children }: { bundle: unknown; children: React.R
}

function renderHeader(opts: { bundle?: unknown; action?: Record<string, unknown> }) {
const onConfirm = vi.fn(async () => true);
const onToast = vi.fn();
// Typed with the handler signatures `@object-ui/core` declares: a bare
// `vi.fn(async () => true)` is zero-arity, so `onConfirm.mock.calls[0][0]` —
// the translated message these tests exist to pin — was the empty tuple's
// element 0 as far as the compiler was concerned (objectui#4040).
const onConfirm = vi.fn<ConfirmationHandler>(async () => true);
const onToast = vi.fn<ToastHandler>();
const handler = vi.fn(async () => ({ success: true }));
const utils = render(
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false }}>
Expand Down
22 changes: 20 additions & 2 deletions packages/components/src/__tests__/page-header-actions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import { describe, it, expect, vi } from 'vitest';
import { useEffect } from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { ComponentRegistry } from '@object-ui/core';
import type {
ActionContext,
ActionDef,
ActionResult,
ParamCollectionHandler,
} from '@object-ui/core';
import {
ActionProvider,
RecordContextProvider,
Expand Down Expand Up @@ -437,7 +443,13 @@ describe('PageHeaderRenderer — record dispatch shape (objectui#3391)', () => {
record?: any;
onParamCollection?: (params: any[], action?: any) => Promise<Record<string, any> | null>;
}) {
const api = vi.fn(async () => ({ success: true }));
// Typed with the signature the `handlers` prop declares: a bare zero-arity
// `vi.fn` makes `api.mock.calls[0]` the empty tuple, so every
// `api.mock.calls[0][0]` below — the dispatched ActionDef, which is what
// these cases are about — was unchecked (objectui#4040).
const api = vi.fn<
(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>
>(async () => ({ success: true }));
const header = <PageHeader schema={{ type: 'page:header', title: 'Plan', actions: [opts.action] }} />;
render(
<ActionProvider handlers={{ api }} onParamCollection={opts.onParamCollection}>
Expand Down Expand Up @@ -483,7 +495,13 @@ describe('PageHeaderRenderer — record dispatch shape (objectui#3391)', () => {
it('surfaces a spec-shaped params ARRAY as actionParams and keeps the stash through collection', async () => {
const record = { id: 'rec-2' };
const paramDefs = [{ name: 'copy_ovr_start', type: 'date', required: true }];
const onParamCollection = vi.fn(async () => ({ copy_ovr_start: '2026-01-01' }));
// Typed for the same reason as `api` above: the assertion below reads
// `onParamCollection.mock.calls[0][0]` — the param DEFINITIONS the runner
// handed the collector — which a zero-arity mock types as element 0 of the
// empty tuple (objectui#4040).
const onParamCollection = vi.fn<ParamCollectionHandler>(async () => ({
copy_ovr_start: '2026-01-01',
}));
const action = {
name: 'copy_plan_params_3391',
type: 'api',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ describe('renamed local dialects do not collide with a spec export', () => {

/* -------------------------------------------------------------------------- */
/* Compile-time pins. A violation is a `tsc` error, not a runtime failure. */
/* Compiled by this package's `tsconfig.typetests.json` (objectui#3181). */
/* Compiled by this package's `tsconfig.test.json` (objectui#3181): the narrow */
/* `tsconfig.typetests.json` that used to name this one file was the rescue */
/* hatch for a package still in TEST_DEBT, and it was retired with the debt */
/* (objectui#4040 / objectui#4291). */
/* -------------------------------------------------------------------------- */

type Assert<T extends true> = T;
Expand Down
12 changes: 9 additions & 3 deletions packages/components/src/__tests__/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

import { render, RenderOptions } from '@testing-library/react';
import { ComponentRegistry } from '@object-ui/core';
import type { SchemaNode } from '@object-ui/types';
import type { BaseSchema } from '@object-ui/types';

/**
* Test utility for rendering components from schema
* Test utility for rendering components from schema.
*
* `BaseSchema`, not `SchemaNode`: `SchemaNode` is the union a schema TREE can
* hold — `BaseSchema | string | number | boolean | null | undefined` — and this
* helper reads `schema.type` off it, which four of those six members do not
* have. Every caller passes an object; the declared type was wider than the
* function and than anything it is used with (objectui#4040).
*/
export function renderComponent(schema: SchemaNode, options?: RenderOptions) {
export function renderComponent(schema: BaseSchema, options?: RenderOptions) {
const Component = ComponentRegistry.get(schema.type);

if (!Component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@
* That verdict is carried, with its evidence, in the gate's JUSTIFIED table.
*/

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { render, waitFor } from '@testing-library/react';
import React from 'react';
import { ComponentRegistry } from '@object-ui/core';
import type {
ActionContext,
ActionDef,
ActionResult,
ParamCollectionHandler,
} from '@object-ui/core';
import { ActionProvider } from '@object-ui/react';
// Module-scope side-effect imports — `action:bar` resolves its members and the
// overflow menu through the ComponentRegistry at render time, and the light
Expand Down Expand Up @@ -82,8 +88,11 @@ const CREATE = {
autoTrigger: true,
};

let api: ReturnType<typeof vi.fn>;
let onParamCollection: ReturnType<typeof vi.fn>;
// Typed with the signatures the provider's props declare, not
// `ReturnType<typeof vi.fn>` — see action-bodyExtra-forward.test.tsx
// (objectui#4040).
let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>>;
let onParamCollection: Mock<ParamCollectionHandler>;

beforeEach(() => {
api = vi.fn(async () => ({ success: true }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
* assertion that refactor would be indistinguishable from the correct one.
*/

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { render, fireEvent, waitFor } from '@testing-library/react';
import React from 'react';
import { ComponentRegistry } from '@object-ui/core';
import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core';
import { ActionProvider } from '@object-ui/react';
// Module-scope side-effect imports — the light `dom` project does not load the
// `@object-ui/components` graph, and these renderers register themselves on
Expand Down Expand Up @@ -100,7 +101,9 @@ const ICON_ORDER = [
'locations', 'toast', 'resultDialog',
];

let api: ReturnType<typeof vi.fn>;
// See action-bodyExtra-forward.test.tsx for why this is not
// `ReturnType<typeof vi.fn>` (objectui#4040).
let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>>;

beforeEach(() => {
api = vi.fn(async () => ({ success: true }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
* actions carry the flag, and only the last block tells them apart.
*/

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { ComponentRegistry } from '@object-ui/core';
import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core';
import { ActionProvider } from '@object-ui/react';
// Module-scope side-effect imports — `action:bar` resolves its members (and the
// overflow menu) through the ComponentRegistry at render time, and the light
Expand Down Expand Up @@ -75,7 +76,9 @@ const CREATE = {
locations: ['list_toolbar'],
};

let api: ReturnType<typeof vi.fn>;
// See action-bodyExtra-forward.test.tsx for why this is not
// `ReturnType<typeof vi.fn>` (objectui#4040).
let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>>;

beforeEach(() => {
api = vi.fn(async () => ({ success: true }));
Expand Down Expand Up @@ -313,7 +316,9 @@ describe('what suppresses an auto-trigger, and what does not (#4162)', () => {
expect(screen.queryByRole('button', { name: 'Create Environment' })).toBeNull();
inline.unmount();

const overflowApi = vi.fn(async () => ({ success: true }));
const overflowApi = vi.fn<
(action: ActionDef, ctx: ActionContext) => Promise<ActionResult>
>(async () => ({ success: true }));
render(
<ActionProvider handlers={{ api: overflowApi }}>
<Bar actions={[...FILLERS, hidden]} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import React from 'react';
import { ComponentRegistry } from '@object-ui/core';
import type { DataTableSchema } from '@object-ui/types';
import { PredicateScopeProvider } from '@object-ui/react';
import { planDataTableRowMenu } from '../data-table';

Expand Down Expand Up @@ -222,9 +223,21 @@ describe('planDataTableRowMenu', () => {
});

it('still counts an item that renders merely DISABLED', () => {
// Typed as what the production caller actually hands the planner —
// `schema.rowEditPredicates`, whose declared shape carries `disabledWhen`
// alongside `visibleWhen` (`@object-ui/types`, objectui#2614). The planner's
// own parameter names only `visibleWhen`, because visibility is all it
// decides; a bare object literal therefore tripped excess-property checking
// once this package started type-checking its tests, while the identical
// value reaches it unremarked in production (objectui#4040). Deriving the
// annotation keeps the fixture honest about which key is being ignored,
// rather than deleting the key and quietly renaming the case.
const editPredicates: DataTableSchema['rowEditPredicates'] = {
disabledWhen: 'record.frozen == true',
};
const plan = planDataTableRowMenu({
onRowEdit: noop,
editPredicates: { disabledWhen: 'record.frozen == true' },
editPredicates,
customActions: [],
row: frozen,
scope,
Expand Down
65 changes: 65 additions & 0 deletions packages/components/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
// Type-checks this package's TESTS, which `tsconfig.json` excludes.
// See `packages/types/tsconfig.test.json` for why that exclusion was a hole:
// the build correctly keeps tests out of `dist`, but nothing else compiled
// them, so a test could assert a contract the compiler never checked.
//
// This project is now the ONLY one that compiles
// `src/__tests__/share-filter-sort-spec-parity.test.ts`, whose compile-time
// pins are erased at runtime — vitest proves nothing about them and `tsc` is
// the only thing that can (objectui#3181). A narrow `tsconfig.typetests.json`
// next door used to name that one file while the rest of the tree was in
// TEST_DEBT; the package graduated in objectui#4040 and the narrow project was
// retired with it, after `--listFiles` showed this project reads the same file
// and a provably-false `Assert` appended to it turned this project red.
//
// Chained from this package's `type-check` script, which is what the CI
// `Type Check` job runs; scripts/check-type-check-coverage.mjs enforces the
// chaining — a config nothing runs is the objectui#3009 failure itself.
"extends": "../../tsconfig.json",
"compilerOptions": {
// A checking project, never an emitting one.
"noEmit": true,
// The package build emits `dist`; this project emits nothing, so it must
// not inherit `composite` / `declaration` from the build config.
"composite": false,
"declaration": false,
"jsx": "react-jsx",
// One notch above the root's ES2020: these suites read the last emitted
// call with `calls.at(-1)`, and `Array.prototype.at` is ES2022. The
// compiler named the remedy itself. Raised HERE and not in `tsconfig.json`,
// so the package SOURCE keeps compiling against the ES2020 baseline it
// ships to.
"lib": ["ES2022", "DOM", "DOM.Iterable"],
// Naming `types` at all switches off automatic `@types/*` inclusion;
// `@testing-library/jest-dom` is listed for the matchers the DOM suites use.
"types": ["node", "@testing-library/jest-dom"],
// MIRRORS `tsconfig.json`, and only this one flag. A test file imports the
// package's own sources, so those sources are program inputs here too — and
// this package's BUILD config has `noImplicitAny: false`. Re-enabling it in
// this project would report 26 errors in `src/renderers/**` (sidebar,
// action-bar, action-menu, action-group, tree-view), i.e. it would make the
// TEST project the compiler of record for a SOURCE strictness decision that
// `tsconfig.json` owns. Those 26 are filed rather than silently adopted;
// tightening the package is a separate change to the build config, where the
// published output would actually move.
"noImplicitAny": false,
// Drop the root tsconfig's source-tree `paths` so `@object-ui/*` and
// `@objectstack/spec` resolve through the workspace dependency's built
// `.d.ts` instead of pulling sibling sources in as program inputs (TS6059).
// The single entry kept is this package's OWN name: `snapshot-critical.test.tsx`
// imports it the way a consumer would, and an empty `paths` sends that
// through the package `exports` to `dist/index.d.ts` — an artifact
// `type-check` must not depend on, since turbo makes it wait on `^build`
// (the DEPENDENCIES' builds), not on this package's own. The repo-root
// vitest config aliases the same specifier to `src`, so this resolves the
// import to exactly what the test runs against.
"baseUrl": ".",
"paths": {
"@object-ui/components": ["src/index.ts"]
}
},
// `src/**/*.d.ts` picks up `src/global.d.ts`, whose ambient declarations the
// test files rely on.
"include": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/**/*.d.ts"]
}
Loading
Loading