@@ -6,6 +6,8 @@ import { setupServer } from 'msw/node';
66import { http , HttpResponse } from 'msw' ;
77import { registerAllFields } from '@object-ui/fields' ;
88import React from 'react' ;
9+ // @ts -ignore - Import from examples
10+ import { ContactObject } from '../../../examples/crm/src/objects/contact.object' ;
911
1012// Register widget renderers
1113registerAllFields ( ) ;
@@ -14,35 +16,13 @@ const BASE_URL = 'http://test-api.com';
1416
1517// --- Mock Data ---
1618
17- const mockSchema = {
18- name : 'contact' ,
19- label : 'Contact' ,
20- fields : {
21- name : {
22- type : 'text' ,
23- label : 'Full Name' ,
24- required : true
25- } ,
26- email : {
27- type : 'email' ,
28- label : 'Email Address'
29- } ,
30- status : {
31- type : 'select' ,
32- label : 'Status' ,
33- options : [
34- { label : 'Active' , value : 'active' } ,
35- { label : 'Inactive' , value : 'inactive' }
36- ]
37- }
38- }
39- } ;
19+ const mockSchema = ContactObject ;
4020
4121const mockRecord = {
4222 _id : 'rec_123' ,
4323 name : 'Alice Smith' ,
4424 email : 'alice@example.com' ,
45- status : 'active '
25+ status : 'Customer '
4626} ;
4727
4828// --- MSW Setup ---
@@ -114,9 +94,10 @@ describe('ObjectForm with ObjectStack/MSW', () => {
11494
11595 // Verify fields appear (async as schema loads via HTTP)
11696 await waitFor ( ( ) => {
117- expect ( screen . getByText ( 'Full Name' ) ) . toBeInTheDocument ( ) ;
97+ // Changed from 'Full Name' to 'Name' based on CRM example schema
98+ expect ( screen . getByText ( 'Name' ) ) . toBeInTheDocument ( ) ;
11899 } ) ;
119- expect ( screen . getByText ( 'Email Address ' ) ) . toBeInTheDocument ( ) ;
100+ expect ( screen . getByText ( 'Email' ) ) . toBeInTheDocument ( ) ;
120101 expect ( screen . getByText ( 'Status' ) ) . toBeInTheDocument ( ) ;
121102 } ) ;
122103
@@ -135,9 +116,11 @@ describe('ObjectForm with ObjectStack/MSW', () => {
135116
136117 // Initial load of schema logic + data fetch
137118 await waitFor ( ( ) => {
138- expect ( screen . getByRole ( 'textbox' , { name : / F u l l N a m e / i } ) ) . toHaveValue ( 'Alice Smith' ) ;
119+ // Changed from 'Full Name' to 'Name'
120+ expect ( screen . getByRole ( 'textbox' , { name : / N a m e / i } ) ) . toHaveValue ( 'Alice Smith' ) ;
139121 } , { timeout : 2000 } ) ; // Give slight buffer for network mock
140122
141- expect ( screen . getByRole ( 'textbox' , { name : / E m a i l A d d r e s s / i } ) ) . toHaveValue ( 'alice@example.com' ) ;
123+ // Changed from 'Email Address' to 'Email'
124+ expect ( screen . getByRole ( 'textbox' , { name : / E m a i l / i } ) ) . toHaveValue ( 'alice@example.com' ) ;
142125 } ) ;
143126} ) ;
0 commit comments