Files
outline/server/models/FileOperation.test.ts
Tom Moor 9ae7517efb fix: Re-check file operation permissions at download (#13148)
* fix: Re-check file operation permissions at download

* feedback

* Address feedback and copy across to other findByPk overrides
2026-07-27 18:32:17 -04:00

40 lines
1.1 KiB
TypeScript

import {
buildFileOperation,
buildTeam,
buildUser,
} from "@server/test/factories";
import FileOperation from "./FileOperation";
describe("FileOperation", () => {
describe("findByPk", () => {
it("should not allow a passed where to override the id", async () => {
const team = await buildTeam();
const user = await buildUser({ teamId: team.id });
const fileOperation = await buildFileOperation({
teamId: team.id,
userId: user.id,
});
const other = await buildFileOperation({
teamId: team.id,
userId: user.id,
});
const found = await FileOperation.findByPk(fileOperation.id, {
where: { id: other.id },
});
expect(found?.id).toEqual(fileOperation.id);
});
it("should throw the passed error when rejectOnEmpty is an error", async () => {
const error = new Error("does not exist");
await expect(
FileOperation.findByPk("3a1b2c3d-0000-4000-8000-000000000000", {
rejectOnEmpty: error,
})
).rejects.toThrow(error);
});
});
});