* feat(plugin-workflow): support multiple data source in workflow * fix(plugin-workflow): fix test cases * test(plugin-workflow-sql): debug test case * fix(plugin-workflow): fix collection trigger creation without config * test(plugin-workflow-sql): debug test case * fix: workflow e2e test * chore(ci): disable console intercept in vitest * chore(ci): disable console intercept in vitest * chore(ci): disable console intercept in vitest * chore(ci): disable console intercept in vitest * test(plugin-workflow-sql): debug test case * test: approval e2e * fix: remove pro-plugins from packages * refactor(plugin-workflow): support pass collection from props to CollectionBlockInitializer * test(plugin-workflow): add test case * fix(plugin-workflow): disable modification of executed workflow * fix: e2ePageObjectModel * fix: load data source when data source load failed (#3793) * chore: console.log * fix(subTable): fix sorting rule setting (#3795) * fix: through collection support search (#3800) * fix(client): visible -> useVisible * fix(client): fix action designer error occured in custom form (#3801) * fix(client): fix action designer error occured in custom form * fix(client): fix from the source * chore(module): remove submodule * fix(plugin-workflow): fix client cycling import * fix(plugin-workflow): fix collection event name * fix(plugin-workflow): fix undefined ref --------- Co-authored-by: hongboji <j414562100@qq.com> Co-authored-by: ChengLei Shao <chareice@live.com> Co-authored-by: Zeke Zhang <958414905@qq.com> Co-authored-by: katherinehhh <shunai.tang@hand-china.com> Co-authored-by: chenos <chenlinxh@gmail.com>
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
import path from 'path';
|
|
|
|
import { ApplicationOptions, Plugin } from '@nocobase/server';
|
|
import { MockServer, createMockServer, mockDatabase } from '@nocobase/test';
|
|
|
|
import functions from './functions';
|
|
import triggers from './triggers';
|
|
import instructions from './instructions';
|
|
import { Resourcer } from '@nocobase/resourcer';
|
|
import { SequelizeDataSource } from '@nocobase/data-source-manager';
|
|
import { uid } from '@nocobase/utils';
|
|
|
|
export interface MockServerOptions extends ApplicationOptions {
|
|
collectionsPath?: string;
|
|
}
|
|
|
|
// async function createMockServer(options: MockServerOptions) {
|
|
// const app = mockServer(options);
|
|
// await app.cleanDb();
|
|
// await app.runCommand('start', '--quickstart');
|
|
// return app;
|
|
// }
|
|
|
|
export function sleep(ms: number) {
|
|
return new Promise((resolve) => {
|
|
setTimeout(resolve, ms);
|
|
});
|
|
}
|
|
|
|
export async function getApp(options: MockServerOptions = {}): Promise<MockServer> {
|
|
const { plugins = [], collectionsPath, ...others } = options;
|
|
class TestCollectionPlugin extends Plugin {
|
|
async load() {
|
|
if (collectionsPath) {
|
|
await this.db.import({ directory: collectionsPath });
|
|
}
|
|
}
|
|
}
|
|
const app = await createMockServer({
|
|
...others,
|
|
plugins: [
|
|
[
|
|
'workflow',
|
|
{
|
|
triggers,
|
|
instructions,
|
|
functions,
|
|
},
|
|
],
|
|
'workflow-test',
|
|
TestCollectionPlugin,
|
|
...plugins,
|
|
],
|
|
});
|
|
|
|
await app.dataSourceManager.add(
|
|
new SequelizeDataSource({
|
|
name: 'another',
|
|
collectionManager: {
|
|
database: mockDatabase({
|
|
tablePrefix: `t${uid(5)}`,
|
|
}),
|
|
},
|
|
resourceManager: {},
|
|
}),
|
|
);
|
|
const another = app.dataSourceManager.dataSources.get('another');
|
|
// @ts-ignore
|
|
const anotherDB = another.collectionManager.db;
|
|
|
|
await anotherDB.import({
|
|
directory: path.resolve(__dirname, 'collections'),
|
|
});
|
|
await anotherDB.sync();
|
|
|
|
another.acl.allow('*', '*');
|
|
|
|
return app;
|
|
}
|
|
|
|
export default class WorkflowTestPlugin extends Plugin {
|
|
async load() {
|
|
await this.importCollections(path.resolve(__dirname, 'collections'));
|
|
}
|
|
}
|