parent
51ca12cc87
commit
2e2b5cd938
@ -1,13 +1,13 @@
|
|||||||
import { mockServer, MockServer } from '@nocobase/test';
|
import { mockServer, MockServer } from '@nocobase/test';
|
||||||
import { Database } from '@nocobase/database';
|
import { Database } from '@nocobase/database';
|
||||||
import PluginUiSchema, { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage';
|
import UiSchemaStoragePlugin, { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage';
|
||||||
import PluginCollectionManager from '@nocobase/plugin-collection-manager';
|
import PluginCollectionManager from '@nocobase/plugin-collection-manager';
|
||||||
|
|
||||||
describe('server hooks', () => {
|
describe('server hooks', () => {
|
||||||
let app: MockServer;
|
let app: MockServer;
|
||||||
let db: Database;
|
let db: Database;
|
||||||
let uiSchemaRepository: UiSchemaRepository;
|
let uiSchemaRepository: UiSchemaRepository;
|
||||||
let uiSchemaPlugin: PluginUiSchema;
|
let uiSchemaPlugin: UiSchemaStoragePlugin;
|
||||||
|
|
||||||
const schema = {
|
const schema = {
|
||||||
'x-uid': 'root',
|
'x-uid': 'root',
|
||||||
@ -61,7 +61,7 @@ describe('server hooks', () => {
|
|||||||
db = app.db;
|
db = app.db;
|
||||||
|
|
||||||
await app.cleanDb();
|
await app.cleanDb();
|
||||||
app.plugin(PluginUiSchema);
|
app.plugin(UiSchemaStoragePlugin);
|
||||||
app.plugin(PluginCollectionManager);
|
app.plugin(PluginCollectionManager);
|
||||||
|
|
||||||
await app.loadAndInstall();
|
await app.loadAndInstall();
|
||||||
@ -69,7 +69,7 @@ describe('server hooks', () => {
|
|||||||
uiSchemaRepository = db.getRepository('ui_schemas');
|
uiSchemaRepository = db.getRepository('ui_schemas');
|
||||||
await uiSchemaRepository.insert(schema);
|
await uiSchemaRepository.insert(schema);
|
||||||
|
|
||||||
uiSchemaPlugin = app.getPlugin<PluginUiSchema>('PluginUiSchema');
|
uiSchemaPlugin = app.getPlugin<UiSchemaStoragePlugin>('UiSchemaStoragePlugin');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call server hooks onFieldDestroy', async () => {
|
it('should call server hooks onFieldDestroy', async () => {
|
||||||
|
@ -78,7 +78,6 @@ describe('ui schema model', () => {
|
|||||||
name: 'root-node',
|
name: 'root-node',
|
||||||
'x-uid': 'root-uid',
|
'x-uid': 'root-uid',
|
||||||
'x-async': false,
|
'x-async': false,
|
||||||
'x-index': null,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,7 +137,6 @@ describe('ui schema model', () => {
|
|||||||
name: 'new-root-name',
|
name: 'new-root-name',
|
||||||
'x-uid': 'root-uid',
|
'x-uid': 'root-uid',
|
||||||
'x-async': false,
|
'x-async': false,
|
||||||
'x-index': null,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -196,7 +196,6 @@ describe('ui_schema repository', () => {
|
|||||||
name: 'root-name',
|
name: 'root-name',
|
||||||
'x-uid': 'root',
|
'x-uid': 'root',
|
||||||
'x-async': false,
|
'x-async': false,
|
||||||
'x-index': null,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -128,9 +128,12 @@ export class UiSchemaRepository extends Repository {
|
|||||||
...lodash.pick(node, [...nodeKeys, 'name']),
|
...lodash.pick(node, [...nodeKeys, 'name']),
|
||||||
['x-uid']: node.uid,
|
['x-uid']: node.uid,
|
||||||
['x-async']: !!node.async,
|
['x-async']: !!node.async,
|
||||||
['x-index']: node.sort,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (lodash.isNumber(node.sort)) {
|
||||||
|
schema['x-index'] = node.sort;
|
||||||
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user