Add missing changeset and test coverage for PR review gaps
Add changeset for catalog-react blueprint migration. Add tests for cross-style config merge (configSchema + deprecated config.schema), deprecation warning emission, and empty configSchema edge case. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
Migrated alpha entity blueprints to use the new `configSchema` option with direct zod schema values.
|
||||
@@ -334,4 +334,20 @@ describe('createConfigSchema', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('edge cases', () => {
|
||||
it('should handle an empty configSchema', () => {
|
||||
const schema = createConfigSchema({});
|
||||
|
||||
expect(schema.parse({})).toEqual({});
|
||||
expect(schema.parse(undefined)).toEqual({});
|
||||
|
||||
const result = schema.schema();
|
||||
expect(result.schema).toEqual({
|
||||
type: 'object',
|
||||
properties: {},
|
||||
additionalProperties: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -309,6 +309,70 @@ describe('createExtensionBlueprint', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should merge configSchema from blueprint with deprecated config.schema from override', () => {
|
||||
const TestBlueprint = createExtensionBlueprint({
|
||||
kind: 'test-extension',
|
||||
attachTo: { id: 'test', input: 'default' },
|
||||
output: [coreExtensionData.reactElement],
|
||||
configSchema: {
|
||||
title: z => z.string().default('default title'),
|
||||
},
|
||||
factory(_, { config }) {
|
||||
return [coreExtensionData.reactElement(<div>{config.title}</div>)];
|
||||
},
|
||||
});
|
||||
|
||||
const extension = TestBlueprint.makeWithOverrides({
|
||||
name: 'my-extension',
|
||||
config: {
|
||||
schema: {
|
||||
extra: z => z.string(),
|
||||
},
|
||||
},
|
||||
factory(origFactory, { config }) {
|
||||
expect(config.title).toBe('default title');
|
||||
expect(config.extra).toBe('extra value');
|
||||
return origFactory({});
|
||||
},
|
||||
});
|
||||
|
||||
expect.assertions(2);
|
||||
|
||||
renderInTestApp(
|
||||
createExtensionTester(extension, {
|
||||
config: { extra: 'extra value' },
|
||||
}).reactElement(),
|
||||
);
|
||||
});
|
||||
|
||||
it('should emit a deprecation warning when using config.schema', () => {
|
||||
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
try {
|
||||
createExtension({
|
||||
name: 'test-deprecated-warning',
|
||||
attachTo: { id: 'test', input: 'default' },
|
||||
output: [coreExtensionData.reactElement],
|
||||
config: {
|
||||
schema: {
|
||||
title: z => z.string().default('hello'),
|
||||
},
|
||||
},
|
||||
factory() {
|
||||
return [coreExtensionData.reactElement(<div />)];
|
||||
},
|
||||
});
|
||||
|
||||
expect(warnSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
'DEPRECATION WARNING: The `config.schema` option for extension config is deprecated',
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
warnSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow getting inputs properly', () => {
|
||||
createExtensionBlueprint({
|
||||
kind: 'test-extension',
|
||||
|
||||
Reference in New Issue
Block a user