feat(shot-status): last sent column per shot
Deploy / deploy (push) Successful in 3m27s

Shows what last reached the client with evidence (shared EXR package or
manual delivery), anything newer still on its way, and the last review MOV,
so it's clear on Shot Status what has actually been sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-10-05 16:24:18 +02:00
parent 91e69f0bcb
commit 88112112d4
4 changed files with 339 additions and 10 deletions
@@ -0,0 +1,112 @@
import { describe, expect, it } from "vitest";
import { summariseShotDelivery, type ShotDeliveryPackage } from "./shot-delivery-summary";
const day = (d: number) => new Date(Date.UTC(2026, 8, d, 12));
const pkg = (over: Partial<ShotDeliveryPackage>): ShotDeliveryPackage => ({
kind: "EXR_DELIVERY",
status: "DELIVERED",
packageNumber: 1,
versionString: "v001",
createdAt: day(1),
builtAt: day(1),
uploadedAt: day(1),
deliveredAt: day(1),
sharedWith: "Dana",
...over,
});
const noManual = { deliveredAt: null, sharedWith: null, note: null };
describe("summariseShotDelivery", () => {
it("reports nothing for a shot that has never been exported", () => {
expect(summariseShotDelivery({ packages: [], manual: noManual, latestExport: null })).toEqual({
sent: null,
review: null,
pending: null,
});
});
it("takes the most recently shared EXR package as sent", () => {
const s = summariseShotDelivery({
packages: [
pkg({ packageNumber: 3, versionString: "v002", deliveredAt: day(5), createdAt: day(4) }),
pkg({ packageNumber: 1, versionString: "v001", deliveredAt: day(2) }),
],
manual: noManual,
latestExport: { versionString: "v002", status: "DELIVERED" },
});
expect(s.sent).toMatchObject({ via: "PACKAGE", version: "v002", label: "Package #3", to: "Dana" });
expect(s.pending).toBeNull();
});
it("prefers a later manual delivery", () => {
const s = summariseShotDelivery({
packages: [pkg({ deliveredAt: day(2) })],
manual: { deliveredAt: day(6), sharedWith: "Sam", note: "WeTransfer" },
latestExport: null,
});
expect(s.sent).toMatchObject({ via: "MANUAL", version: null, to: "Sam", note: "WeTransfer" });
});
it("does not count a built but unshared package as sent", () => {
const s = summariseShotDelivery({
packages: [pkg({ status: "READY", uploadedAt: null, deliveredAt: null, packageNumber: 7, versionString: "v003" })],
manual: noManual,
latestExport: { versionString: "v003", status: "PACKAGED" },
});
expect(s.sent).toBeNull();
expect(s.pending).toEqual({ version: "v003", label: "built in #7, not uploaded", tone: "waiting" });
});
it("flags an uploaded package whose link was never shared", () => {
const s = summariseShotDelivery({
packages: [pkg({ status: "READY", deliveredAt: null, packageNumber: 7 })],
manual: noManual,
latestExport: null,
});
expect(s.pending?.label).toBe("uploaded in #7, link not shared");
});
it("ignores cancelled packages and open packages older than the last send", () => {
const s = summariseShotDelivery({
packages: [
pkg({ status: "CANCELLED", deliveredAt: null, createdAt: day(9) }),
pkg({ status: "FAILED", deliveredAt: null, createdAt: day(1) }),
pkg({ deliveredAt: day(3), createdAt: day(2) }),
],
manual: noManual,
latestExport: { versionString: "v001", status: "DELIVERED" },
});
expect(s.pending).toBeNull();
});
it("shows a newer export that has not gone out", () => {
const s = summariseShotDelivery({
packages: [pkg({ deliveredAt: day(2) })],
manual: noManual,
latestExport: { versionString: "v002", status: "READY_FOR_QC" },
});
expect(s.pending).toEqual({ version: "v002", label: "in QC", tone: "waiting" });
});
it("reports failed exports as failed", () => {
const s = summariseShotDelivery({
packages: [],
manual: noManual,
latestExport: { versionString: "v002", status: "QC_FAILED" },
});
expect(s.pending?.tone).toBe("failed");
});
it("keeps review MOVs apart from deliveries", () => {
const s = summariseShotDelivery({
packages: [pkg({ kind: "MOV_REVIEW", status: "READY", packageNumber: 4, versionString: "v002", builtAt: day(8), deliveredAt: null })],
manual: noManual,
latestExport: null,
});
expect(s.sent).toBeNull();
expect(s.pending).toBeNull();
expect(s.review).toMatchObject({ version: "v002", label: "Review #4" });
});
});