diff --git a/packages/plugin-ui-schema-storage/src/__tests__/action.test.ts b/packages/plugin-ui-schema-storage/src/__tests__/action.test.ts index 26a22a98f..d74ab68ea 100644 --- a/packages/plugin-ui-schema-storage/src/__tests__/action.test.ts +++ b/packages/plugin-ui-schema-storage/src/__tests__/action.test.ts @@ -86,6 +86,22 @@ describe('action test', () => { expect(data.properties.b.properties.c['x-uid']).toEqual('n3'); }); + test('getJsonSchema when uid not exists', async () => { + const response = await app.agent().resource('ui_schemas').getJsonSchema({ + resourceIndex: 'not-exists', + }); + + expect(response.statusCode).toEqual(200); + }); + + test('get properties when uid not exists', async () => { + const response = await app.agent().resource('ui_schemas').getProperties({ + resourceIndex: 'not-exists', + }); + + expect(response.statusCode).toEqual(200); + }); + test('remove', async () => { await app .agent() diff --git a/packages/plugin-ui-schema-storage/src/repository.ts b/packages/plugin-ui-schema-storage/src/repository.ts index e313bc813..b236336d5 100644 --- a/packages/plugin-ui-schema-storage/src/repository.ts +++ b/packages/plugin-ui-schema-storage/src/repository.ts @@ -89,6 +89,10 @@ export class UiSchemaRepository extends Repository { }, }); + if (nodes[0].length == 0) { + return {}; + } + const schema = this.nodesToSchema(nodes[0], uid); return lodash.pick(schema, ['type', 'properties']); } @@ -117,6 +121,10 @@ export class UiSchemaRepository extends Repository { transaction: options?.transaction, }); + if (nodes[0].length == 0) { + return {}; + } + const schema = this.nodesToSchema(nodes[0], uid); return schema; }