feat(test): add quickstart

This commit is contained in:
chenos 2023-12-02 09:40:22 +08:00
parent 52c83cadb3
commit 7adb162cc8
2 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { Database, mockDatabase } from '@nocobase/database';
import { mockDatabase } from '@nocobase/database';
import Application, { AppSupervisor, ApplicationOptions, Gateway, PluginManager } from '@nocobase/server';
import jwt from 'jsonwebtoken';
import qs from 'qs';
@ -81,6 +81,14 @@ export class MockServer extends Application {
await this.db.clean({ drop: true });
}
async quickstart(options: { clean?: boolean } = {}) {
const { clean } = options;
if (clean) {
await this.cleanDb();
}
await this.runCommand('start', '--quickstart');
}
protected createDatabase(options: ApplicationOptions) {
const oldDatabase = this._db;

View File

@ -1,19 +1,13 @@
import { mockServer, MockServer } from '@nocobase/test';
import PluginACL from '../../server';
export async function prepareApp(): Promise<MockServer> {
const app = mockServer({
registerActions: true,
acl: true,
plugins: ['error-handler', 'users', 'ui-schema-storage', 'collection-manager', 'auth'],
plugins: ['acl', 'error-handler', 'users', 'ui-schema-storage', 'collection-manager', 'auth'],
});
await app.db.clean({ drop: true });
app.plugin(PluginACL, {
name: 'acl',
});
await app.quickstart({ clean: true });
await app.loadAndInstall({ clean: true });
await app.start();
return app;
}