* 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.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { buildUser, buildCollection } from "@server/test/factories";
|
|
import { getTestDatabase, getTestServer } from "@server/test/support";
|
|
|
|
const db = getTestDatabase();
|
|
const server = getTestServer();
|
|
|
|
afterAll(server.disconnect);
|
|
|
|
beforeEach(db.flush);
|
|
|
|
describe("auth/redirect", () => {
|
|
it("should redirect to home", async () => {
|
|
const user = await buildUser();
|
|
const res = await server.get(
|
|
`/auth/redirect?token=${user.getTransferToken()}`,
|
|
{
|
|
redirect: "manual",
|
|
}
|
|
);
|
|
expect(res.status).toEqual(302);
|
|
expect(res.headers.get("location").endsWith("/home")).toBeTruthy();
|
|
});
|
|
|
|
it("should redirect to first collection", async () => {
|
|
const collection = await buildCollection();
|
|
const user = await buildUser({
|
|
teamId: collection.teamId,
|
|
});
|
|
const res = await server.get(
|
|
`/auth/redirect?token=${user.getTransferToken()}`,
|
|
{
|
|
redirect: "manual",
|
|
}
|
|
);
|
|
expect(res.status).toEqual(302);
|
|
expect(res.headers.get("location").endsWith(collection.url)).toBeTruthy();
|
|
});
|
|
});
|