frontend-plugin-api: clean up error messages for input overrides

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-08-11 20:04:48 +02:00
parent cea81165f4
commit 3d7d38d94f
3 changed files with 13 additions and 13 deletions
@@ -969,7 +969,7 @@ describe('createExtension', () => {
.add(multi2Ext)
.data(outputRef),
).toThrowErrorMatchingInlineSnapshot(
`"Failed to instantiate extension 'subject', Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`,
`"Failed to instantiate extension 'subject', override data provided for input 'multi' must match the length of the original inputs"`,
);
// Required input not provided
@@ -992,7 +992,7 @@ describe('createExtension', () => {
.add(multi2Ext)
.data(outputRef),
).toThrowErrorMatchingInlineSnapshot(
`"Failed to instantiate extension 'subject', Missing required data values for 'test1'"`,
`"Failed to instantiate extension 'subject', missing required extension data value(s) 'test1'"`,
);
// Wrong value provided
@@ -1021,7 +1021,7 @@ describe('createExtension', () => {
.add(multi2Ext)
.data(outputRef),
).toThrowErrorMatchingInlineSnapshot(
`"Failed to instantiate extension 'subject', Invalid data value provided, 'test2' was not declared"`,
`"Failed to instantiate extension 'subject', extension data 'test2' was provided but not declared"`,
);
});
});
@@ -462,7 +462,7 @@ describe('createExtensionBlueprint', () => {
mockParentInputs,
),
).toThrowErrorMatchingInlineSnapshot(
`"Invalid override provided for input 'multi', when overriding the input data the length must match the original input data"`,
`"override data provided for input 'multi' must match the length of the original inputs"`,
);
// Required input not provided
@@ -484,7 +484,7 @@ describe('createExtensionBlueprint', () => {
mockParentInputs,
),
).toThrowErrorMatchingInlineSnapshot(
`"Missing required data values for 'test1'"`,
`"missing required extension data value(s) 'test1'"`,
);
// Wrong value provided
@@ -512,7 +512,7 @@ describe('createExtensionBlueprint', () => {
mockParentInputs,
),
).toThrowErrorMatchingInlineSnapshot(
`"Invalid data value provided, 'test2' was not declared"`,
`"extension data 'test2' was provided but not declared"`,
);
// Forwarding entire inputs object
@@ -706,7 +706,7 @@ describe('createExtensionBlueprint', () => {
}).makeWithOverrides({ factory: orig => orig({}) }),
),
).toThrowErrorMatchingInlineSnapshot(
`"Invalid data value provided, 'test2' was not declared"`,
`"extension data 'test2' was provided but not declared"`,
);
expect(() =>
@@ -722,7 +722,7 @@ describe('createExtensionBlueprint', () => {
}).makeWithOverrides({ factory: orig => orig({}) }),
),
).toThrowErrorMatchingInlineSnapshot(
`"Missing required data values for 'test1'"`,
`"missing required extension data value(s) 'test1'"`,
);
});
@@ -269,7 +269,7 @@ export function createDataContainer<UData extends AnyExtensionDataRef>(
if (verifyRefs) {
if (!verifyRefs.delete(output.id)) {
throw new Error(
`Invalid data value provided, '${output.id}' was not declared`,
`extension data '${output.id}' was provided but not declared`,
);
}
}
@@ -281,7 +281,7 @@ export function createDataContainer<UData extends AnyExtensionDataRef>(
Array.from(verifyRefs.values()).filter(ref => !ref.config.optional);
if (remainingRefs && remainingRefs.length > 0) {
throw new Error(
`Missing required data values for '${remainingRefs
`missing required extension data value(s) '${remainingRefs
.map(ref => ref.id)
.join(', ')}'`,
);
@@ -339,7 +339,7 @@ export function resolveInputOverrides(
);
if (!originalInput) {
throw new Error(
`A data override was provided for input '${name}', but no original input was present.`,
`attempted to override data of input '${name}' but it is not present in the original inputs`,
);
}
newInputs[name] = Object.assign(providedContainer, {
@@ -350,12 +350,12 @@ export function resolveInputOverrides(
const originalInput = expectArray(inputs[name]);
if (!Array.isArray(providedData)) {
throw new Error(
`Invalid override provided for input '${name}', expected an array`,
`override data provided for input '${name}' must be an array`,
);
}
if (originalInput.length !== providedData.length) {
throw new Error(
`Invalid override provided for input '${name}', when overriding the input data the length must match the original input data`,
`override data provided for input '${name}' must match the length of the original inputs`,
);
}
newInputs[name] = providedData.map((data, i) => {