A Canon body stores the wall time without an offset. Rejecting that date rejected the whole folder, so the page showed a generic error after counting the sidecars.
100 lines
3.7 KiB
TypeScript
100 lines
3.7 KiB
TypeScript
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
import { bearer, createTestApp, login, resetDb, seedUser, type TestContext } from "./helpers.js";
|
|
|
|
let ctx: TestContext;
|
|
beforeAll(async () => {
|
|
ctx = await createTestApp();
|
|
});
|
|
afterAll(async () => {
|
|
await ctx.app.close();
|
|
await ctx.db.$disconnect();
|
|
});
|
|
beforeEach(() => resetDb(ctx.db));
|
|
|
|
const at = (ms: number) => new Date(Date.parse("2026-10-21T10:00:00.000Z") + ms).toISOString();
|
|
|
|
function shot(id: string, bias: number, ms: number) {
|
|
return {
|
|
id,
|
|
fileName: `${id}.CR3`,
|
|
capturedAt: at(ms),
|
|
cameraSerial: "body",
|
|
focalLength: 16,
|
|
aperture: 8,
|
|
iso: 100,
|
|
exposureBias: bias,
|
|
exposureTime: 0.01,
|
|
};
|
|
}
|
|
|
|
describe("real estate", () => {
|
|
it("stays off until the owner turns it on, and then groups a bracket without taking the files", async () => {
|
|
const { org } = await seedUser(ctx.db, "[email protected]", { org: "casa", role: "OWNER" });
|
|
await seedUser(ctx.db, "[email protected]", { org: "casa", role: "PHOTOGRAPHER" });
|
|
await seedUser(ctx.db, "[email protected]", { org: "casa", role: "CLIENT" });
|
|
const owner = await login(ctx.app, "[email protected]");
|
|
const photographer = await login(ctx.app, "[email protected]");
|
|
const client = await login(ctx.app, "[email protected]");
|
|
const orgId = org!.id;
|
|
const url = `/v1/orgs/${orgId}/real-estate`;
|
|
|
|
const me = await ctx.app.inject({ method: "GET", url: "/v1/me", headers: bearer(owner.body.accessToken) });
|
|
expect(me.json().memberships[0].organization.realEstateEnabled).toBe(false);
|
|
|
|
const hidden = await ctx.app.inject({
|
|
method: "POST",
|
|
url: `${url}/groups`,
|
|
headers: bearer(owner.body.accessToken),
|
|
payload: { frames: [shot("a", -2, 0), shot("b", 0, 200), shot("c", 2, 400)] },
|
|
});
|
|
expect(hidden.statusCode).toBe(409);
|
|
expect(hidden.json().error).toBe("real_estate_disabled");
|
|
|
|
const asPhotographer = await ctx.app.inject({
|
|
method: "PUT",
|
|
url,
|
|
headers: bearer(photographer.body.accessToken),
|
|
payload: { enabled: true },
|
|
});
|
|
expect(asPhotographer.statusCode).toBe(403);
|
|
|
|
const on = await ctx.app.inject({ method: "PUT", url, headers: bearer(owner.body.accessToken), payload: { enabled: true } });
|
|
expect(on.json()).toEqual({ enabled: true });
|
|
|
|
const asClient = await ctx.app.inject({
|
|
method: "POST",
|
|
url: `${url}/groups`,
|
|
headers: bearer(client.body.accessToken),
|
|
payload: { frames: [shot("a", -2, 0)] },
|
|
});
|
|
expect(asClient.statusCode).toBe(403);
|
|
|
|
const grouped = await ctx.app.inject({
|
|
method: "POST",
|
|
url: `${url}/groups`,
|
|
headers: bearer(photographer.body.accessToken),
|
|
payload: {
|
|
frames: [shot("a", -2, 0), shot("b", 0, 200), shot("c", 2, 400), shot("solo", 0, 30_000)],
|
|
},
|
|
});
|
|
expect(grouped.statusCode).toBe(200);
|
|
expect(grouped.json()).toEqual({ stacks: [{ frameIds: ["a", "b", "c"] }], aside: ["solo"] });
|
|
|
|
const localClock = await ctx.app.inject({
|
|
method: "POST",
|
|
url: `${url}/groups`,
|
|
headers: bearer(photographer.body.accessToken),
|
|
payload: {
|
|
frames: [
|
|
{ ...shot("a", -2, 0), id: "local-a", capturedAt: "2026-10-21T10:00:00" },
|
|
{ ...shot("b", 0, 200), id: "local-b", capturedAt: "2026-10-21T10:00:00.200" },
|
|
{ ...shot("c", 2, 400), id: "local-c", capturedAt: "2026-10-21T10:00:00.400" },
|
|
{ id: "bad", fileName: "nota.XMP", capturedAt: "not a date", cameraSerial: "other", exposureBias: 0 },
|
|
],
|
|
},
|
|
});
|
|
expect(localClock.statusCode).toBe(200);
|
|
expect(localClock.json()).toEqual({ stacks: [{ frameIds: ["local-a", "local-b", "local-c"] }], aside: ["bad"] });
|
|
});
|
|
});
|