* perf: reduce memory usage upon running server tests * perf: plug leaks in server/routes * perf: plug leaks in server/scripts * perf: plug leaks in server/policies * perf: plug leaks in server/models * perf: plug leaks in server/middlewares * perf: plug leaks in server/commands * fix: missing await on db.flush * perf: plug leaks in server/queues * chore: remove unused legacy funcs * fix: await on db.flush * perf: await on GC to run in between tests * fix: remove db refs * fix: revert embeds * perf: plug leaks in shared/i18n
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { buildUser, buildTeam, buildAdmin } from "@server/test/factories";
|
|
import { getTestDatabase } from "@server/test/support";
|
|
import { serialize } from "./index";
|
|
|
|
const db = getTestDatabase();
|
|
|
|
afterAll(db.disconnect);
|
|
|
|
beforeEach(db.flush);
|
|
|
|
it("should allow reading only", async () => {
|
|
const team = await buildTeam();
|
|
const user = await buildUser({
|
|
teamId: team.id,
|
|
});
|
|
const abilities = serialize(user, team);
|
|
expect(abilities.read).toEqual(true);
|
|
expect(abilities.manage).toEqual(false);
|
|
expect(abilities.createAttachment).toEqual(true);
|
|
expect(abilities.createCollection).toEqual(true);
|
|
expect(abilities.createDocument).toEqual(true);
|
|
expect(abilities.createGroup).toEqual(false);
|
|
expect(abilities.createIntegration).toEqual(false);
|
|
});
|
|
it("should allow admins to manage", async () => {
|
|
const team = await buildTeam();
|
|
const admin = await buildAdmin({
|
|
teamId: team.id,
|
|
});
|
|
const abilities = serialize(admin, team);
|
|
expect(abilities.read).toEqual(true);
|
|
expect(abilities.manage).toEqual(true);
|
|
expect(abilities.createAttachment).toEqual(true);
|
|
expect(abilities.createCollection).toEqual(true);
|
|
expect(abilities.createDocument).toEqual(true);
|
|
expect(abilities.createGroup).toEqual(true);
|
|
expect(abilities.createIntegration).toEqual(true);
|
|
});
|