Files
outline/server/routes/api/integrations.test.ts
Apoorv Mishra 0c51bfb899 perf: reduce memory usage upon running server tests (#3949)
* 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
2022-08-11 21:39:17 +05:30

53 lines
1.3 KiB
TypeScript

import {
buildAdmin,
buildTeam,
buildUser,
buildIntegration,
} from "@server/test/factories";
import { getTestDatabase, getTestServer } from "@server/test/support";
const db = getTestDatabase();
const server = getTestServer();
afterAll(server.disconnect);
beforeEach(db.flush);
describe("#integrations.update", () => {
it("should allow updating integration events", async () => {
const team = await buildTeam();
const user = await buildAdmin({ teamId: team.id });
const integration = await buildIntegration({
userId: user.id,
teamId: team.id,
});
const res = await server.post("/api/integrations.update", {
body: {
events: ["documents.update"],
token: user.getJwtToken(),
id: integration.id,
},
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.id).toEqual(integration.id);
expect(body.data.events.length).toEqual(1);
});
it("should require authorization", async () => {
const user = await buildUser();
const integration = await buildIntegration({
userId: user.id,
});
const res = await server.post("/api/integrations.update", {
body: {
token: user.getJwtToken(),
id: integration.id,
},
});
expect(res.status).toEqual(403);
});
});