Skip to content

Fix component registry initialization for coverage tests#330

Merged
hotlong merged 12 commits intomainfrom
copilot/fix-action-run-step-error
Feb 2, 2026
Merged

Fix component registry initialization for coverage tests#330
hotlong merged 12 commits intomainfrom
copilot/fix-action-run-step-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 2, 2026

CI coverage tests were failing with "Unknown component type: div" in ServerDefinitions.test.tsx because the root vitest setup wasn't registering components.

Changes

  • Unified test setup: Renamed vitest.setup.tsvitest.setup.tsx and added component registration imports (@object-ui/components, @object-ui/fields, plugins)
  • Added package aliases: Extended vitest.config.mts with missing aliases (@object-ui/core, @object-ui/types, @object-ui/react, field/plugin packages)
  • Consolidated configs: Updated apps/console/vite.config.ts to reference root setup; removed redundant apps/console/vitest.setup.tsx

The root setup file now handles component registration for all test runs (both regular and coverage), ensuring the component registry is populated before tests execute.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21578281993/job/62170200265#step:9:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 2, 2026 7:42am
objectui-components Ready Ready Preview, Comment Feb 2, 2026 7:42am
objectui-crm-app Error Error Feb 2, 2026 7:42am

Request Review

… setup

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix action run step error in workflow Fix component registry initialization for coverage tests Feb 2, 2026
Copilot AI requested a review from hotlong February 2, 2026 05:43
@github-actions github-actions Bot added the apps label Feb 2, 2026
Copilot AI and others added 9 commits February 2, 2026 05:51
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review February 2, 2026 07:33
Copilot AI review requested due to automatic review settings February 2, 2026 07:33
@hotlong hotlong merged commit fee1558 into main Feb 2, 2026
11 of 16 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

📦 Bundle Size Report

