frontend-app-api: list candidate inputs in undeclared input warning

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-01-12 17:49:22 +01:00
parent 074dfe37b0
commit 4780af8e15
2 changed files with 14 additions and 8 deletions
@@ -475,7 +475,7 @@ describe('createAppNodeInstance', () => {
);
expect(warn).toEqual([
"The extension 'app/test' is attached to the input 'undeclared' of 'app/parent', but the extension 'app/parent' noes not declare a 'undeclared' input",
"The extension 'app/test' is attached to the input 'undeclared' of the extension 'app/parent', but it has no such input (candidates are 'declared')",
]);
});
@@ -510,8 +510,8 @@ describe('createAppNodeInstance', () => {
);
expect(warn).toEqual([
"The extension 'app/test' is attached to the input 'undeclared1' of 'app/parent', but the extension 'app/parent' noes not declare a 'undeclared1' input",
"The extensions 'app/test', 'app/test' are attached to the input 'undeclared2' of 'app/parent', but the extension 'app/parent' noes not declare a 'undeclared2' input",
"The extension 'app/test' is attached to the input 'undeclared1' of the extension 'app/parent', but it has no inputs",
"The extensions 'app/test', 'app/test' are attached to the input 'undeclared2' of the extension 'app/parent', but it has no inputs",
]);
});
@@ -55,15 +55,21 @@ function resolveInputs(
);
if (process.env.NODE_ENV !== 'production') {
const inputNames = Object.keys(inputMap);
for (const [name, nodes] of undeclaredAttachments) {
const pl = nodes.length > 1;
// eslint-disable-next-line no-console
console.warn(
`The extension${pl ? 's' : ''} '${nodes
.map(n => n.spec.id)
.join("', '")}' ${
pl ? 'are' : 'is'
} attached to the input '${name}' of '${id}', but the extension '${id}' noes not declare a '${name}' input`,
[
`The extension${pl ? 's' : ''} '${nodes
.map(n => n.spec.id)
.join("', '")}' ${pl ? 'are' : 'is'}`,
`attached to the input '${name}' of the extension '${id}', but it`,
inputNames.length === 0
? 'has no inputs'
: `has no such input (candidates are '${inputNames.join("', '")}')`,
].join(' '),
);
}
}