Per explicit feedback on full-v10: the "SIGNED EVENT LOG - LIVE" terminal panel (hex hash, type/fields JSON line, blinking cursor) and the per-app frozen-still hold are both gone. - buildComposition.mjs: removed layoutAppStage's static-snapshot hold + extractAppClips() entirely; each app's window now plays its own real captured clip continuously. Per-app text is a single large/bold/short plain-language headline with an optional small event-type pill - no hash/JSON/monospace anywhere. - tour.mjs: added app-<id>-start/-end marks around all 13 mini-apps plus a linger() helper (real scroll + :hover motion, never a held frame) so a from-scratch recapture can give each app a dedicated, longer real clip. Also fixed a real flake: ShellLayout's boot-time auto-seed means the Admin page's demo-load status now usually reads "already loaded", not "Demo data loaded" - the beat's waitFor accepts both. - capture.mjs: CLIP_SPEC slices one real clip per mini-app via the new marks (replacing the old 3 giant per-act blobs) for that recapture path. - src/lib/farms.ts: fixed a real LP-solver bug surfaced while recapturing - a crop with kWhPerM2: 0 under any positive energyBudgetKwh produced a false "infeasible" (an all-zero-coefficient constraint row breaks javascript-lp-solver's simplex solve). Now the energy constraint is only added when some eligible crop actually draws power. Regression test added. SHIP-NOW NOTE: the from-scratch recapture (dedicated 8-12s real dwell per app) hit an additional intermittent Health Post hang under deadline pressure; full-v11 instead reuses the already-captured, already-verified act1/act2/act3 footage, playing each app's own real sub-window continuously (old, shorter per-app dwell - disclosed, not padded with any hold). A true recapture with longer dwell is the follow-up.
671 lines
33 KiB
JavaScript
671 lines
33 KiB
JavaScript
// STAGE-2 OpenMotion full main-tour: shared tour-script module.
|
|
//
|
|
// This is the SINGLE source of the full main-tour beat sequence for the
|
|
// OpenMotion pipeline (`capture.mjs` drives it, `buildComposition.mjs`
|
|
// reads its exported title-card copy + Wave-1 callouts to template the
|
|
// composition). It drives the REAL shipped app through its REAL rendered
|
|
// UI on ONE continuous Playwright page/context (same viewport, same 2x
|
|
// device scale, same recordVideo mechanism, same event-log continuity as
|
|
// `e2e/demoVideoFull.e2e.mjs`'s recordMainScene()), covering Acts I-III of
|
|
// the real tour and stopping right before the Epilogue (Stage-2 scope).
|
|
//
|
|
// It does NOT import or modify demoVideoFull.e2e.mjs. That file could not
|
|
// be reused directly: it is not an ES module with exports (its
|
|
// recordMainScene() is a private function and the module self-invokes
|
|
// main() on import, which would trigger a full real render), AND its
|
|
// recordMainScene() bundles a playwright-recast motion-graphics pass +
|
|
// act-title-cards-baked-into-the-phone-footage that the OpenMotion
|
|
// pipeline deliberately REPLACES with GSAP compositing. So this module is
|
|
// the clean, exportable capture core the OpenMotion pipeline owns; when
|
|
// demoVideoFull.e2e.mjs is next edited it can `import { runTour }` from
|
|
// here to retire its own inline copy (that edit is out of scope this
|
|
// stage - the file is explicitly off-limits).
|
|
//
|
|
// The act-title-card copy below is byte-for-byte the same in-universe text
|
|
// as demoVideoFull.e2e.mjs's intro `renderTitleCard()` + `showActTitleCard()`
|
|
// calls; the Wave-1 callouts are the same real narration substrings its
|
|
// `WAVE1_FIX_CALLOUTS` cites. They live here so the OpenMotion margin +
|
|
// title cards are templated from one place, never re-typed into the HTML.
|
|
|
|
// ---------------------------------------------------------------------
|
|
// In-universe title-card copy (verbatim from demoVideoFull.e2e.mjs). The
|
|
// OpenMotion composition renders these as full-screen GSAP title cards
|
|
// between act footage segments - the OpenMotion equivalent of the real
|
|
// tour's intro renderTitleCard() + inter-act showActTitleCard() cards.
|
|
// ---------------------------------------------------------------------
|
|
export const TITLE_CARDS = {
|
|
intro: {
|
|
eyebrow: "One shelter in the Hollow, tonight",
|
|
title: "Who do you trust when the water turns bad?",
|
|
tagline: "4,200 residents in this shelter, cut off from the surface - one self-hosted record, no outside cloud, no central login.",
|
|
},
|
|
act1: {
|
|
eyebrow: "Act I",
|
|
title: "A Crisis, Verified Twice",
|
|
tagline:
|
|
"Bad water, blackouts and flooded tunnels hit the deep levels first. The Commons catches the water before anyone drinks it, splits what's left, and reroutes around the flood.",
|
|
},
|
|
act2: {
|
|
eyebrow: "Act II",
|
|
title: "Keeping the Hollow Alive",
|
|
tagline:
|
|
"Food cut off, rooms meant for one, medicine gone, a life with no sun. The Commons grows, assigns, triages and measures what the Directorate won't.",
|
|
},
|
|
act3: {
|
|
eyebrow: "Act III",
|
|
title: "Who Decides",
|
|
tagline:
|
|
"The Directorate controls the network and can shut it down. The Commons keeps the vote running, the lottery honest, and the Hollow's real mood in the open.",
|
|
},
|
|
// Stage-3 Epilogue + outro cards. Byte-for-byte the same in-universe copy
|
|
// as demoVideoFull.e2e.mjs's Epilogue showActTitleCard() call and its
|
|
// addMotionGraphics() outro renderTitleCard() call (the "The Commons"
|
|
// closing statement). Same card mechanic Stage 2 proved for Act I/II/III.
|
|
epilogue: {
|
|
eyebrow: "Epilogue",
|
|
title: "Trust, Made Verifiable",
|
|
tagline:
|
|
"No server underground to take on faith. Every balance re-checks its own signature - and any resident can ship a new mini-app, no gatekeeper required.",
|
|
},
|
|
outro: {
|
|
eyebrow: "Built in 36 hours",
|
|
title: "The Commons",
|
|
tagline:
|
|
"One signed wallet, one shared record - every civic problem in the Hollow gets a real answer.",
|
|
},
|
|
};
|
|
|
|
// ---------------------------------------------------------------------
|
|
// Wave-1 fix callouts (right margin). These are the exact narration
|
|
// substrings demoVideoFull.e2e.mjs's WAVE1_FIX_CALLOUTS cites, and the
|
|
// beat notes below reference these same constants so the on-screen margin
|
|
// text can never drift from what the tour actually demonstrates.
|
|
// ---------------------------------------------------------------------
|
|
const CO_NO_FALSE_ALERT = "flat 2nd reading (7.0 -> 7.05) did NOT fire a false alert";
|
|
const CO_LOCALIZATION = "real pipe-graph leak localization named a suspected origin node";
|
|
const CO_FARMS = "real GDD + LP optimizer forecast (1 temp reading, 1 plot, 1 crop) -> 200.00 kg";
|
|
const CO_HOUSING = "the resident-facing 'Run assignment cycle' button recorded a new real housing.assignment cycle";
|
|
const CO_QV = "the QV tally is no longer stuck at zero (Wave-1 fix: QV credit granted on the real roster/proposal lifecycle)";
|
|
const CO_SKY = "a fast double-click produced exactly one entry, not two (GAP-20 fix)";
|
|
|
|
export const WAVE1_FIX_CALLOUTS = [
|
|
{ beat: "waterwatch-no-false-alert", text: CO_NO_FALSE_ALERT },
|
|
{ beat: "waterwatch-localization", text: CO_LOCALIZATION },
|
|
{ beat: "farms-forecast", text: CO_FARMS },
|
|
{ beat: "housing-run-cycle", text: CO_HOUSING },
|
|
{ beat: "assembly-qv-tally", text: CO_QV },
|
|
{ beat: "sky-post", text: CO_SKY },
|
|
];
|
|
|
|
// ---------------------------------------------------------------------
|
|
// Pacing. Real-time footage (no recast idle speed-up in this pipeline),
|
|
// so post-action reading holds are kept modest - long enough to read a
|
|
// settled screen, short enough to keep the tour tight.
|
|
// ---------------------------------------------------------------------
|
|
const SETTLE = 900; // brief settle after a quick action
|
|
const READ = 1700; // reading hold on a meaningful beat
|
|
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
|
// ---------------------------------------------------------------------
|
|
// Per-mini-app real dwell (REDESIGN: longer real footage, no freeze-frame).
|
|
// Each of the 13 mini-apps now gets its own api.mark() pair (app-<id>-start/
|
|
// app-<id>-end) so capture.mjs slices a DEDICATED real clip per app, long
|
|
// enough (~8-12s) to read a short blurb at normal pace. `linger()` fills any
|
|
// remaining real time with genuine, visible motion on the REAL rendered
|
|
// page - alternating scroll pulses (visible wherever a form/screen overflows
|
|
// the 414x896 viewport) plus a hover over the always-present "Back to home"
|
|
// link (a real CSS :hover transition) - never a held static frame.
|
|
// ---------------------------------------------------------------------
|
|
async function linger(page, ms) {
|
|
const backLink = page.getByRole("link", { name: "Back to home" });
|
|
const steps = Math.max(1, Math.round(ms / 550));
|
|
const per = ms / steps;
|
|
for (let i = 0; i < steps; i++) {
|
|
await page.mouse.wheel(0, i % 2 === 0 ? 140 : -140).catch(() => {});
|
|
if (i === 1) await backLink.hover({ timeout: 500 }).catch(() => {});
|
|
await sleep(per);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------
|
|
// Interaction pacing. The OpenMotion capture is REAL-TIME (no recast
|
|
// speed-up in this pipeline). Playwright's native .fill() populates a whole
|
|
// field in one instant, which made the FORM-HEAVY beats (Farms, Health Post,
|
|
// The Climb - a dozen fields each) blur past faster than a viewer could
|
|
// follow. The fix is targeted, not uniform: single taps / toggles / selects
|
|
// stay at ~normal speed (a tiny hold so a result is not a single frame), and
|
|
// the real slowdown is concentrated in TYPING - text is entered
|
|
// character-by-character so the multi-field forms are legibly followable.
|
|
// Idle/poll waits (waitFor, the SETTLE/READ reading holds) are untouched.
|
|
// ---------------------------------------------------------------------
|
|
const TAP_HOLD = 150; // brief hold after a tap so its result is not a single frame
|
|
const FIELD_HOLD = 220; // brief hold after a field is filled
|
|
const KEYSTROKE = 85; // per-character typing delay (visible typing on form fills)
|
|
|
|
async function tap(locator) {
|
|
await locator.click();
|
|
await sleep(TAP_HOLD);
|
|
}
|
|
async function type(locator, value) {
|
|
await locator.fill("");
|
|
await locator.pressSequentially(String(value), { delay: KEYSTROKE });
|
|
await sleep(FIELD_HOLD);
|
|
}
|
|
async function choose(locator, option) {
|
|
await locator.selectOption(option);
|
|
await sleep(TAP_HOLD);
|
|
}
|
|
async function check(locator) {
|
|
await locator.check();
|
|
await sleep(TAP_HOLD);
|
|
}
|
|
// Instant fill (not char-by-char) for inputs where keystroke typing is
|
|
// unreliable or meaningless on camera: native <input type="date"> and emoji.
|
|
async function setValue(locator, value) {
|
|
await locator.fill(value);
|
|
await sleep(FIELD_HOLD);
|
|
}
|
|
|
|
export async function waitFor(fn, label, timeoutMs = 35000) {
|
|
const start = Date.now();
|
|
let lastErr;
|
|
while (Date.now() - start < timeoutMs) {
|
|
try {
|
|
const v = await fn();
|
|
if (v) return v;
|
|
} catch (e) {
|
|
lastErr = e;
|
|
}
|
|
await sleep(150);
|
|
}
|
|
throw new Error(`timeout waiting for: ${label}${lastErr ? ` (last error: ${lastErr})` : ""}`);
|
|
}
|
|
|
|
async function walletBalanceText(page) {
|
|
return (await page.getByTestId("wallet-balance").textContent())?.trim();
|
|
}
|
|
async function openTile(page, label) {
|
|
await tap(page.getByRole("button", { name: label }));
|
|
await page.locator(`[aria-label="${label}"]`).first().waitFor({ state: "visible", timeout: 10000 });
|
|
}
|
|
async function backHome(page) {
|
|
await tap(page.getByRole("link", { name: "Back to home" }));
|
|
await page.getByRole("grid", { name: "Miniapps" }).waitFor({ state: "visible" });
|
|
}
|
|
|
|
// Mirrors e2e/fairDrawWalletCredit.e2e.mjs FILL_FOR_YOU_WINS exactly, so
|
|
// Fair Draw's real commit/reveal/verify cycle deterministically resolves
|
|
// to "You" winning on camera without touching any other real logic.
|
|
export async function forceLocalIdentityWinsFairDraw(context) {
|
|
await context.addInitScript(() => {
|
|
window.crypto.getRandomValues = function (arr) {
|
|
arr.fill(0x02);
|
|
return arr;
|
|
};
|
|
});
|
|
}
|
|
|
|
// Drives the full Acts I-III tour on one continuous page.
|
|
// api.mark(name) -> record the current clip-boundary offset
|
|
// api.beat(label, note) -> record a beat (timestamp + optional screenshot)
|
|
// The capture owns the clock; marks delimit the per-act footage clips the
|
|
// OpenMotion composition slices and composites.
|
|
export async function runTour(page, api, APP_URL) {
|
|
const { mark, beat } = api;
|
|
|
|
// --- Cold start: real non-custodial identity resolves, honest empty state ---
|
|
await page.goto(`${APP_URL}/`, { waitUntil: "load" });
|
|
await page.getByRole("grid", { name: "Miniapps" }).waitFor({ state: "visible" });
|
|
await waitFor(async () => (await walletBalanceText(page)) !== "--", "identity resolves (wallet leaves '--')");
|
|
// Boot/mount is complete here; the intro clip is sliced from this mark,
|
|
// trimming the (light-canvas, not white) first-paint frames.
|
|
await mark("gridReady");
|
|
await beat("cold-start", "fresh local Ed25519 identity resolved, honest empty home grid + wallet");
|
|
await sleep(READ);
|
|
|
|
// --- Admin: Load Hollow demo seed (real signed seed.* events) ---
|
|
// NOTE: ShellLayout auto-seeds the Hollow demo fixture on boot-mount
|
|
// whenever the Event Log is empty (src/shell/ShellLayout.tsx), so by the
|
|
// time this page visits /admin the fixture has typically already been
|
|
// loaded by the home-page visit above - the button's real status text is
|
|
// then "Demo data already loaded - no new events appended.", not the
|
|
// first-time "Demo data loaded" text. Both are real, successful outcomes
|
|
// of the same idempotent seed path (`loadHollowDemoFixture()`); accept
|
|
// either so this beat isn't a flaky race against the boot-time auto-seed.
|
|
await page.goto(`${APP_URL}/admin`, { waitUntil: "load" });
|
|
await tap(page.getByRole("button", { name: "Load Hollow demo" }));
|
|
await waitFor(
|
|
async () => {
|
|
const status = (await page.getByTestId("demo-load-status").textContent()) ?? "";
|
|
return status.includes("Demo data loaded") || status.includes("already loaded");
|
|
},
|
|
"demo seed load status",
|
|
);
|
|
await beat("admin-seed", "Load Hollow demo clicked - signed seed.* events appended");
|
|
await sleep(READ);
|
|
|
|
await page.goto(`${APP_URL}/`, { waitUntil: "load" });
|
|
await page.getByRole("grid", { name: "Miniapps" }).waitFor({ state: "visible" });
|
|
await sleep(SETTLE);
|
|
await mark("introEnd"); // end of intro footage / Act I title card goes here
|
|
|
|
// =================================================================
|
|
// ACT I: "A Crisis, Verified Twice"
|
|
// =================================================================
|
|
// --- Water Watch: GAP-8 false-alert fix + genuine corroborated detection ---
|
|
await openTile(page, "Water Watch");
|
|
await mark("app-waterwatch-start");
|
|
async function reportReading(sensorId, value) {
|
|
await type(page.getByTestId("report-reading-sensor"), sensorId);
|
|
await type(page.getByTestId("report-reading-value"), String(value));
|
|
await tap(page.getByTestId("report-reading-submit"));
|
|
await waitFor(
|
|
async () => !((await page.getByTestId("report-reading-status").textContent()) ?? "").includes("Submitting..."),
|
|
`submit ${sensorId}=${value} settles`,
|
|
);
|
|
}
|
|
await reportReading("kiosk-1", 7);
|
|
await sleep(300);
|
|
await reportReading("kiosk-1", 7.05);
|
|
const stateAfterFlat = await page.getByTestId("device-monitor-status-light-pH").getAttribute("data-state");
|
|
if (stateAfterFlat === "alert") {
|
|
throw new Error("REGRESSION: a flat 2nd reading triggered a false alert (GAP-8 fix did not hold)");
|
|
}
|
|
await beat("waterwatch-no-false-alert", `${CO_NO_FALSE_ALERT} - state is "${stateAfterFlat}", not "alert"`);
|
|
await sleep(READ);
|
|
|
|
await reportReading("kiosk-1", 50);
|
|
await waitFor(
|
|
async () => (await page.getByTestId("device-monitor-status-light-pH").getAttribute("data-state")) === "corroborating",
|
|
"pH channel reaches corroborating after a genuine spike",
|
|
);
|
|
await beat("waterwatch-corroborating", "genuine spike (7 -> 50) correctly flagged - awaiting a second independent sensor");
|
|
await sleep(SETTLE);
|
|
|
|
await reportReading("kiosk-2", 7);
|
|
await reportReading("kiosk-2", 55);
|
|
await waitFor(
|
|
async () => (await page.getByTestId("device-monitor-status-light-pH").getAttribute("data-state")) === "alert",
|
|
"pH channel reaches alert once corroborated",
|
|
);
|
|
await beat("waterwatch-alert", "independent kiosk-2 corroborated the spike - real signed alert, Fair Share re-solve triggered");
|
|
await sleep(READ);
|
|
|
|
await choose(page.getByTestId("device-monitor-my-tap"), { index: 1 });
|
|
await waitFor(
|
|
async () => (await page.getByTestId("device-monitor-origin-pH").count()) > 0,
|
|
"pipe-graph leak localization resolves a suspected origin",
|
|
);
|
|
await beat("waterwatch-localization", `${CO_LOCALIZATION}, with a live per-tap arrival countdown for the selected tap`);
|
|
await sleep(READ);
|
|
await linger(page, 1500);
|
|
await mark("app-waterwatch-end");
|
|
|
|
// --- Fair Share: water allocation re-solved ---
|
|
await backHome(page);
|
|
await openTile(page, "Fair Share");
|
|
await mark("app-fairshare-start");
|
|
await waitFor(async () => {
|
|
const text = (await page.getByTestId("tile-water-allocation").textContent()) ?? "";
|
|
return text.trim().length > 0 && text !== "No allocation yet";
|
|
}, "Fair Share water tile shows a real re-solved allocation");
|
|
await beat("fairshare-water", "Fair Share's water tile reflects the honesty-anchor chain's re-solved CEEI allocation");
|
|
await sleep(READ);
|
|
await linger(page, 6000);
|
|
await mark("app-fairshare-end");
|
|
|
|
// --- Tunnel Safety: real hazard report ---
|
|
await backHome(page);
|
|
await openTile(page, "Tunnel Safety");
|
|
await mark("app-tunnelsafety-start");
|
|
await tap(page.getByTestId("tunnel-safety-report-submit"));
|
|
await waitFor(
|
|
async () => ((await page.getByTestId("tunnel-safety-report-status-text").textContent()) ?? "").includes("Hazard reported"),
|
|
"hazard report submitted",
|
|
);
|
|
await beat("tunnelsafety", "real hazard report appended for the selected corridor segment");
|
|
await sleep(READ);
|
|
await linger(page, 6500);
|
|
await mark("app-tunnelsafety-end");
|
|
|
|
// --- Find Family: on-device PSI search ---
|
|
await backHome(page);
|
|
await openTile(page, "Find Family");
|
|
await mark("app-findfamily-start");
|
|
await type(page.getByTestId("findfamily-search-input"), "Ana Ramirez");
|
|
await tap(page.getByTestId("findfamily-search-button"));
|
|
await waitFor(
|
|
async () =>
|
|
(await page.getByTestId("findfamily-result-match").count()) > 0 ||
|
|
(await page.getByTestId("findfamily-result-nomatch").count()) > 0,
|
|
"PSI search resolves",
|
|
);
|
|
await beat("findfamily", "on-device private-set-intersection search resolved - the query never left the device");
|
|
await sleep(READ);
|
|
await linger(page, 6000);
|
|
await mark("app-findfamily-end");
|
|
|
|
await backHome(page);
|
|
await mark("act1End"); // Act II title card goes here
|
|
|
|
// =================================================================
|
|
// ACT II: "Keeping the Hollow Alive"
|
|
// =================================================================
|
|
// --- Farms -> Fair Share food edge ---
|
|
await openTile(page, "Farms");
|
|
await mark("app-farms-start");
|
|
await setValue(page.getByTestId("farms-temp-date"), "2026-05-01");
|
|
await type(page.getByTestId("farms-temp-tmin"), "10");
|
|
await type(page.getByTestId("farms-temp-tmax"), "30");
|
|
await tap(page.getByTestId("farms-temp-add"));
|
|
await type(page.getByTestId("farms-plot-id"), "plot-a");
|
|
await type(page.getByTestId("farms-plot-area"), "100");
|
|
await tap(page.getByTestId("farms-plot-add"));
|
|
await type(page.getByTestId("farms-crop-id"), "wheat");
|
|
await type(page.getByTestId("farms-crop-maturity-gdd"), "10");
|
|
await type(page.getByTestId("farms-crop-yield"), "2");
|
|
await type(page.getByTestId("farms-crop-kwh"), "0");
|
|
await tap(page.getByTestId("farms-crop-add"));
|
|
await waitFor(
|
|
async () => ((await page.getByTestId("farms-forecast-total").textContent()) ?? "").includes("200.00 kg"),
|
|
"Farms LP optimizer reaches a real 200.00 kg forecast",
|
|
);
|
|
await beat("farms-forecast", CO_FARMS);
|
|
await sleep(READ);
|
|
await linger(page, 3000);
|
|
await mark("app-farms-end");
|
|
|
|
await backHome(page);
|
|
await openTile(page, "Fair Share");
|
|
await waitFor(async () => {
|
|
const text = (await page.getByTestId("tile-food-allocation").textContent()) ?? "";
|
|
return text.trim().length > 0 && text !== "No allocation yet" && text.trim() !== "0";
|
|
}, "Fair Share food tile reflects the Farms forecast");
|
|
await beat("fairshare-food", "Farms' real forecast fed Fair Share's second cross-mini-app integration edge - food tile re-solved");
|
|
await sleep(READ);
|
|
|
|
// --- Housing ---
|
|
await backHome(page);
|
|
await openTile(page, "Housing");
|
|
await mark("app-housing-start");
|
|
await page.getByTestId("housing-assigned-slot").waitFor({ state: "visible" });
|
|
await beat("housing", "Housing shows a real assigned room slot from the seeded assignment cycle, not a permanent empty state");
|
|
await sleep(SETTLE);
|
|
|
|
await type(page.getByTestId("housing-report-space-id"), "common-room-3");
|
|
await type(page.getByTestId("housing-report-location"), "East wing, ground floor");
|
|
await tap(page.getByTestId("housing-report-submit"));
|
|
await waitFor(
|
|
async () => ((await page.getByTestId("housing-report-status-text").textContent()) ?? "").includes("Idle space reported"),
|
|
"idle space report submits",
|
|
);
|
|
await beat("housing-report-idle-space", "a resident reported a real idle space through the real form - available to the next assignment cycle");
|
|
await sleep(SETTLE);
|
|
|
|
await tap(page.getByTestId("housing-run-cycle"));
|
|
await waitFor(
|
|
async () => ((await page.getByTestId("housing-run-cycle-status").textContent()) ?? "").length > 0,
|
|
"resident-triggered assignment cycle runs",
|
|
);
|
|
await beat("housing-run-cycle", CO_HOUSING + " against the current fairness-debt ledger");
|
|
await sleep(READ);
|
|
await linger(page, 2000);
|
|
await mark("app-housing-end");
|
|
|
|
// --- Mentor ---
|
|
await backHome(page);
|
|
await openTile(page, "Mentor");
|
|
await mark("app-mentor-start");
|
|
await page.getByTestId("mentor-card-well-repair").waitFor({ state: "visible" });
|
|
await beat("mentor", "Mentor shows a real at-risk skill card (deduped dependents count) from the seeded skill-holder data");
|
|
await sleep(SETTLE);
|
|
|
|
await tap(page.getByTestId("mentor-rate-again-well-repair"));
|
|
await waitFor(async () => (await page.getByTestId("mentor-matches").count()) > 0, "the apprentice-match engine reacts to the new review");
|
|
await beat("mentor-apprentice-match", "rating yourself 'Again' created a real apprentice need; the real matching engine scores the mentor pool honestly");
|
|
await sleep(READ);
|
|
await linger(page, 5000);
|
|
await mark("app-mentor-end");
|
|
|
|
// --- Health Post: WHO-IMCI triage + referral ---
|
|
await backHome(page);
|
|
await openTile(page, "Health Post");
|
|
await mark("app-healthpost-start");
|
|
await type(page.getByTestId("triage-age-input"), "24");
|
|
await tap(page.getByTestId("triage-hasCough-yes"));
|
|
await type(page.getByTestId("triage-breathsPerMinute-input"), "45");
|
|
await tap(page.getByTestId("triage-chestIndrawing-no"));
|
|
await tap(page.getByTestId("triage-stridorWhenCalm-no"));
|
|
await tap(page.getByTestId("triage-hasDiarrhea-yes"));
|
|
await type(page.getByTestId("triage-durationDays-input"), "3");
|
|
await tap(page.getByTestId("triage-bloodInStool-no"));
|
|
await tap(page.getByTestId("triage-restlessOrIrritable-no"));
|
|
await tap(page.getByTestId("triage-sunkenEyes-no"));
|
|
await choose(page.getByTestId("triage-ableToDrink-select"), "normal");
|
|
await choose(page.getByTestId("triage-skinPinch-select"), "immediate");
|
|
await tap(page.getByTestId("triage-submit"));
|
|
await page.getByTestId("triage-result").waitFor({ state: "visible" });
|
|
const urgency = (await page.getByTestId("triage-urgency").textContent())?.trim();
|
|
await beat("healthpost-triage", `real WHO-IMCI classification from a full exam: "${urgency}"`);
|
|
await sleep(READ);
|
|
|
|
await tap(page.getByTestId("triage-send-referral"));
|
|
await page.getByTestId("triage-referral-sent").waitFor({ state: "visible" });
|
|
await beat("healthpost-send-to-clinician", "the real 'Send to clinician' button posted a signed healthpost.referral event to the clinician queue");
|
|
await sleep(READ);
|
|
await linger(page, 1000);
|
|
await mark("app-healthpost-end");
|
|
|
|
// --- Light Clock: manual sleep/wake log (honest no-sensor fallback) ---
|
|
await page.evaluate(() => {
|
|
delete window.DeviceMotionEvent;
|
|
});
|
|
await backHome(page);
|
|
await openTile(page, "Light Clock");
|
|
await mark("app-lightclock-start");
|
|
await tap(page.getByTestId("lightclock-enable-sensor"));
|
|
await page.getByTestId("lightclock-manual-hours").waitFor({ state: "visible" });
|
|
await beat("lightclock-manual-fallback", "no motion sensor available - the real sensor-first/manual-fallback contract switched to the manual log form");
|
|
await type(page.getByTestId("lightclock-manual-hours"), "8");
|
|
await choose(page.getByTestId("lightclock-manual-state"), "asleep");
|
|
await tap(page.getByTestId("lightclock-manual-add"));
|
|
await page.getByTestId("lightclock-manual-entries").locator("li").first().waitFor({ state: "visible" });
|
|
await tap(page.getByTestId("lightclock-manual-compute"));
|
|
await beat("lightclock", "manual sleep/wake log entry added and circadian status computed");
|
|
await sleep(READ);
|
|
await linger(page, 4500);
|
|
await mark("app-lightclock-end");
|
|
|
|
// --- The Climb: schedule inputs feeding the min-cost-flow engine ---
|
|
await backHome(page);
|
|
await openTile(page, "The Climb");
|
|
await mark("app-theclimb-start");
|
|
await type(page.getByTestId("theclimb-shaft-id"), "shaft-1");
|
|
await type(page.getByTestId("theclimb-shaft-from"), "D1");
|
|
await type(page.getByTestId("theclimb-shaft-to"), "surface");
|
|
await type(page.getByTestId("theclimb-shaft-capacity"), "20");
|
|
await type(page.getByTestId("theclimb-shaft-travel"), "2");
|
|
await tap(page.getByTestId("theclimb-shaft-add"));
|
|
await type(page.getByTestId("theclimb-demand-id"), "wave-1");
|
|
await type(page.getByTestId("theclimb-demand-sector"), "D1");
|
|
await type(page.getByTestId("theclimb-demand-ready-period"), "0");
|
|
await type(page.getByTestId("theclimb-demand-count"), "15");
|
|
await tap(page.getByTestId("theclimb-demand-add"));
|
|
await type(page.getByTestId("theclimb-capacity-period"), "0");
|
|
await type(page.getByTestId("theclimb-capacity-value"), "20");
|
|
await tap(page.getByTestId("theclimb-capacity-add"));
|
|
await beat("theclimb", "real shaft/wave-demand/surface-capacity schedule fed to the min-cost-flow congestion engine");
|
|
await sleep(READ);
|
|
await linger(page, 1500);
|
|
await mark("app-theclimb-end");
|
|
|
|
await backHome(page);
|
|
await mark("act2End"); // Act III title card goes here
|
|
|
|
// =================================================================
|
|
// ACT III: "Who Decides"
|
|
// =================================================================
|
|
// --- Assembly (single-user half): seeded roster/proposal + create/vote + QV ---
|
|
await openTile(page, "Assembly");
|
|
await mark("app-qvballot-start");
|
|
await page.getByTestId("assembly-sync-toggle").waitFor({ state: "visible" });
|
|
await beat("assembly-seeded", "demo-seeded roster (Aria, Kade) and an open proposal visible cold, no manual setup");
|
|
await sleep(SETTLE);
|
|
|
|
await type(page.getByTestId("assembly-create-proposal-title-input"), "Repave the common courtyard");
|
|
await type(page.getByTestId("assembly-create-proposal-description-input"), "The paving stones have cracked and are a tripping hazard.");
|
|
await tap(page.getByTestId("assembly-create-proposal-submit"));
|
|
await page.getByText("Repave the common courtyard").waitFor({ state: "visible" });
|
|
const proposalArticle = page.locator("article", { hasText: "Repave the common courtyard" }).first();
|
|
const proposalId = (await proposalArticle.getAttribute("data-testid"))?.replace("assembly-proposal-", "");
|
|
await beat("assembly-create-proposal", "a new proposal was created through the real form");
|
|
await sleep(SETTLE);
|
|
|
|
await type(page.getByTestId("assembly-add-resident-name-input"), "Nguyen");
|
|
await tap(page.getByTestId("assembly-add-resident-submit"));
|
|
await waitFor(
|
|
async () => (await page.locator('[data-testid^="assembly-roster-"]', { hasText: "Nguyen" }).count()) > 0,
|
|
"new resident appears on the roster",
|
|
);
|
|
await beat("assembly-add-resident", "a new resident was added to the roster through the real form");
|
|
await sleep(SETTLE);
|
|
|
|
if (proposalId) {
|
|
await tap(page.getByTestId(`assembly-vote-yes-${proposalId}`));
|
|
await waitFor(
|
|
async () => ((await page.getByTestId(`assembly-vote-status-${proposalId}`).textContent()) ?? "").includes("You voted Yes"),
|
|
"vote registers",
|
|
);
|
|
await beat("assembly-vote", "a direct vote was cast on the new proposal and the status readout updated live");
|
|
await sleep(SETTLE);
|
|
|
|
await tap(page.getByTestId(`assembly-qv-ballot-yes-${proposalId}`));
|
|
await waitFor(
|
|
async () => !((await page.getByTestId(`assembly-tally-yes-${proposalId}`).textContent()) ?? "").includes("Yes 0.00"),
|
|
"QV tally becomes non-zero after a real weighted ballot",
|
|
);
|
|
await beat("assembly-qv-tally", CO_QV);
|
|
await sleep(READ);
|
|
}
|
|
await linger(page, 1000);
|
|
await mark("app-qvballot-end");
|
|
|
|
// --- Fair Draw: real commit-reveal-verify -> real wallet credit ---
|
|
await backHome(page);
|
|
await openTile(page, "Fair Draw");
|
|
await mark("app-fairdraw-start");
|
|
await tap(page.getByRole("button", { name: "Start Draw" }));
|
|
await page.getByTestId("reveal-draw-commit-hash").waitFor({ state: "visible" });
|
|
const commitHash = (await page.getByTestId("reveal-draw-commit-hash").textContent())?.trim();
|
|
await beat("fairdraw-commit", `a signed commit hash was published BEFORE any reveal - "${commitHash?.slice(0, 16)}..." - re-rolling after this point is auditable and rejected`);
|
|
await sleep(READ);
|
|
|
|
await tap(page.getByRole("button", { name: "Reveal" }));
|
|
await page.getByTestId("reveal-draw-revealed").waitFor({ state: "visible" });
|
|
const winnerText = (await page.getByTestId("reveal-draw-winner").textContent())?.trim();
|
|
const badgeState = await page.getByTestId("reveal-draw-badge").getAttribute("data-state");
|
|
await beat("fairdraw-reveal", `real commit -> reveal -> verify cycle: "${winnerText}", badge state "${badgeState}"`);
|
|
await sleep(READ);
|
|
|
|
await waitFor(async () => (await walletBalanceText(page)) !== undefined, "wallet balance chip present on fair-draw route");
|
|
await beat("fairdraw-wallet-live", "WalletCard balance updates live on the same route, no reload, from the real Fair Draw win");
|
|
await sleep(SETTLE);
|
|
await linger(page, 6000);
|
|
await mark("app-fairdraw-end");
|
|
|
|
await tap(page.getByRole("link", { name: "Back to home" }));
|
|
await page.getByTestId("history-entry").first().waitFor({ state: "visible" });
|
|
await beat("fairdraw-history-row", "full transaction history now shows the real signed wallet.issue credit row");
|
|
await sleep(READ);
|
|
|
|
// --- Sky: memory-wall post + double-click guard (GAP-20) + mood pulse ---
|
|
// Already on home (fairdraw-history-row click landed here); no backHome.
|
|
await openTile(page, "Sky");
|
|
await mark("app-sky-start");
|
|
const skyMessage = "The sky over the Hollow turned amber tonight.";
|
|
await type(page.getByTestId("sky-memory-input"), skyMessage);
|
|
const countBefore = await page.getByTestId("sky-memory-list").locator("li").count().catch(() => 0);
|
|
await Promise.all([
|
|
page.getByTestId("sky-memory-submit").click(),
|
|
page.getByTestId("sky-memory-submit").click(),
|
|
]);
|
|
await waitFor(
|
|
async () => (await page.getByTestId("sky-memory-list").locator("li").count()) === countBefore + 1,
|
|
"exactly one memory-wall entry posted despite two synchronous clicks",
|
|
);
|
|
await beat("sky-post", "posted to the memory wall; " + CO_SKY);
|
|
await sleep(READ);
|
|
|
|
await choose(page.getByTestId("sky-mood-select"), { index: 1 });
|
|
await type(page.getByTestId("sky-mood-note"), "Tense, but the water's clean again.");
|
|
await tap(page.getByTestId("sky-mood-submit"));
|
|
await waitFor(async () => (await page.getByTestId("sky-mood-latest").count()) > 0, "mood pulse posts and the latest-pulse readout updates");
|
|
await beat("sky-mood-pulse", "a real signed mood/morale pulse was posted - the shelter's honest mood is now visible, aggregated from real signed events");
|
|
await sleep(READ);
|
|
await linger(page, 3000);
|
|
await mark("app-sky-end");
|
|
|
|
// Short calm end-hold on the posted mood, then close out Act III.
|
|
await sleep(500);
|
|
await mark("act3End"); // Epilogue title card goes here
|
|
|
|
// =================================================================
|
|
// EPILOGUE: "Trust, Made Verifiable" - the headline crypto feature
|
|
// (every wallet entry re-checks its own Ed25519 signature) plus the
|
|
// open-platform close (any resident can ship a mini-app, no gatekeeper).
|
|
// Same real footage + real app interaction as demoVideoFull.e2e.mjs's
|
|
// Epilogue beats; the Epilogue title card is rendered by the OpenMotion
|
|
// composition between the Act III clip and this clip.
|
|
// =================================================================
|
|
await backHome(page);
|
|
|
|
// --- Wallet signature verification (headline crypto feature) ---
|
|
await page.getByTestId("history-entry").first().waitFor({ state: "visible" });
|
|
const firstRow = page.getByTestId("history-entry").first();
|
|
const badge = firstRow.locator('[data-testid^="history-signature-badge-"]');
|
|
await waitFor(async () => ((await badge.textContent()) ?? "").trim() === "Verified", "signature badge resolves to Verified");
|
|
await beat("wallet-sig-verified", "independent verifyEntrySignature() re-check confirms the entry's Ed25519 signature is genuine");
|
|
await sleep(READ);
|
|
|
|
const sigToggle = firstRow.locator('[data-testid^="history-expand-toggle-"]');
|
|
await tap(sigToggle);
|
|
const sigDetail = firstRow.locator('[data-testid^="history-signature-detail-"]');
|
|
await sigDetail.waitFor({ state: "visible" });
|
|
await beat("wallet-sig-expanded", "raw Ed25519 signature + author public key bytes are directly inspectable, not just a claimed verification");
|
|
await sleep(READ);
|
|
await tap(sigToggle);
|
|
|
|
// --- Upload a mini-app (open platform, no gatekeeper) ---
|
|
// Already on the home route; ShellLayout hides "Back to home" on "/", so
|
|
// no backHome() here.
|
|
await tap(page.getByRole("button", { name: "+ Upload a mini-app" }));
|
|
await type(page.getByLabel("Mini-app name"), "Counter Widget");
|
|
await setValue(page.getByLabel("Icon (emoji or data URI)"), "\uD83D\uDD22");
|
|
await type(page.getByLabel("Entry point"), "index.html");
|
|
await check(page.getByLabel("ledger.read"));
|
|
await page.setInputFiles("#upload-html-file", {
|
|
name: "index.html",
|
|
mimeType: "text/html",
|
|
buffer: Buffer.from("<html><body><p>Counter Widget</p></body></html>"),
|
|
});
|
|
await beat("upload-form-filled", "real manifest form filled + a real HTML file attached via the real file input");
|
|
await sleep(SETTLE);
|
|
|
|
await tap(page.getByRole("button", { name: "Upload mini-app" }));
|
|
await page.getByTestId("upload-success").waitFor({ state: "visible" });
|
|
await beat("upload-success", "the real uploadMiniapp() storage path accepted the package");
|
|
await sleep(SETTLE);
|
|
|
|
await tap(page.getByRole("button", { name: "Go to home" }));
|
|
await page.getByRole("button", { name: "Counter Widget" }).waitFor({ state: "visible" });
|
|
await beat("upload-tile-appears", "the uploaded mini-app now appears as a real tile on the home grid");
|
|
await sleep(READ);
|
|
|
|
// Brief calm end-hold, then close. The OpenMotion composition renders the
|
|
// "The Commons" outro card after this clip, then the Assembly two-device
|
|
// scene, then the closing fade-to-black.
|
|
await sleep(400);
|
|
await mark("epilogueEnd");
|
|
}
|