Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ValJed committed Dec 10, 2024
1 parent 3fe5a9c commit 52e6290
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion modules/@apostrophecms/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ module.exports = {
}

// Relationship does not support conditional fields right now
if (['array' /*, 'relationship' */].includes(field.type) && field.schema) {
if ([ 'array' /*, 'relationship' */].includes(field.type) && field.schema) {
for (const arrayItem of destination[field.name] || []) {
await getNonVisibleFields({
req,
Expand Down
20 changes: 9 additions & 11 deletions test/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -5078,7 +5078,6 @@ describe('Schemas', function() {
});

it('should not error complex nested arrays required property if parents are not visible', async function() {
const req = apos.task.getReq();
const schema = apos.schema.compose({
addFields: [
{
Expand Down Expand Up @@ -5247,7 +5246,7 @@ describe('Schemas', function() {
},
{
name: 'showRelString',
type: 'boolean',
type: 'boolean'
}
]
}
Expand All @@ -5257,20 +5256,20 @@ describe('Schemas', function() {
const article1 = await apos.article.insert(req, {
...apos.article.newInstance(),
title: 'article 1'
})
});
const article2 = await apos.article.insert(req, {
...apos.article.newInstance(),
title: 'article 2'
})
});

article1._fields = {
showRelString: false
}
};

article2._fields = {
relString: 'article 2 rel string',
showRelString: true
}
};

const data = {
title: 'toto',
Expand All @@ -5280,19 +5279,18 @@ describe('Schemas', function() {
]
};

const errPath = `_rel.${article1._id}.relString`
const output = {};
const [ success, errors ] = await testConvert(apos, data, schema, output);
const foundError = findError(errors, 'relString', 'required');

const expected = {
success: false,
foundError: true
}
};

const actual = {
success,
foundError,
foundError
};

assert.deepEqual(expected, actual);
Expand Down Expand Up @@ -5324,7 +5322,7 @@ async function testConvert(
schema,
output
) {
const req = apos.task.getReq({mode: 'draft'});
const req = apos.task.getReq({ mode: 'draft' });
try {
await apos.schema.convert(req, schema, data, output);
return [ true, [] ];
Expand All @@ -5335,7 +5333,7 @@ async function testConvert(

function findError(errors, fieldPath, errorName) {
if (!Array.isArray(errors)) {
return false
return false;
}
return errors.some((err) => {
if (err.data?.errors) {
Expand Down

0 comments on commit 52e6290

Please sign in to comment.