Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2024-12-28 14:31:01 +00:00
commit 702a335b6d
2 changed files with 52 additions and 2 deletions

View File

@ -118,9 +118,10 @@ export class MockServer extends Application {
await AppSupervisor.getInstance().destroy(); await AppSupervisor.getInstance().destroy();
} }
agent(): ExtendedAgent { agent(callback?): ExtendedAgent {
const agent = supertest.agent(this.callback()); const agent = supertest.agent(callback || this.callback());
const prefix = this.resourcer.options.prefix; const prefix = this.resourcer.options.prefix;
const proxy = new Proxy(agent, { const proxy = new Proxy(agent, {
get(target, method: string, receiver) { get(target, method: string, receiver) {
if (['login', 'loginUsingId'].includes(method)) { if (['login', 'loginUsingId'].includes(method)) {

View File

@ -0,0 +1,49 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { createMockServer, MockServer } from '@nocobase/test';
import { AppSupervisor } from '@nocobase/server';
describe('sub app', async () => {
let app: MockServer;
let agent: any;
beforeEach(async () => {
app = await createMockServer({
plugins: ['multi-app-manager', 'client', 'ui-schema-storage', 'system-settings'],
});
await app.db.getRepository('applications').create({
values: {
name: 'test_sub',
options: {
plugins: ['client', 'ui-schema-storage', 'system-settings'],
},
},
context: {
waitSubAppInstall: true,
},
});
agent = app.agent();
});
afterEach(async () => {
await app.destroy();
});
test('sub agent', async () => {
const res = await agent.get('/app:getInfo');
expect(res.body.data.name).toBe('main');
const subApp = await AppSupervisor.getInstance().getApp('test_sub');
const res1 = await app.agent(subApp.callback()).get('/api/app:getInfo');
expect(res1.body.data.name).toBe('test_sub');
});
});