@hyperframes/studio 0.9.27 → 0.9.28-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.9.27",
3
+ "version": "0.9.28-alpha.1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,12 +60,12 @@
60
60
  "dockview-react": "8.3.1",
61
61
  "gsap": "^3.13.0",
62
62
  "mediabunny": "^1.65.2",
63
- "@hyperframes/player": "0.9.27",
64
- "@hyperframes/shader-transitions": "0.9.27",
65
- "@hyperframes/studio-server": "0.9.27",
66
- "@hyperframes/sdk": "0.9.27",
67
- "@hyperframes/core": "0.9.27",
68
- "@hyperframes/parsers": "0.9.27"
63
+ "@hyperframes/core": "0.9.28-alpha.1",
64
+ "@hyperframes/player": "0.9.28-alpha.1",
65
+ "@hyperframes/sdk": "0.9.28-alpha.1",
66
+ "@hyperframes/shader-transitions": "0.9.28-alpha.1",
67
+ "@hyperframes/studio-server": "0.9.28-alpha.1",
68
+ "@hyperframes/parsers": "0.9.28-alpha.1"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tailwindcss/vite": "^4.3.3",
@@ -82,7 +82,7 @@
82
82
  "vite": "^6.4.2",
83
83
  "vitest": "^4.1.11",
84
84
  "zustand": "^5.0.0",
