feat(test): add quickstart
This commit is contained in:
parent
52c83cadb3
commit
7adb162cc8
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user