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 Application, { AppSupervisor, ApplicationOptions, Gateway, PluginManager } from '@nocobase/server';
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
@ -81,6 +81,14 @@ export class MockServer extends Application {
|
|||||||
await this.db.clean({ drop: true });
|
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) {
|
protected createDatabase(options: ApplicationOptions) {
|
||||||
const oldDatabase = this._db;
|
const oldDatabase = this._db;
|
||||||
|
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
import { mockServer, MockServer } from '@nocobase/test';
|
import { mockServer, MockServer } from '@nocobase/test';
|
||||||
import PluginACL from '../../server';
|
|
||||||
|
|
||||||
export async function prepareApp(): Promise<MockServer> {
|
export async function prepareApp(): Promise<MockServer> {
|
||||||
const app = mockServer({
|
const app = mockServer({
|
||||||
registerActions: true,
|
registerActions: true,
|
||||||
acl: 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 });
|
await app.quickstart({ clean: true });
|
||||||
app.plugin(PluginACL, {
|
|
||||||
name: 'acl',
|
|
||||||
});
|
|
||||||
|
|
||||||
await app.loadAndInstall({ clean: true });
|
|
||||||
await app.start();
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user