Repository navigation
test(studio): share one sealed preview frame that delivers messages like a browser - #8165
Conversation
terencecho
left a comment
There was a problem hiding this comment.
Reviewed 0f0be1f against stack base 218835e (#8154). No blocker found in this test-only diff. #8154 must land first; recheck the retargeted head/diff before merge.
The shared helper keeps the real editing agent and frame-source identity, queues message delivery onto a later task, refuses cross-origin property reads and exposes a null contentDocument. The port-wrapper hook remains available for delayed-reply tests, and the runtime agent is disposed at test completion. Existing assertions in the 14 migrated files are retained; the additional regression opens the shortcut and Studio clients together and checks that Studio receives its own read result.
Validation: all 209 tests across the 21 migrated/helper-consumer suites pass at this head. Removing #8154's port-claim guard from the source and built client makes the new race test fail with { watching: 28 } instead of { zIndex: 7 }; restoring it passes. Full workspace build passed after retrying one SIGTERM, before the final test-only option rename; that final rename and its caller are covered by the 21 suites. The comment-share gate passes locally and CI is green (11 success, four skipped). The required fails-without-the-fix line is present; no visible product change or browser walk is claimed.
— tai (automated review)
The base branch was changed.
0f0be1f to
d75a061
Compare
terencecho
left a comment
There was a problem hiding this comment.
Rechecked retargeted head d75a061 against main e95cdf7. #8154 is merged at that base. Both child commits are '=' in range-diff, all 17 changed files are byte-identical to approved 0f0be1f, and the base editingPort implementation matches the previously tested parent. No new behavior issue found, but the retargeted CI run exposes two required blockers:
[P2] Make the unused postLater helper private (or use it through a real consumer). The Fallow PR report flags fallow/unused-export at sealedPreviewFrame.test-helpers.ts:7. I read the failed audit job and report; this is the reason its gate is red.
[P2] Put the new test helper under a recognized test path, or deliberately update the capture checker's test-helper classification with coverage. The capture job counts 41 changed non-test lines (39 from this helper plus the harness change), so its under-20-lines No visible change exemption rejects the body. scripts/check-pr-captures.mjs currently recognizes /tests/, /tests/ or .test./.spec. paths, not .test-helpers.ts. This PR is test-only; use the supported test classification so its No visible change declaration is accepted.
Prior validation carries forward because the patch and affected file contents are unchanged: 209 tests in 21 files passed, and removing the parent port-claim guard made the new race test fail with watching:28 instead of zIndex:7. No tests/build were rerun for this rebase-only comparison. The required fails-without-the-fix line is present. Approval can be re-pinned once these CI blockers are resolved.
— tai (automated review)
|
Both fixed at 5d323e5.
|
terencecho
left a comment
There was a problem hiding this comment.
Re-reviewed 5d323e5. The earlier Fallow and capture blockers are fixed: postLater is private, the checker recognizes .test-helpers files, and both CI gates are green. All 75 capture-checker tests pass locally; restoring the old classifier makes the newly extended test fail, then restoring this head passes again.
[P2] Exclude the new test-only helper from Studio's production typecheck, consistently with core's existing .test-helpers convention.
The required Typecheck job now fails with eight TS2339 errors in core/src/runtime/editingAgent.ts for __player, __hfStartupError, __clipManifest, __clipTree, __hfWaitForSeekCompletion and __hf. The new sealedPreviewFrame.test-helpers.ts imports the core test agent, but Studio's tsconfig includes all src and excludes only src/**/.test.ts. It therefore pulls this runtime source into Studio's type program without the core runtime Window augmentations. Core already excludes **/.test-helpers.ts in both tsconfigs.
Finish the test-only wiring in Studio's TypeScript configuration (or use a test path consistently excluded there) and rerun Studio/the required typecheck. The failing CI log identifies this exact import/type boundary; no runtime declaration weakening is needed.
The helper's message/port behavior is unchanged, so the prior 209-test and two-client race validation carries forward. Those package suites were not rerun for this small checker/private-export delta. No new product behavior issue found; the remaining blocker is the introduced required typecheck failure.
— tai (automated review)
Edit accuracy: accurate 271 (base branch 271), smooth 62 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
|
Fixed at 5ec72c3: Studio |
terencecho
left a comment
There was a problem hiding this comment.
Re-reviewed 5ec72c3. The remaining typecheck blocker is resolved: Studio excludes src/**/*.test-helpers.ts, consistent with core's existing test-helper convention. The helper's consumers are excluded .test.ts files, so this removes the fake/core-test-agent import tree from the production type program without changing runtime test discovery.
Full workspace build and Studio typecheck pass at this head. Restoring the previous tsconfig reproduces the eight TS2339 Window-property errors; restoring this exclusion makes typecheck pass again. All 30 preview-selection tests using the shared helper pass, confirming those tests still run with the helper excluded from production typechecking. The prior 209-test suite and two-client race validation carry forward because helper behavior is unchanged.
The previous unused-export and capture-classification fixes remain; their CI gates are green. The required fails-without-the-fix line is present. No remaining blocker found. CI Typecheck and other jobs are still running with no failed checks when submitted; local typecheck is green. No merge performed.
— tai (automated review)
What
One shared fake for a preview frame Studio cannot script,
sealedPreviewFrame()inpackages/studio/src/player/lib/sealedPreviewFrame.test-helpers.ts, replacing the local copies in 14 Studio test files (+85 / −381).It behaves like a real cross-origin frame in the two ways the copies did not:
postMessageon a later task, to every listener present when the dispatch begins. The copies delivered synchronously, which hid the bug fixed in fix(core): each editing client takes its own port, so a sealed preview answers Studio again #8154 (two editing clients took the same handed-over port). The helper, andserveEditingRequestsintimelinePlayerTestHarness.ts, now deliver on a later task.SecurityErroron every property exceptpostMessage, and the iframe'scontentDocumentis null, so a test fails if Studio reaches into the frame instead of going through the editing port.The frame's real runtime agent answers, and its messages carry the frame as their source, so the editing port's source check runs as in the app.
sealedPreviewFrame({ port })wraps each handed-over port, for tests that hold or inspect replies (the caption overlay test).Capture check
scripts/check-pr-captures.mjsnow treats.test-helpers.files as tests, as it already treats.test.and.spec.files..test-helpers.tsis the repo's existing name for test helpers (10 files across core, parsers, studio, studio-server and cli). Its test gains a.test-helpers.tsrow that fails with main's checker.Tests
New in
packages/studio/src/hooks/useAppHotkeys.previewForwarding.test.tsx, "leaves Studio's own reads of the preview answered while it forwards keys": the shortcut watcher and Studio's own client open on one sealed frame in the same tick, and Studio's read must still get its answer.fails without the fix: on this branch with #8154's change taken out of
packages/core/src/runtime/editingPort.ts, that test fails:The shortcut watcher's client took the port and got Studio's reply. With #8154 the test passes, along with the 14 converted files and every other user of
serveEditingRequests:useConsoleErrorCapture,useElementPicker,previewMessageRouter.manifest,usePlaybackKeyboard,previewChannelandpreviewElements(21 files, 209 tests).No visible change
Test code only.