fix: ui schema storage (#188)

* fix: test

* chore: root schema x-index

* fix: getJsonSchema & getProperties empty response
This commit is contained in:
ChengLei Shao 2022-02-13 10:36:25 +08:00 committed by GitHub
parent 2e2b5cd938
commit 8a791f37aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -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()

View File

@ -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;
}