Skip to content

Add test environment configuration to plugin packages#315

Merged
hotlong merged 8 commits intocopilot/upgrade-objectstack-core-packagefrom
copilot/fix-step-8-error
Feb 1, 2026
Merged

Add test environment configuration to plugin packages#315
hotlong merged 8 commits intocopilot/upgrade-objectstack-core-packagefrom
copilot/fix-step-8-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

CI failing on @object-ui/plugin-form#test with ReferenceError: document is not defined. Seven plugin packages have tests but their vite configs lack DOM environment setup.

Changes

Added test configuration block to vite.config.ts in plugin packages with tests:

test: {
  globals: true,
  environment: 'happy-dom',
  setupFiles: ['../../vitest.setup.ts'],
  passWithNoTests: true,
}

Affected packages:

  • plugin-form
  • plugin-aggrid
  • plugin-charts
  • plugin-editor
  • plugin-grid
  • plugin-kanban
  • plugin-markdown

This aligns with the existing configuration in @object-ui/components and @object-ui/fields.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21559929720/job/62122583933#step:8:1


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 1, 2026

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 1, 2026 10:35am
objectui-components Ready Ready Preview, Comment Feb 1, 2026 10:35am
objectui-crm-app Ready Ready Preview, Comment Feb 1, 2026 10:35am

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI and others added 6 commits February 1, 2026 09:43
Add manual re-registration of text component to override field widget

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>
Move {...props} before explicit props to allow proper overriding

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@github-actions github-actions Bot added the apps label Feb 1, 2026
@hotlong hotlong marked this pull request as ready for review February 1, 2026 10:16
Copilot AI review requested due to automatic review settings February 1, 2026 10:16
@hotlong hotlong merged commit 3ac0983 into copilot/upgrade-objectstack-core-package Feb 1, 2026
2 of 6 checks passed
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

Addresses CI failures caused by Vitest running in a non-DOM environment by aligning plugin package test configuration with existing workspace defaults; also includes unrelated updates to field widgets and the console Vitest setup.

Changes:

  • Added Vitest environment: 'happy-dom' + shared setupFiles to plugin packages with tests.
  • Updated multiple @object-ui/fields widgets to spread remaining props into the underlying inputs/selects.
  • Reworked apps/console Vitest setup (migrated setup file to .tsx and updated Vite config).

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
packages/plugin-markdown/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-kanban/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-grid/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-form/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-editor/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-charts/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/plugin-aggrid/vite.config.ts Adds Vitest DOM environment + shared setup file.
packages/fields/src/widgets/UrlField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/TimeField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/TextField.tsx Starts forwarding extra props into <Textarea> / <Input>.
packages/fields/src/widgets/TextAreaField.tsx Starts forwarding extra props into the underlying <Textarea>.
packages/fields/src/widgets/SelectField.tsx Starts forwarding extra props into the <Select>.
packages/fields/src/widgets/PhoneField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/PercentField.tsx Starts forwarding extra props into the underlying <Input> and adjusts className handling.
packages/fields/src/widgets/PasswordField.tsx Starts forwarding extra props into the underlying <Input> and adjusts className handling.
packages/fields/src/widgets/NumberField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/EmailField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/DateTimeField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/DateField.tsx Starts forwarding extra props into the underlying <Input>.
packages/fields/src/widgets/CurrencyField.tsx Continues forwarding extra props into the underlying <Input> while adjusting className handling.
packages/fields/src/widgets/BooleanField.tsx Starts forwarding extra props into <Checkbox> / <Switch>.
apps/console/vitest.setup.tsx New TSX-based Vitest setup with custom registry overrides.
apps/console/vitest.setup.ts Removes prior Vitest setup entrypoint.
apps/console/vite.config.ts Points Vitest setupFiles to the new .tsx setup file.

if (rows && rows > 1) {
return (
<Textarea
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

This spread will include a schema object when the widget is rendered via the form renderer’s registry path; passing it through to <Textarea> will forward an object-valued schema attribute to the DOM. Strip schema (and other non-DOM props) before spreading, and apply the same fix to the <Input> branch in this component as well.

Copilot uses AI. Check for mistakes.

return (
<Input
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props will include the schema object coming from the form renderer; spreading it onto <Input> forwards an object-valued schema attribute to the underlying DOM input. Please omit schema (and other non-DOM props) from the spread before passing props to <Input>.

Copilot uses AI. Check for mistakes.

return (
<Select
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The form renderer passes schema (an object) into registered field widgets; spreading ...props here will forward that object as a schema prop into the Radix/Shadcn <Select> tree (and potentially to the DOM). Strip schema out before spreading, and only forward supported Select props.

Copilot uses AI. Check for mistakes.
return (
<div className="flex items-center space-x-2">
<Checkbox
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props will contain the form-renderer schema object; spreading it onto <Checkbox> / <Switch> can leak an object-valued schema prop into the Radix tree (and potentially to the DOM). Destructure schema out before spreading (apply for both checkbox and switch branches).

Copilot uses AI. Check for mistakes.

return (
<Input
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props currently includes a schema object (passed by the form renderer via <RegisteredComponent schema={props} {...props} />). Spreading it onto <Input> will forward an object-valued schema attribute to the DOM (React warnings / invalid markup). Destructure schema (and any other non-DOM props) out before spreading, and only pass safe input props to <Input>.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +5
import '@testing-library/jest-dom';
import React from 'react';
import '@object-ui/fields'; // Import fields first
import '@object-ui/plugin-dashboard'; // Import to register dashboard components
import '@object-ui/plugin-grid'; // Import to register grid components
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The PR description focuses on adding Vitest DOM environment config for plugin packages, but this PR also includes changes to field widgets and the console’s Vitest setup. If these are required for the CI fix, please document why; otherwise consider splitting these into a separate PR to keep scope focused.

Copilot uses AI. Check for mistakes.
return (
<div className="relative">
<Textarea
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props may contain a schema object from the form renderer; spreading it onto <Textarea> will forward an object-valued schema attribute to the DOM. Destructure schema out before spreading and only pass valid textarea props.

Copilot uses AI. Check for mistakes.
return (
<div className="relative">
<Input
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props here can include the form-renderer schema object; spreading it onto <Input> forwards an object-valued schema attribute to the DOM input. Destructure schema out before spreading, and only forward valid input props.

Copilot uses AI. Check for mistakes.

return (
<Input
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

...props includes the form-renderer schema object; spreading it onto <Input> will forward an object-valued schema attribute to the DOM. Please omit schema from the spread before passing props to <Input>.

Copilot uses AI. Check for mistakes.

return (
<Input
{...props}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Spreading ...props onto <Input> will forward the form-renderer schema object as an object-valued schema attribute on the DOM input. Destructure schema out before spreading to <Input>.

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