Skip to content

Commit eeedb57

Browse files
committed
test(app-shell): parse the held field rule through the rule schema; read transition keys directly
Claude-Session: https://claude.ai/code/session_01JQwxbaA4X9WGDi4ZgwZ4PZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 66b10ee commit eeedb57

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎ui/packages/app-shell/src/views/studio-design/ObjectValidationsPanel.newRuleComplete-26731.test.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as React from 'react';
3333
import { describe, it, expect, vi, afterEach } from 'vitest';
3434
import { render, screen, fireEvent, cleanup, within } from '@testing-library/react';
3535
import { I18nProvider, createI18n } from '@object-ui/i18n';
36-
import { ObjectSchema } from '@objectstack/spec/data';
36+
import { ValidationRuleSchema } from '@objectstack/spec/data';
3737

3838
import { ObjectValidationsPanel } from './ObjectValidationsPanel';
3939
import { t } from '../metadata-admin/i18n';
@@ -130,7 +130,8 @@ describe('a new field rule waits for its field and message (objectstack#26731)',
130130
events: ['insert', 'update'],
131131
});
132132
expect(written[1].field).not.toBe('created_at');
133-
expect(ObjectSchema.safeParse({ ...baseDraft, validations: written }).success).toBe(true);
133+
// The rule the pillar would save parses through the spec's own rule schema.
134+
expect(ValidationRuleSchema.safeParse(written[1]).success).toBe(true);
134135

135136
// Written, it is an ordinary rule.
136137
expect(screen.queryByTestId('rule-unsaved')).toBeNull();
@@ -200,7 +201,7 @@ describe('an empty transition row is not stored (objectstack#26731)', () => {
200201
expect(onPatch).toHaveBeenCalledTimes(1);
201202
const written = lastValidations(onPatch)[0];
202203
expect(written.transitions).toEqual({ open: ['closed'], closed: ['open'] });
203-
expect(written.transitions).not.toHaveProperty('');
204+
expect(Object.keys(written.transitions as object)).not.toContain('');
204205
// The row it became is the one the author is typing in.
205206
expect(screen.getAllByPlaceholderText(t('engine.studio.rules.transitionFrom', 'en-US'))[1]).toHaveValue('closed');
206207
});

0 commit comments

Comments
 (0)