Package Size Gzipped
components (index.js) 1765.36KB 417.25KB
core (index.js) 0.63KB 0.30KB
create-plugin (index.js) 9.28KB 2.98KB
data-objectstack (index.js) 16.99KB 4.48KB
fields (index.js) 87.09KB 17.11KB
layout (index.js) 12.79KB 3.96KB
plugin-aggrid (AgGridImpl-BQ6tBvrq.js) 5.27KB 1.92KB
plugin-aggrid (ObjectAgGridImpl-CGFeGvOH.js) 11.44KB 3.52KB
plugin-aggrid (index-CLKYMco3.js) 19.20KB 4.89KB
plugin-aggrid (index.js) 0.22KB 0.16KB
plugin-calendar (index.js) 33.29KB 8.32KB
plugin-charts (AdvancedChartImpl-Cyae7QYH.js) 69.51KB 16.23KB
plugin-charts (BarChart-RKJxvg5Y.js) 535.74KB 134.11KB
plugin-charts (ChartImpl-CrYQhLTB.js) 8.78KB 3.11KB
plugin-charts (index-BGwsUQF8.js) 12.68KB 3.91KB
plugin-charts (index.js) 0.21KB 0.16KB
plugin-chatbot (index.js) 18.39KB 5.22KB
plugin-dashboard (index.js) 11.99KB 3.82KB
plugin-editor (MonacoImpl-hfdmoz6k.js) 18.15KB 5.59KB
plugin-editor (index-CuYbY6xb.js) 10.10KB 3.32KB
plugin-editor (index.js) 0.19KB 0.15KB
plugin-form (index.js) 15.21KB 4.91KB
plugin-gantt (index.js) 18.13KB 5.29KB
plugin-grid (index.js) 40.64KB 11.25KB
plugin-kanban (KanbanImpl-kbzXvR7a.js) 76.50KB 20.46KB
plugin-kanban (index-4iNpG2-h.js) 11.89KB 3.68KB
plugin-kanban (index.js) 0.18KB 0.15KB
plugin-map (index.js) 16.78KB 5.12KB
plugin-markdown (MarkdownImpl-9F_xYhwR.js) 256.79KB 64.50KB
plugin-markdown (index-DZS4FNIJ.js) 9.63KB 3.17KB
plugin-markdown (index.js) 0.19KB 0.15KB
plugin-timeline (index.js) 25.86KB 6.70KB
plugin-view (index.js) 16.69KB 4.93KB
react (LazyPluginLoader.js) 1.10KB 0.58KB
react (SchemaRenderer.js) 3.02KB 1.21KB
react (index.js) 0.39KB 0.25KB
react (index.test.js) 0.34KB 0.26KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 0.20KB 0.18KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (disclosure.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (index.js) 0.34KB 0.25KB
types (layout.js) 0.20KB 0.18KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 0.20KB 0.18KB
types (views.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes CI coverage failures caused by an uninitialized component registry by ensuring a single, shared Vitest setup runs for all test modes (including coverage) and that workspace package imports resolve correctly during tests.

Changes:

  • Switched all Vitest configs to use the root vitest.setup.tsx and removed the old root vitest.setup.ts.
  • Added/expanded Vite/Vitest resolve.alias entries across the repo so @object-ui/* packages resolve to workspace source during tests.
  • Updated a couple of field widgets and a test file (non-registry-related changes).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vitest.setup.tsx Centralized test setup: side-effect imports to register components + ResizeObserver polyfill.
vitest.setup.ts Removed legacy root setup file now replaced by .tsx.
vitest.config.mts Points setup to vitest.setup.tsx and adds missing @object-ui/* aliases for test resolution.
packages/plugin-timeline/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/plugin-markdown/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/plugin-kanban/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/plugin-grid/vite.config.ts Updates aliases to point at package source dirs + uses root setup .tsx.
packages/plugin-form/vite.config.ts Updates aliases to point at package source dirs + uses root setup .tsx.
packages/plugin-editor/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/plugin-charts/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/plugin-aggrid/vite.config.ts Aligns test setup file path and adds workspace aliases for tests/build.
packages/fields/vite.config.ts Adds aliases (including self-alias) and uses root vitest.setup.tsx for tests.
packages/fields/src/widgets/ObjectField.tsx Changes internal JSON string initialization/sync behavior for the ObjectField widget.
packages/fields/src/widgets/BooleanField.tsx Replaces randomized id generation with useId() for BooleanField.
packages/fields/src/standard-widgets.test.tsx Minor cleanup in a widget test.
packages/components/vite.config.ts Adds aliases (including self-alias) and uses root vitest.setup.tsx for tests.
apps/console/vite.config.ts Points console tests at the root vitest.setup.tsx instead of a local setup file.

Comment on lines +38 to +42
// Fallback if internal state was invalid JSON
// eslint-disable-next-line react-hooks/set-state-in-effect -- Required for controlled component sync
setJsonString(JSON.stringify(value, null, 2));
}
}, [value]);
}, [value, jsonString]);
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The effect depends on jsonString and also calls setJsonString(...). This makes the sync effect run on every keystroke, and when the user temporarily types invalid JSON (so value doesn’t update), the catch path will immediately reset the textarea back to JSON.stringify(value, ...), preventing users from correcting invalid intermediate states and potentially causing extra renders.

Consider making this effect run only when value changes (and explicitly opting out of exhaustive-deps), or refactor to avoid reading jsonString from the effect dependency list (e.g., keep a ref of the last successfully-parsed value/string) so local editing isn’t overwritten.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to 12
import React, { useId } from 'react';
import { Switch, Checkbox, Label } from '@object-ui/components';
import { FieldWidgetProps } from './types';

export function BooleanField({ value, onChange, field, readonly, ...props }: FieldWidgetProps<boolean>) {
if (readonly) {
return <span className="text-sm">{value ? 'Yes' : 'No'}</span>;
}

const config = (field || (props as any).schema) as any;
// Use simple type assertion for arbitrary custom properties not in BaseFieldMetadata
const widget = config?.widget;
const id = config?.name || `boolean-field-${Math.random().toString(36).substr(2, 9)}`;
// Generate unique ID using React's useId hook - must be before early returns (rules of hooks)
const generatedId = useId();
const id = config?.name || generatedId;
const label = config?.label || 'Checkbox';
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is described as fixing component registry initialization for coverage tests, but it also changes runtime field widget behavior (ObjectField state sync logic and BooleanField id generation). These look orthogonal to the test/registry issue and make the change set harder to reason about/revert.

If they’re not strictly required to fix the coverage failure, consider moving the widget changes into a separate PR (or explicitly calling out why they’re needed here).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants