feat(media): add Convex media archive with backfill and mixed-media library

This commit is contained in:
2026-04-10 15:15:44 +02:00
parent ddb2412349
commit a1df097f9c
26 changed files with 2664 additions and 122 deletions

View File

@@ -49,7 +49,31 @@ function createCachedSnapshot() {
},
],
canvases: [],
mediaPreview: [],
mediaPreview: [
{
kind: "image",
storageId: "storage_1",
filename: "preview.jpg",
createdAt: 1,
},
],
};
}
function createLegacyCachedSnapshotWithoutKind() {
return {
balance: { available: 120 },
subscription: null,
usageStats: null,
recentTransactions: [],
canvases: [],
mediaPreview: [
{
storageId: "storage_legacy",
filename: "legacy.jpg",
createdAt: 1,
},
],
};
}
@@ -116,4 +140,23 @@ describe("useDashboardSnapshot", () => {
expect(latestHookValue.current?.source).toBe("cache");
expect(firstSnapshot).toBe(secondSnapshot);
});
it("ignores legacy cached snapshots that miss media item kind", async () => {
useAuthQueryMock.mockReturnValue(undefined);
getDashboardSnapshotCacheInvalidationSignalKeyMock.mockReturnValue("dashboard:invalidate");
readDashboardSnapshotCacheMock.mockReturnValue({
snapshot: createLegacyCachedSnapshotWithoutKind(),
});
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
await act(async () => {
root?.render(React.createElement(HookHarness, { userId: "user_legacy" }));
});
expect(latestHookValue.current?.source).toBe("none");
expect(latestHookValue.current?.snapshot).toBeUndefined();
});
});