diff --git a/packages/core/test/src/server/mock-server.ts b/packages/core/test/src/server/mock-server.ts index 1a3b0fd736..c99b89b85c 100644 --- a/packages/core/test/src/server/mock-server.ts +++ b/packages/core/test/src/server/mock-server.ts @@ -239,13 +239,15 @@ export function mockServer(options: ApplicationOptions = {}) { ...options, }); - const basename = app.options.pubSubManager?.channelPrefix || app.name; + const basename = app.options.pubSubManager?.channelPrefix; - app.pubSubManager.setAdapter( - MemoryPubSubAdapter.create(basename, { - debounce: 500, - }), - ); + if (basename) { + app.pubSubManager.setAdapter( + MemoryPubSubAdapter.create(basename, { + debounce: 500, + }), + ); + } return app; } diff --git a/packages/plugins/@nocobase/plugin-file-manager/src/server/__tests__/cluster.test.ts b/packages/plugins/@nocobase/plugin-file-manager/src/server/__tests__/cluster.test.ts index 67927ac3ff..f273a34097 100644 --- a/packages/plugins/@nocobase/plugin-file-manager/src/server/__tests__/cluster.test.ts +++ b/packages/plugins/@nocobase/plugin-file-manager/src/server/__tests__/cluster.test.ts @@ -16,7 +16,7 @@ describe('file-manager > cluster', () => { beforeEach(async () => { cluster = await createMockCluster({ - plugins: [[Plugin, { name: 'file-manager' }]], + plugins: ['file-manager'], }); }); @@ -44,9 +44,7 @@ describe('file-manager > cluster', () => { path: 'a', }); expect(p1.storagesCache.get(s1.id).path).toEqual('a'); - await sleep(550); - expect(p2.storagesCache.get(s1.id).path).toEqual('a'); }); }); diff --git a/packages/plugins/@nocobase/plugin-file-manager/src/server/server.ts b/packages/plugins/@nocobase/plugin-file-manager/src/server/server.ts index 66f9c082e0..e356211ae7 100644 --- a/packages/plugins/@nocobase/plugin-file-manager/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-file-manager/src/server/server.ts @@ -190,19 +190,25 @@ export default class PluginFileManagerServer extends Plugin { }); const Storage = this.db.getModel('storages'); - Storage.afterSave((m) => { + Storage.afterSave((m, { transaction }) => { this.storagesCache.set(m.id, m.toJSON()); - this.sendSyncMessage({ - type: 'storageChange', - storageId: m.id, - }); + this.sendSyncMessage( + { + type: 'storageChange', + storageId: m.id, + }, + { transaction }, + ); }); - Storage.afterDestroy((m) => { + Storage.afterDestroy((m, { transaction }) => { this.storagesCache.delete(m.id); - this.sendSyncMessage({ - type: 'storageRemove', - storageId: m.id, - }); + this.sendSyncMessage( + { + type: 'storageRemove', + storageId: m.id, + }, + { transaction }, + ); }); this.app.acl.registerSnippet({