mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 04:07:50 +08:00
fix(plugin-cm): fix life cycle (#2535)
This commit is contained in:
parent
3d9a6ef76f
commit
643594abad
@ -214,7 +214,7 @@ export class CollectionManagerPlugin extends Plugin {
|
||||
await this.app.db.getRepository<CollectionRepository>('collections').load();
|
||||
};
|
||||
|
||||
this.app.on('afterStart', loadCollections);
|
||||
this.app.on('beforeStart', loadCollections);
|
||||
this.app.on('beforeUpgrade', async () => {
|
||||
const syncOptions = {
|
||||
alter: {
|
||||
|
@ -34,6 +34,8 @@
|
||||
"@nocobase/database": "0.x",
|
||||
"@nocobase/evaluators": "0.x",
|
||||
"@nocobase/logger": "0.x",
|
||||
"@nocobase/plugin-collection-manager": "0.x",
|
||||
"@nocobase/plugin-error-handler": "0.x",
|
||||
"@nocobase/plugin-users": "0.x",
|
||||
"@nocobase/resourcer": "0.x",
|
||||
"@nocobase/server": "0.x",
|
||||
|
@ -13,7 +13,9 @@ describe('workflow > triggers > collection', () => {
|
||||
let WorkflowModel;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = await getApp();
|
||||
app = await getApp({
|
||||
plugins: ['error-handler', 'collection-manager'],
|
||||
});
|
||||
|
||||
db = app.db;
|
||||
WorkflowModel = db.getCollection('workflows').model;
|
||||
@ -50,6 +52,51 @@ describe('workflow > triggers > collection', () => {
|
||||
const executions = await workflow.getExecutions();
|
||||
expect(executions.length).toBe(0);
|
||||
});
|
||||
|
||||
it('restart server and listen a collection managed by collection-manager', async () => {
|
||||
await db.getRepository('collections').create({
|
||||
values: {
|
||||
name: 'temp',
|
||||
title: 'Temp',
|
||||
},
|
||||
// to trigger collection sync to db.collections
|
||||
context: {},
|
||||
});
|
||||
|
||||
const workflow = await WorkflowModel.create({
|
||||
type: 'collection',
|
||||
config: {
|
||||
mode: 1,
|
||||
collection: 'temp',
|
||||
},
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
await db.getRepository('temp').create({ values: {} });
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const e1 = await workflow.getExecutions();
|
||||
expect(e1.length).toBe(1);
|
||||
|
||||
await app.destroy();
|
||||
|
||||
app = await getApp({
|
||||
plugins: ['error-handler', 'collection-manager'],
|
||||
database: {
|
||||
tablePrefix: db.options.tablePrefix,
|
||||
},
|
||||
});
|
||||
|
||||
db = app.db;
|
||||
|
||||
await db.getRepository('temp').create({ values: {} });
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const e2 = await db.getModel('executions').findAll();
|
||||
expect(e2.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('model context', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user