85
- "@hyperframes/producer": "0.9.27"
85
+ "@hyperframes/producer": "0.9.28-alpha.1"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
package/src/App.tsx CHANGED
@@ -517,6 +517,7 @@ export function StudioApp({ readOnlyPreview = false, readOnlyPreviewReason }: St
517
517
  inspectorButtonActive={inspectorButtonActive}
518
518
  inspectorPanelActive={inspectorPanelActive}
519
519
  onExport={handleExport}
520
+ beforeShare={previewPersistence.waitForPendingDomEditSaves}
520
521
  />
521
522
  {previewPersistence.domEditSaveQueuePaused && !externalFileChanges.blocked && (
522
523
  <SaveQueuePausedBanner
@@ -1,4 +1,5 @@
1
1
  import { memo, useContext, type MouseEvent } from "react";
2
+ import { QuickShare } from "./share/QuickShare";
2
3
  import { Camera } from "../icons/SystemIcons";
3
4
  import { useStudioShellContext } from "../contexts/StudioContext";
4
5
  import { usePanelLayoutContext } from "../contexts/PanelLayoutContext";
@@ -19,6 +20,7 @@ interface StudioHeaderProps {
19
20
  inspectorButtonActive: boolean;
20
21
  inspectorPanelActive: boolean;
21
22
  onExport?: () => void;
23
+ beforeShare?: () => Promise<void>;
22
24
  }
23
25
 
24
26
  /**
@@ -45,6 +47,7 @@ export const StudioHeader = memo(function StudioHeader({
45
47
  inspectorButtonActive,
46
48
  inspectorPanelActive,
47
49
  onExport,
50
+ beforeShare,
48
51
  }: StudioHeaderProps) {
49
52
  const showThemeToggle = useContext(ShowThemeToggle);
50
53
  const { projectId, renderQueue } = useStudioShellContext();
@@ -153,6 +156,7 @@ export const StudioHeader = memo(function StudioHeader({
153
156
  {showThemeToggle && <ThemeToggle />}
154
157
  <Dock.WindowMenu />
155
158
  <OpenInDesktopButton />
159
+ <QuickShare beforeShare={beforeShare} />
156
160
  <Tooltip
157
161
  label={
158
162
  ffmpegMissing
@@ -0,0 +1,548 @@
1
+ // @vitest-environment happy-dom
2
+ import React, { act } from "react";
3
+ import { createRoot, type Root } from "react-dom/client";
4
+ import { afterEach, beforeEach, expect, it, vi } from "vitest";
5
+ import type { LocalShareSnapshot, LocalShareJob } from "@hyperframes/studio-server";
6
+ import type { Button } from "../ui/Button";
7
+ type ButtonProps = React.ComponentProps<typeof Button>;
8
+
9
+ const interaction = vi.hoisted(() => vi.fn());
10
+ vi.mock("./localShareTelemetry", () => ({ shareInteraction: interaction }));
11
+ vi.mock("../ui", () => ({
12
+ Button: ({ children, variant: _variant, ...props }: ButtonProps) => (
13
+ <button {...props}>{children}</button>
14
+ ),
15
+ Menu: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
16
+ MenuRadioGroup: ({
17
+ children,
18
+ value,
19
+ onValueChange,
20
+ }: {
21
+ children: React.ReactNode;
22
+ value: string;
23
+ onValueChange: (value: string) => void;
24
+ }) => (
25
+ <select
26
+ aria-label="Who can access"
27
+ value={value}
28
+ onChange={(event) => onValueChange(event.target.value)}
29
+ >
30
+ <option value="">Choose access</option>
31
+ {children}
32
+ </select>
33
+ ),
34
+ MenuRadioItem: ({ value, disabled }: { value: string; disabled?: boolean }) => (
35
+ <option value={value} disabled={disabled}>
36
+ {value === "private" ? "Only you" : value}
37
+ </option>
38
+ ),
39
+ Popover: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
40
+ }));
41
+ const { QuickShare, QuickShareContent } = await import("./QuickShare");
42
+ Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", true);
43
+ let root: Root;
44
+ let host: HTMLDivElement;
45
+ let snapshot: LocalShareSnapshot;
46
+ let calls: unknown[];
47
+ let job: LocalShareJob;
48
+ const token = "a".repeat(43);
49
+ beforeEach(() => {
50
+ interaction.mockReset();
51
+ calls = [];
52
+ snapshot = {
53
+ versionSharing: true,
54
+ share: {
55
+ source: "not_checked",
56
+ state: "not_shared",
57
+ url: null,
58
+ manageUrl: "https://hyperframes.dev/shares",
59
+ changed: false,
60
+ audience: null,
61
+ spaceId: null,
62
+ },
63
+ spaces: [
64
+ {
65
+ id: "team1",
66
+ name: "Design team",
67
+ bound: true,
68
+ canCreate: true,
69
+ audiences: ["public", "private", "invite"],
70
+ used: 5,
71
+ limit: 5,
72
+ },
73
+ ],
74
+ job: null,
75
+ };
76
+ job = { id: "job1", state: "running", step: "uploading", result: null, error: null };
77
+ host = document.createElement("div");
78
+ document.body.append(host);
79
+ root = createRoot(host);
80
+ vi.stubGlobal(
81
+ "fetch",
82
+ vi.fn(async (url: string, init?: RequestInit) => {
83
+ expect(new Headers(init?.headers).get("X-Hyperframes-Share-CSRF")).toBe(token);
84
+ if (url.endsWith("/snapshot")) return Response.json(snapshot);
85
+ if (url.endsWith("/actions")) {
86
+ calls.push(JSON.parse(String(init?.body)));
87
+ return Response.json(job, { status: 202 });
88
+ }
89
+ return Response.json(job);
90
+ }),
91
+ );
92
+ });
93
+ afterEach(() => {
94
+ act(() => root.unmount());
95
+ host.remove();
96
+ vi.unstubAllGlobals();
97
+ vi.useRealTimers();
98
+ });
99
+ const button = (label: string) =>
100
+ [...host.querySelectorAll("button")].find((element) => element.textContent === label);
101
+ async function mount(beforeShare?: () => Promise<void>) {
102
+ await act(async () => root.render(<QuickShareContent token={token} beforeShare={beforeShare} />));
103
+ }
104
+ async function choose(value: string) {
105
+ const select = host.querySelector<HTMLSelectElement>('[aria-label="Who can access"]');
106
+ if (!select) throw new Error("Missing audience");
107
+ await act(async () => {
108
+ select.value = value;
109
+ select.dispatchEvent(new Event("change", { bubbles: true }));
110
+ });
111
+ }
112
+ it("requires explicit audience, uses the bound workspace and permits server-authoritative quota retries", async () => {
113
+ await mount();
114
+ expect(host.textContent).toContain("5 of 5 free share links used");
115
+ expect(button("Create share link")?.disabled).toBe(true);
116
+ expect(calls).toEqual([]);
117
+ await choose("public");
118
+ expect(button("Create share link")?.disabled).toBe(false);
119
+ await act(async () => button("Create share link")?.click());
120
+ expect(calls).toEqual([{ action: "share", audience: "public", space: "team1" }]);
121
+ });
122
+ it("drains pending editor saves before creating or uploading", async () => {
123
+ let resolveSave = () => {};
124
+ const save = vi.fn(
125
+ () =>
126
+ new Promise<void>((resolve) => {
127
+ resolveSave = resolve;
128
+ }),
129
+ );
130
+ await mount(save);
131
+ await choose("public");
132
+ await act(async () => button("Create share link")?.click());
133
+ expect(save).toHaveBeenCalledOnce();
134
+ expect(calls).toEqual([]);
135
+ await act(async () => resolveSave());
136
+ expect(calls).toHaveLength(1);
137
+ });
138
+ it("does not publish when saving fails", async () => {
139
+ await mount(async () => {
140
+ throw new Error("write failed");
141
+ });
142
+ await choose("public");
143
+ await act(async () => button("Create share link")?.click());
144
+ expect(calls).toEqual([]);
145
+ expect(host.querySelector('[role="alert"]')).not.toBeNull();
146
+ });
147
+ it("shows stale copy separately and never uploads merely by opening", async () => {
148
+ snapshot.share = {
149
+ ...snapshot.share,
150
+ state: "ready",
151
+ url: "https://hyperframes.dev/r/live",
152
+ changed: true,
153
+ audience: "private",
154
+ spaceId: "team1",
155
+ };
156
+ await mount();
157
+ expect(button("Copy current shared link")).toBeDefined();
158
+ expect(calls).toEqual([]);
159
+ await act(async () => button("Update shared version")?.click());
160
+ expect(calls).toEqual([{ action: "update" }]);
161
+ });
162
+ it("keeps link-off updates separate from explicit re-enabling", async () => {
163
+ snapshot.share = { ...snapshot.share, state: "link_off", audience: "private", spaceId: "team1" };
164
+ await mount();
165
+ expect(button("Turn link on")).toBeDefined();
166
+ await act(async () => button("Update shared version")?.click());
167
+ expect(calls).toEqual([{ action: "update" }]);
168
+ });
169
+ it("recovers a running job on reopening, and stops browser polling on close", async () => {
170
+ vi.useFakeTimers();
171
+ snapshot.job = job;
172
+ await mount();
173
+ expect(host.textContent).toContain("Uploading your video");
174
+ expect(calls).toEqual([]);
175
+ await act(async () => root.render(null));
176
+ const before = vi.mocked(fetch).mock.calls.length;
177
+ await act(async () => vi.advanceTimersByTime(3000));
178
+ expect(vi.mocked(fetch).mock.calls.length).toBe(before);
179
+ await mount();
180
+ expect(host.textContent).toContain("Uploading your video");
181
+ expect(calls).toEqual([]);
182
+ });
183
+ it("hides creation while feature is off but keeps existing management", async () => {
184
+ snapshot.versionSharing = false;
185
+ snapshot.share = { ...snapshot.share, state: "link_off", audience: "private", spaceId: "team1" };
186
+ await mount();
187
+ expect(button("Update shared version")).toBeUndefined();
188
+ expect(button("Turn link on")).toBeDefined();
189
+ });
190
+ it("recovers a failed job on reopening instead of silently dropping the error", async () => {
191
+ snapshot.job = {
192
+ ...job,
193
+ state: "failed",
194
+ error: { code: "share_failed", message: "The upload failed. Try again." },
195
+ };
196
+ await mount();
197
+ expect(host.querySelector('[role="alert"]')?.textContent).toContain("The upload failed");
198
+ expect(calls).toEqual([]);
199
+ });
200
+
201
+ it("offers video-only recovery explicitly after a failed source upload", async () => {
202
+ snapshot.share = {
203
+ ...snapshot.share,
204
+ state: "processing",
205
+ audience: "private",
206
+ spaceId: "team1",
207
+ };
208
+ snapshot.job = {
209
+ ...job,
210
+ state: "failed",
211
+ error: { code: "source_unavailable", message: "Project files could not be attached." },
212
+ };
213
+ await mount();
214
+ expect(calls).toEqual([]);
215
+ await act(async () => button("Retry with video only")?.click());
216
+ expect(calls).toEqual([{ action: "update", videoOnly: true }]);
217
+ });
218
+ it("labels files as included only after a ready upload result", async () => {
219
+ snapshot.job = {
220
+ ...job,
221
+ state: "done",
222
+ result: { ...snapshot.share, state: "ready", source: "ready" },
223
+ };
224
+ await mount();
225
+ expect(host.textContent).toContain("Last Studio upload: project files included.");
226
+ });
227
+ it.each(["unauthenticated", "login_expired"])(
228
+ "offers explicit browser login for %s and recovers signed-out polling",
229
+ async (code) => {
230
+ vi.stubGlobal(
231
+ "fetch",
232
+ vi.fn(async (url: string, init?: RequestInit) => {
233
+ if (url.endsWith("/actions")) {
234
+ calls.push(JSON.parse(String(init?.body)));
235
+ return Response.json({ ...job, step: "signing_in" });
236
+ }
237
+ return Response.json({ code, message: "Sign in to share.", job: null }, { status: 400 });
238
+ }),
239
+ );
240
+ await mount();
241
+ expect(calls).toEqual([]);
242
+ expect(button("Sign in")).toBeDefined();
243
+ await act(async () => button("Sign in")?.click());
244
+ expect(calls).toEqual([{ action: "login" }]);
245
+ expect(host.textContent).toContain("Finish signing in in your browser");
246
+ },
247
+ );
248
+
249
+ it("records a copy only after the clipboard succeeds and opening once per panel", async () => {
250
+ snapshot.share = {
251
+ ...snapshot.share,
252
+ state: "ready",
253
+ url: "https://hyperframes.dev/r/old",
254
+ audience: "private",
255
+ spaceId: "team1",
256
+ };
257
+ const copy = vi.spyOn(navigator.clipboard, "writeText");
258
+ copy.mockRejectedValueOnce(new Error("denied")).mockResolvedValue(undefined);
259
+ await mount();
260
+ expect(interaction).toHaveBeenCalledExactlyOnceWith(token, {
261
+ event: "share_opened",
262
+ link: "live",
263
+ });
264
+ await act(async () => button("Copy link")?.click());
265
+ expect(interaction).toHaveBeenCalledTimes(1);
266
+ await act(async () => button("Copy link")?.click());
267
+ expect(interaction).toHaveBeenLastCalledWith(token, { event: "share_link_copied", via: "copy" });
268
+ expect(calls).toEqual([]);
269
+ copy.mockRestore();
270
+ });
271
+
272
+ it("clears account-specific links and workspace controls after an identity failure", async () => {
273
+ snapshot.share = {
274
+ ...snapshot.share,
275
+ state: "ready",
276
+ url: "https://hyperframes.dev/r/private",
277
+ audience: "private",
278
+ spaceId: "team1",
279
+ };
280
+ await mount();
281
+ expect(button("Copy link")).toBeDefined();
282
+ vi.mocked(fetch).mockResolvedValue(
283
+ Response.json({ code: "login_changed", message: "Your login changed" }, { status: 400 }),
284
+ );
285
+ await act(async () => button("Update shared version")?.click());
286
+ expect(button("Copy link")).toBeUndefined();
287
+ expect(button("Update shared version")).toBeUndefined();
288
+ expect(host.querySelector('[aria-label="Sharing workspace"]')).toBeNull();
289
+ expect(host.textContent).not.toContain("Design team");
290
+ expect(button("Sign in")).toBeDefined();
291
+ });
292
+
293
+ it("does not claim an older upload is current when its portable content identity is unknown", async () => {
294
+ snapshot.share = {
295
+ ...snapshot.share,
296
+ state: "ready",
297
+ changed: null,
298
+ url: "https://hyperframes.dev/r/live",
299
+ };
300
+ await mount();
301
+ expect(button("Copy current shared link")).toBeDefined();
302
+ expect(host.textContent).toContain("Changes after your last upload aren’t shared automatically");
303
+ });
304
+
305
+ it("continues from a running browser login to fresh controls without refreshing or publishing", async () => {
306
+ vi.useFakeTimers();
307
+ let signedIn = false;
308
+ const loginJob = { ...job, step: "signing_in" };
309
+ vi.mocked(fetch).mockImplementation(async (url, init) => {
310
+ const path = String(url);
311
+ if (path.endsWith("/actions")) {
312
+ calls.push(JSON.parse(String(init?.body)));
313
+ return Response.json(loginJob, { status: 202 });
314
+ }
315
+ if (path.includes("/jobs/"))
316
+ return Response.json(
317
+ signedIn ? { ...loginJob, state: "done", result: snapshot.share } : loginJob,
318
+ );
319
+ return signedIn
320
+ ? Response.json({ ...snapshot, job: { ...loginJob, state: "done", result: snapshot.share } })
321
+ : Response.json({ code: "login_expired", message: "Sign in again." }, { status: 400 });
322
+ });
323
+ await mount();
324
+ await act(async () => button("Sign in")?.click());
325
+ await act(async () => vi.advanceTimersByTime(1000));
326
+ expect(host.textContent).toContain("Finish signing in");
327
+ signedIn = true;
328
+ await act(async () => vi.advanceTimersByTime(1000));
329
+ expect(button("Sign in")).toBeUndefined();
330
+ expect(host.querySelector('[aria-label="Who can access"]')).not.toBeNull();
331
+ expect(button("Create share link")?.disabled).toBe(true);
332
+ expect(calls).toEqual([{ action: "login" }]);
333
+ });
334
+
335
+ it.each(["snapshot", "poll"])(
336
+ "reconnects on return after a %s error without a refresh press",
337
+ async (failureAt) => {
338
+ vi.useFakeTimers();
339
+ let restored = false;
340
+ snapshot.job = failureAt === "poll" ? { ...job, step: "signing_in" } : null;
341
+ vi.mocked(fetch).mockImplementation(async (url) => {
342
+ if (restored) return Response.json({ ...snapshot, job: null });
343
+ if (failureAt === "snapshot")
344
+ return Response.json({ code: "login_expired", message: "Sign in again." }, { status: 400 });
345
+ if (String(url).includes("/jobs/")) throw new Error("Connection lost");
346
+ return Response.json(snapshot);
347
+ });
348
+ await mount();
349
+ if (failureAt === "poll") await act(async () => vi.advanceTimersByTime(1000));
350
+ restored = true;
351
+ await act(async () => window.dispatchEvent(new Event("focus")));
352
+ expect(host.querySelector('[aria-label="Who can access"]')).not.toBeNull();
353
+ expect(button("Create share link")?.disabled).toBe(true);
354
+ expect(calls).toEqual([]);
355
+ },
356
+ );
357
+
358
+ it("keeps audience choices when a healthy panel regains focus", async () => {
359
+ await mount();
360
+ await choose("invite");
361
+ const requests = vi.mocked(fetch).mock.calls.length;
362
+ await act(async () => window.dispatchEvent(new Event("focus")));
363
+ await act(async () => document.dispatchEvent(new Event("visibilitychange")));
364
+ expect(host.querySelector<HTMLSelectElement>('[aria-label="Who can access"]')?.value).toBe(
365
+ "invite",
366
+ );
367
+ expect(vi.mocked(fetch).mock.calls.length).toBe(requests);
368
+ expect(calls).toEqual([]);
369
+ });
370
+
371
+ it("does not send an authenticated sharing-admission refusal into another login loop", async () => {
372
+ vi.mocked(fetch).mockResolvedValue(
373
+ Response.json(
374
+ {
375
+ code: "sharing_not_admitted",
376
+ message:
377
+ "You're signed in, but sharing isn't accepting this sign-in. Try again later or contact support.",
378
+ },
379
+ { status: 400 },
380
+ ),
381
+ );
382
+ await mount();
383
+ expect(host.textContent).toContain("You're signed in");
384
+ expect(button("Sign in")).toBeUndefined();
385
+ expect(button("Create share link")).toBeUndefined();
386
+ expect(calls).toEqual([]);
387
+ });
388
+
389
+ it("shows retry only for recoverable errors, never a permanent refresh footer", async () => {
390
+ await mount();
391
+ expect(button("Refresh")).toBeUndefined();
392
+ expect(button("Try again")).toBeUndefined();
393
+ });
394
+
395
+ it.each(["login_expired", "sharing_not_admitted", "review_upload_origins_required"])(
396
+ "does not offer a misleading retry for %s",
397
+ async (code) => {
398
+ vi.mocked(fetch).mockResolvedValue(
399
+ Response.json({ code, message: "Unavailable" }, { status: 400 }),
400
+ );
401
+ await mount();
402
+ expect(button("Try again")).toBeUndefined();
403
+ },
404
+ );
405
+
406
+ it.each(["request", "job"])(
407
+ "restores the create action and audience after a failed %s",
408
+ async (failureAt) => {
409
+ await mount();
410
+ await choose("public");
411
+ const failed = {
412
+ ...job,
413
+ state: "failed" as const,
414
+ error: { code: "share_failed", message: "Cannot render" },
415
+ };
416
+ if (failureAt === "request")
417
+ vi.mocked(fetch).mockResolvedValueOnce(Response.json(failed.error, { status: 400 }));
418
+ else {
419
+ job = failed;
420
+ snapshot.job = failed;
421
+ }
422
+ await act(async () => button("Create share link")?.click());
423
+ expect(button("Create share link")?.disabled).toBe(false);
424
+ expect(host.querySelector<HTMLSelectElement>('[aria-label="Who can access"]')?.value).toBe(
425
+ "public",
426
+ );
427
+ expect(button("Try again")).toBeUndefined();
428
+ expect(host.textContent).toContain("Cannot render");
429
+ },
430
+ );
431
+
432
+ it("uses the OAuth-selected workspace among several without a dropdown", async () => {
433
+ snapshot.spaces.unshift({ ...snapshot.spaces[0]!, id: "other", name: "Other", bound: false });
434
+ await mount();
435
+ expect(host.querySelector('[aria-label="Sharing workspace"]')).toBeNull();
436
+ await choose("public");
437
+ await act(async () => button("Create share link")?.click());
438
+ expect(calls).toEqual([{ action: "share", audience: "public", space: "team1" }]);
439
+ });
440
+ it("refuses to substitute another workspace when the OAuth selection is missing", async () => {
441
+ snapshot.spaces[0]!.bound = false;
442
+ await mount();
443
+ expect(button("Create share link")?.disabled).toBe(true);
444
+ expect(host.textContent).toContain("workspace selected at sign-in");
445
+ expect(calls).toEqual([]);
446
+ });
447
+
448
+ it("omits Only you for new shares but preserves an existing private audience", async () => {
449
+ await mount();
450
+ expect(host.querySelector('option[value="private"]')).toBeNull();
451
+ });
452
+ it("displays an existing private share without converting its audience", async () => {
453
+ snapshot.share = { ...snapshot.share, state: "ready", audience: "private", spaceId: "team1" };
454
+ await mount();
455
+ expect(host.querySelector<HTMLSelectElement>('[aria-label="Who can access"]')?.value).toBe(
456
+ "private",
457
+ );
458
+ expect(host.textContent).toContain("Only you");
459
+ expect(calls).toEqual([]);
460
+ });
461
+
462
+ it("resumes a failed first creation without presenting an uploaded version", async () => {
463
+ snapshot.share = {
464
+ ...snapshot.share,
465
+ state: "processing",
466
+ audience: "public",
467
+ spaceId: "team1",
468
+ hasReadyVersion: false,
469
+ };
470
+ snapshot.job = {
471
+ ...job,
472
+ state: "failed",
473
+ error: { code: "source_unavailable", message: "Project files could not upload" },
474
+ };
475
+ await mount();
476
+ expect(button("Create share link")?.disabled).toBe(false);
477
+ expect(button("Update shared version")).toBeUndefined();
478
+ expect(host.textContent).not.toContain("still being prepared");
479
+ await act(async () => button("Create share link")?.click());
480
+ expect(calls).toEqual([{ action: "update" }]);
481
+ });
482
+
483
+ it.each(["free", "subscribed", null] as const)(
484
+ "shows the Pro CTA only for authoritative free entitlement: %s",
485
+ async (plan) => {
486
+ snapshot.spaces[0]!.plan = plan;
487
+ snapshot.spaces[0]!.upgradeUrl = "https://hyperframes.dev/pricing";
488
+ await mount();
489
+ const link = [...host.querySelectorAll("a")].find((a) =>
490
+ a.textContent?.includes("Upgrade to Pro"),
491
+ );
492
+ if (plan === "free") expect(link?.href).toBe("https://hyperframes.dev/pricing");
493
+ else expect(link).toBeUndefined();
494
+ },
495
+ );
496
+ it("refuses an upgrade destination outside the public pricing flow", async () => {
497
+ snapshot.spaces[0]!.plan = "free";
498
+ snapshot.spaces[0]!.upgradeUrl = "https://example.com/checkout";
499
+ await mount();
500
+ expect(host.textContent).not.toContain("Upgrade to Pro");
501
+ });
502
+
503
+ it.each([false, true])(
504
+ "shows a persisted failed export after reopen (previous version: %s)",
505
+ async (previous) => {
506
+ snapshot.share = {
507
+ ...snapshot.share,
508
+ state: "failed",
509
+ failure: "This video can't be shared.",
510
+ hasReadyVersion: previous,
511
+ changed: true,
512
+ audience: "public",
513
+ spaceId: "team1",
514
+ url: previous ? "https://hyperframes.dev/r/previous" : null,
515
+ };
516
+ await mount();
517
+ expect(host.querySelector('[role="alert"]')?.textContent).toBe("This video can't be shared.");
518
+ expect(host.textContent).not.toContain("still being prepared");
519
+ expect(calls).toEqual([]);
520
+ const action = button(previous ? "Update shared version" : "Create share link");
521
+ expect(action?.disabled).toBe(false);
522
+ if (previous) expect(button("Copy current shared link")).toBeDefined();
523
+ await act(async () => action?.click());
524
+ expect(calls).toEqual([{ action: "update" }]);
525
+ },
526
+ );
527
+
528
+ it("does not probe unsupported Studio hosts for the CLI sharing bridge", async () => {
529
+ await act(async () => root.render(<QuickShare />));
530
+ expect(fetch).not.toHaveBeenCalled();
531
+ });
532
+
533
+ it("bootstraps sharing when the CLI advertises its bridge", async () => {
534
+ const marker = document.createElement("meta");
535
+ marker.name = "hyperframes-local-share";
536
+ marker.content = "1";
537
+ document.head.append(marker);
538
+ vi.mocked(fetch).mockResolvedValue(Response.json({ csrf: token }));
539
+ try {
540
+ await act(async () => root.render(<QuickShare />));
541
+ expect(fetch).toHaveBeenCalledWith(
542
+ "/api/share/bootstrap",
543
+ expect.objectContaining({ method: "GET" }),
544
+ );
545
+ } finally {
546
+ marker.remove();
547
+ }
548
+ });