Skip to content

Commit

Permalink
2172: update transformer validation to accept no transformer when int…
Browse files Browse the repository at this point in the history
…ernalScopes includes graphic scope
  • Loading branch information
ThieryMichel committed Dec 19, 2024
1 parent 9265055 commit 147de20
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/common/validateFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export const validateTransformers = (field, isContribution) => {
isValid: true,
};

if (isContribution || field.scope === SCOPE_GRAPHIC || field.composedOf) {
if (
isContribution ||
field.scope === SCOPE_GRAPHIC ||
field.internalScopes?.includes(SCOPE_GRAPHIC) ||
field.composedOf
) {
return result;
}

Expand Down
38 changes: 38 additions & 0 deletions src/common/validateFields.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,44 @@ describe('validateField', () => {
error: 'required',
});
});

it('should return valid result if no transformers and scope is graphic', () => {
expect(
validateTransformers({
scope: SCOPE_GRAPHIC,
}),
).toEqual({
name: 'transformers',
isValid: true,
});
});

it('should return valid result if no transformers and internalScopes include graphic', () => {
expect(
validateTransformers({
internalScopes: [SCOPE_DOCUMENT, SCOPE_GRAPHIC],
}),
).toEqual({
name: 'transformers',
isValid: true,
});
});

it('should return valid result if no transformers and isContribution is true', () => {
expect(validateTransformers({}, true)).toEqual({
name: 'transformers',
isValid: true,
});
});

it('should return valid result if no transformers and composedOf is set', () => {
expect(
validateTransformers({ composedOf: ['field1', 'field2'] }),
).toEqual({
name: 'transformers',
isValid: true,
});
});
});

describe('validateTransformer', () => {
Expand Down

0 comments on commit 147de20

Please sign in to comment.