Skip to content

Use fake parent window test helper#2428

Merged
tf merged 2 commits into
codevise:masterfrom
tf:use-fake-parent-window
May 22, 2026
Merged

Use fake parent window test helper#2428
tf merged 2 commits into
codevise:masterfrom
tf:use-fake-parent-window

Conversation

@tf
Copy link
Copy Markdown
Member

@tf tf commented May 22, 2026

No description provided.

tf added 2 commits May 22, 2026 09:39
Inline editing only ever runs inside the editor's preview iframe in
production, so `window.parent !== window` is always true and the
postMessage listener in inline-editing's MessageHandler is always
attached. Have the helper set that up by default so inline-editing
specs no longer need to remember `fakeParentWindow()` per test.
Bundle the fake parent window setup AND its postMessage stub into a
single setup hook so specs that need outgoing messages mocked can opt
in with one line. `useInlineEditingPageObjects` calls it instead of
the bare `fakeParentWindow()`; specs that previously paired
`fakeParentWindow()` with `window.parent.postMessage = jest.fn()`
drop both calls and use the hook directly.

The shallow-equal transient state test in inEditorPreview-spec used
to re-stub `window.parent.postMessage` mid-test before re-rendering.
With the hook stubbing it once per beforeEach, switch to a
`mockClear()` before the rerender and assert that no further posts
happen, instead of asserting a total call count.
@tf tf added this to the v17.2 milestone May 22, 2026
@tf tf merged commit 0802f18 into codevise:master May 22, 2026
16 checks passed
@tf tf deleted the use-fake-parent-window branch May 22, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant