diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/server/__tests__/migrations/20240420105949-add-sort-field.test.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/server/__tests__/migrations/20240420105949-add-sort-field.test.ts index a6d4f952b1708..b6feaf9909fe3 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/server/__tests__/migrations/20240420105949-add-sort-field.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/server/__tests__/migrations/20240420105949-add-sort-field.test.ts @@ -17,6 +17,16 @@ describe('nocobase-admin-menu', () => { }); test('migration', async () => { + await app.db.getRepository('collections').create({ + values: { + autoGenId: true, + sortable: true, + name: 'bar', + template: 'general', + view: false, + }, + context: {}, + }); await app.db.getRepository('collections').create({ values: { autoGenId: true, @@ -37,7 +47,7 @@ describe('nocobase-admin-menu', () => { { type: 'sort', name: 'sort3', - interface: 'sort3', + interface: 'sort', uiSchema: { type: 'number', title: 'Sort 3', @@ -46,10 +56,18 @@ describe('nocobase-admin-menu', () => { 'x-validator': 'integer', }, }, + { + type: 'hasMany', + name: 'bar', + target: 'bar', + foreignKey: 'fooId', + sortable: true, + }, ], }, context: {}, }); + const migration = new Migration({ db: app.db, // @ts-ignore @@ -79,6 +97,15 @@ describe('nocobase-admin-menu', () => { name: 'sort3', }, }); + expect(sort3.interface).toBe('sort'); expect(sort3.get('uiSchema.title')).toBe('Sort 3'); + const sort4 = await app.db.getRepository('fields').findOne({ + filter: { + collectionName: 'bar', + name: 'fooIdSort', + }, + }); + expect(sort4.interface).toBe('sort'); + expect(sort4.get('uiSchema.title')).toBe('fooIdSort'); }); });