tachybase_todo/packages/plugin-file-manager/src/__tests__/index.ts
Junyi 60b966f59e
Fix: plugin-file-manager (#111)
* fix: test cases

* fix env used by file manager

* default value of process.env.LOCAL_STORAGE_BASE_URL

* use workspace dependencies

* refactor some env to adapt more scenario

* fix reviewing issues

* fix env default value

* update umi config

* bugfix

* fix shared cache

Co-authored-by: chenos <chenlinxh@gmail.com>
2021-12-03 07:31:22 +08:00

35 lines
782 B
TypeScript

import path from 'path';
import supertest from 'supertest';
import { MockServer, mockServer } from '@nocobase/test';
import plugin from '../server';
export async function getApp(options = {}): Promise<MockServer> {
const app = mockServer({
...options,
cors: {
origin: '*'
}
});
app.plugin(require('@nocobase/plugin-collections/src/server').default);
app.plugin(plugin);
await app.load();
app.db.import({
directory: path.resolve(__dirname, './tables')
});
try {
await app.db.sync();
} catch (error) {
console.error(error);
}
return app;
}
// because the app in supertest is using a random port
export function requestFile(url, agent) {
return path.isAbsolute(url)
? agent.get(url)
: supertest.agent(url).get('');
}