Files
hyperframes/packages/share/tests/versionStart.test.mjs
T
terencechoandClaude Opus 5.5 f54b2227fd feat(share): extract shared review kernel for local hosts (#7134)
* feat(share): extract shared review kernel for local hosts

* fix: recover completed shares and integrate kernel checks

* fix: terminate ffprobe options before share media input

* fix: verify executable imports without matching JSDoc types

* build: budget the published sharing package

* fix: publish NodeNext-compatible sharing declarations

* fix: invalidate shared renders when linked media changes

* fix: reserve share progress before awaiting upload lock

* fix: copy share build inputs before image dependency install

* fix(share): preserve Desktop snapshots and support portable locks

* fix(share): restrict video uploads to trusted origins

* fix(share): preserve review state across recovery and uploads

* fix(share): preserve review title and feedback attribution

* fix(share): accept legacy review records safely

* build(share): update measured package size budget

* fix(share): preserve feedback cutoff across export retries

* docs(share): describe only the storage origins the signer uses

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 04:35:33 +00:00

51 lines
1.7 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
import { realpathSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { addVersion, bindShareHost, withProjectShareLock } from "../src/index.mjs";
test("an upload reserves its in-process state before waiting for the file lock", async (t) => {
const dir = await mkdtemp(join(tmpdir(), "share-start-"));
t.after(() => rm(dir, { recursive: true, force: true }));
await mkdir(join(dir, ".hyperframes"));
const file = join(dir, ".hyperframes/video.mp4");
await writeFile(file, "video");
bindShareHost({
normalize: realpathSync,
projectFingerprint: async () => "rendered",
latestExportFile: () => ({ path: file, fingerprint: "rendered", id: "r1" }),
});
const states = [];
let creates = 0;
const request = {
projectPath: dir,
title: "Video",
projectId: "project",
probe: async () => ({ width: 100, height: 100, duration: 1 }),
onProgress: (value) => states.push(value?.step ?? null),
client: {
createExport: async () => {
creates++;
return {
status: "ready",
video_id: "video",
version_id: "version",
exported_at: "2026-11-04T00:00:00Z",
};
},
},
};
let pending;
await withProjectShareLock(dir, "export", async () => {
pending = addVersion(request);
assert.deepEqual(states, ["preparing"]);
assert.equal(await addVersion(request), null);
assert.equal(creates, 0);
});
assert.equal(await pending, null);
assert.equal(creates, 1);
assert.equal(states.filter((state) => state === null).length, 1);
});