From 51e5e9df8bf3dde6b2fd2ac2081c189496813867 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 20:08:28 +0000 Subject: [PATCH 1/2] fix(examples): lowercase hello-world schema node types to registered keys `examples/hello-world/schema.json` used PascalCase (`Page`/`Card`/`Text`/ `Button`) but the registry keys are lowercase (`page`/`card`/`text`/ `button`), so every node fell through `Registry.get` to the OBJUI-001 "Unknown component type" panel. Lowercase all four; add a test that walks the schema's node types against the CLI's generated `KNOWN_SCHEMA_TYPES` list instead of restating the four strings, so the pin survives a rename. Fixes #5236 --- examples/hello-world/schema.json | 10 +++--- examples/hello-world/schema.test.ts | 48 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 examples/hello-world/schema.test.ts diff --git a/examples/hello-world/schema.json b/examples/hello-world/schema.json index 18ceccee5f..f512e36393 100644 --- a/examples/hello-world/schema.json +++ b/examples/hello-world/schema.json @@ -1,13 +1,13 @@ { - "type": "Page", + "type": "page", "title": "Hello ObjectUI", "children": [ { - "type": "Card", + "type": "card", "children": [ - { "type": "Text", "content": "Welcome to ObjectUI!" }, - { "type": "Text", "content": "This UI is rendered from a JSON schema." }, - { "type": "Button", "content": "Get Started", "variant": "default" } + { "type": "text", "content": "Welcome to ObjectUI!" }, + { "type": "text", "content": "This UI is rendered from a JSON schema." }, + { "type": "button", "content": "Get Started", "variant": "default" } ] } ] diff --git a/examples/hello-world/schema.test.ts b/examples/hello-world/schema.test.ts new file mode 100644 index 0000000000..dcf6400228 --- /dev/null +++ b/examples/hello-world/schema.test.ts @@ -0,0 +1,48 @@ +/** + * objectui#5236 — `examples/hello-world/schema.json` is the smallest example + * in the repo, the one a newcomer opens first, and `App.tsx` renders it + * directly (`import schema from './schema.json'` fed to `SchemaRenderer`). + * A node whose `type` is not a registered component key renders the + * OBJUI-001 "Unknown component type" panel instead of the intended UI. + * + * This walks every node in the schema and checks its `type` against + * `KNOWN_SCHEMA_TYPES` — the generated, registration-derived list `objectui + * check` itself uses (`packages/cli/src/utils/known-schema-types.ts`, + * objectui#5115) — rather than restating `page`/`card`/`text`/`button` as + * fossil literals here. That keeps the pin meaningful if the example's node + * types ever change: it fails on any type this repository does not + * register, not just on a diff from today's four values. + */ +import { describe, expect, it } from 'vitest'; + +import { KNOWN_SCHEMA_TYPES } from '../../packages/cli/src/utils/known-schema-types.js'; +import schema from './schema.json'; + +interface SchemaNode { + type?: unknown; + children?: unknown; + [key: string]: unknown; +} + +function collectTypes(node: unknown, out: string[]): void { + if (!node || typeof node !== 'object') return; + const n = node as SchemaNode; + if (typeof n.type === 'string') out.push(n.type); + if (Array.isArray(n.children)) { + for (const child of n.children) collectTypes(child, out); + } +} + +describe('examples/hello-world schema.json', () => { + const types: string[] = []; + collectTypes(schema, types); + const knownTypes = new Set(KNOWN_SCHEMA_TYPES); + + it('has at least one node to check (fixture sanity)', () => { + expect(types.length).toBeGreaterThan(0); + }); + + it.each(types)('node type %j is a registered component key', (type) => { + expect(knownTypes.has(type)).toBe(true); + }); +}); From 13fe3d1e2bda4b5970a8e307494b6d80144b44c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 20:21:14 +0000 Subject: [PATCH 2/2] fix(examples): drop the hello-world pin test, keep the schema.json fix `@object-ui/example-hello-world` has no `src/` directory, so any test file in it is unconditionally "outside src/" to `scripts/__tests__/check-type-check-coverage.test.ts`'s ledger, which then requires a `tsconfig.test.json` + `type-check` script this example deliberately does not have (objectui#3968's hole). That is exactly the build-setup rider the original dispatch forbade. Drop the test; the schema.json fix stands on its own, observable via `node packages/cli/dist/cli.js check | grep hello-world`. --- examples/hello-world/schema.test.ts | 48 ----------------------------- 1 file changed, 48 deletions(-) delete mode 100644 examples/hello-world/schema.test.ts diff --git a/examples/hello-world/schema.test.ts b/examples/hello-world/schema.test.ts deleted file mode 100644 index dcf6400228..0000000000 --- a/examples/hello-world/schema.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * objectui#5236 — `examples/hello-world/schema.json` is the smallest example - * in the repo, the one a newcomer opens first, and `App.tsx` renders it - * directly (`import schema from './schema.json'` fed to `SchemaRenderer`). - * A node whose `type` is not a registered component key renders the - * OBJUI-001 "Unknown component type" panel instead of the intended UI. - * - * This walks every node in the schema and checks its `type` against - * `KNOWN_SCHEMA_TYPES` — the generated, registration-derived list `objectui - * check` itself uses (`packages/cli/src/utils/known-schema-types.ts`, - * objectui#5115) — rather than restating `page`/`card`/`text`/`button` as - * fossil literals here. That keeps the pin meaningful if the example's node - * types ever change: it fails on any type this repository does not - * register, not just on a diff from today's four values. - */ -import { describe, expect, it } from 'vitest'; - -import { KNOWN_SCHEMA_TYPES } from '../../packages/cli/src/utils/known-schema-types.js'; -import schema from './schema.json'; - -interface SchemaNode { - type?: unknown; - children?: unknown; - [key: string]: unknown; -} - -function collectTypes(node: unknown, out: string[]): void { - if (!node || typeof node !== 'object') return; - const n = node as SchemaNode; - if (typeof n.type === 'string') out.push(n.type); - if (Array.isArray(n.children)) { - for (const child of n.children) collectTypes(child, out); - } -} - -describe('examples/hello-world schema.json', () => { - const types: string[] = []; - collectTypes(schema, types); - const knownTypes = new Set(KNOWN_SCHEMA_TYPES); - - it('has at least one node to check (fixture sanity)', () => { - expect(types.length).toBeGreaterThan(0); - }); - - it.each(types)('node type %j is a registered component key', (type) => { - expect(knownTypes.has(type)).toBe(true); - }); -});