Skip to content

Commit

Permalink
fixup! fix(core): field ui-options higher priority
Browse files Browse the repository at this point in the history
  • Loading branch information
shaddollxz committed Jun 5, 2024
1 parent 6bdc3a4 commit 37f3e61
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
26 changes: 0 additions & 26 deletions packages/core/test/SchemaField.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,6 @@ describe('SchemaField', () => {
globalUiOptions: { copyable: true },
});
});
it('should provide expected registry with field option first', () => {
let receivedProps;
const schema = {
type: 'object',
properties: {
a: { type: 'string' },
},
};

createFormComponent({
schema,
uiSchema: {
'ui:globalOptions': { readonly: true },
a: {
'ui:readonly': false,
'ui:widget': (props) => {
receivedProps = props;
return null;
},
},
},
});

const { readonly } = receivedProps;
expect(readonly).eql(false);
});
});

describe('Unsupported field', () => {
Expand Down
38 changes: 32 additions & 6 deletions packages/core/test/uiSchema.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2505,9 +2505,7 @@ describe('uiSchema', () => {
});

describe('ObjectField', () => {
let node;

beforeEach(() => {
it('should mark as readonly an ObjectField', () => {
const schema = {
type: 'object',
properties: {
Expand All @@ -2523,13 +2521,41 @@ describe('uiSchema', () => {
const uiSchema = {};

let rendered = createFormComponent({ schema, uiSchema });
node = rendered.node;
});
const node = rendered.node;

it('should mark as readonly an ObjectField', () => {
const disabled = [].map.call(node.querySelectorAll('[type=text]'), (node) => node.hasAttribute('readonly'));
expect(disabled).eql([true, true]);
});

it('should not mark as readonly even if globalOptions set readonly', () => {
const schema = {
type: 'object',
properties: {
foo: {
type: 'string',
},
bar: {
type: 'string',
},
},
readOnly: true,
};

const uiSchema = {
'ui:globalOptions': {
readonly: true,
},
foo: {
'ui:readonly': false,
},
};

let rendered = createFormComponent({ schema, uiSchema });
const node = rendered.node;

const disabled = [].map.call(node.querySelectorAll('[type=text]'), (node) => node.hasAttribute('readonly'));
expect(disabled).eql([false, true]);
});
});
});

Expand Down

0 comments on commit 37f3e61

Please sign in to comment.