1
0

feat: stream private office screens

This commit is contained in:
2026-08-11 21:31:15 -07:00
parent d841575315
commit 5ca214e4bb
28 changed files with 1754 additions and 35 deletions
+47 -1
View File
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { createOfficeScreenPanel, type MediaSurfaceDescriptor } from "../media/index.ts";
import { createOfficeScreenPanel } from "../media/officeScreenPanel.ts";
import type { MediaSurfaceDescriptor } from "../media/presentation.ts";
type Listener = (event: FakeEvent) => void;
class FakeEvent {
@@ -121,6 +122,18 @@ describe("office screen manager panel", () => {
assert.equal("mediaDevices" in panel, false);
});
it("keeps presenting separate from viewer opt-in", () => {
const { panel, shares, opts } = setup();
panel.open();
const root = panel.root as unknown as FakeElement;
const share = root.find("data-action", "share");
assert.equal(share.disabled, false);
share.dispatch("click");
assert.deepEqual(shares, ["lobby-monitor"]);
assert.deepEqual(opts, []);
assert.deepEqual(panel.state().optedInScreenIds, []);
});
it("updates defensively, removes stale consent, and represents an empty office", () => {
const { panel } = setup();
const root = panel.root as unknown as FakeElement;
@@ -136,6 +149,39 @@ describe("office screen manager panel", () => {
assert.match(root.text(), /No authored office screens/);
});
it("shows concise remote lifecycle states and forgets them with their screen", () => {
const { panel, stops, opts } = setup();
const root = panel.root as unknown as FakeElement;
root.find("data-action", "opt-in").dispatch("click");
panel.setRemoteStatus("lobby-monitor", "connecting");
assert.equal(panel.state().remoteStatusByScreen["lobby-monitor"], "connecting");
assert.match(root.text(), /Remote connecting/);
assert.equal(root.find("data-action", "stop").disabled, false);
root.find("data-action", "stop").dispatch("click");
assert.deepEqual(stops, ["lobby-monitor"]);
panel.setRemoteStatus("lobby-monitor", "unavailable");
assert.match(root.text(), /No remote share/);
assert.equal(root.find("data-action", "opt-in").textContent, "Retry remote");
root.find("data-action", "opt-in").dispatch("click");
assert.deepEqual(opts.at(-1), ["lobby-monitor", true]);
assert.deepEqual(panel.state().optedInScreenIds, ["lobby-monitor"]);
panel.update([SURFACES[1]!]);
assert.deepEqual(panel.state().remoteStatusByScreen, {});
assert.throws(() => panel.setRemoteStatus("commons-display", "invalid" as "live"), /invalid remote status/);
});
it("refreshes a remote surface from bound back to cleared", () => {
const { panel } = setup();
const root = panel.root as unknown as FakeElement;
panel.setRemoteStatus("lobby-monitor", "live");
panel.update([{ ...SURFACES[0]!, bound: true }, SURFACES[1]!]);
assert.match(root.text(), /Media active · Remote live/);
panel.update(SURFACES);
panel.setRemoteStatus("lobby-monitor", "off");
assert.match(root.text(), /Media off · Remote off/);
assert.equal(root.find("data-action", "stop").disabled, true);
});
it("traps tab focus, closes on Escape, restores focus, and disposes idempotently", () => {
const { document, container, panel } = setup();
const trigger = document.createElement("button");