Skip to content

Commit 75ee3ee

Browse files
committed
Update tests to verify widget title counts and adjust contact name in MSW tests; enhance form reset behavior on defaultValues change
1 parent 7b4cb01 commit 75ee3ee

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

apps/console/src/__tests__/Dashboard.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ describe('Dashboard MSW Integration', () => {
5353
render(<DashboardRenderer schema={schema} />);
5454

5555
// Check that widget titles are rendered
56-
expect(screen.getByText('Total Contacts')).toBeInTheDocument();
57-
expect(screen.getByText('Active Contacts')).toBeInTheDocument();
56+
expect(screen.getAllByText('Total Contacts')).toHaveLength(2);
57+
expect(screen.getAllByText('Active Contacts')).toHaveLength(1);
5858
});
5959

6060
it('should render dashboard with different column configurations', async () => {

apps/console/src/__tests__/MSWServer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('MSW Server Integration', () => {
2424
// Check that initial data was loaded
2525
const contacts = await driver!.find('contact', { object: 'contact' });
2626
expect(contacts).toHaveLength(3);
27-
expect(contacts[0].name).toBe('John Doe');
27+
expect(contacts[0].name).toBe('Alice Johnson');
2828
});
2929

3030
it('should create a new contact via driver', async () => {

apps/console/src/__tests__/ObjectFormUnit.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ describe('ObjectForm Unit Tests', () => {
368368
expect(emailInput).toHaveAttribute('type', 'email');
369369

370370
// Verify Boolean (Switch/Checkbox)
371-
expect(screen.getByText('Boolean Type')).toBeInTheDocument();
371+
expect(screen.getAllByText('Boolean Type').length).toBeGreaterThan(0);
372372
const switchControl = screen.getByRole('switch', { name: 'Boolean Type' });
373373
expect(switchControl).toBeInTheDocument();
374374
});

apps/console/src/__tests__/ServerDefinitions.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ describe('Server-Driven Definitions', () => {
307307
render(<SchemaRenderer schema={complexPage} />);
308308

309309
expect(screen.getByText('CRM Dashboard')).toBeInTheDocument();
310-
expect(screen.getByText('Total Contacts')).toBeInTheDocument();
311-
expect(screen.getByText('Active')).toBeInTheDocument();
310+
expect(screen.getAllByText('Total Contacts')).toHaveLength(1);
311+
expect(screen.getAllByText('Active')).toHaveLength(2);
312312
});
313313
});
314314

packages/components/src/renderers/form/form.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ ComponentRegistry.register('form',
5656
const [isSubmitting, setIsSubmitting] = React.useState(false);
5757
const [submitError, setSubmitError] = React.useState<string | null>(null);
5858

59+
// React to defaultValues changes
60+
React.useEffect(() => {
61+
form.reset(defaultValues);
62+
}, [defaultValues]);
63+
5964
// Watch for form changes - only track changes when onAction is available
6065
React.useEffect(() => {
6166
if (onAction) {

0 commit comments

Comments
 (0)