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