Skip to content

test: check the import map on a server-rendered Flex page - #53

Merged
domiebett merged 3 commits into
mainfrom
dkb/e2e-ssr-import-map
Oct 22, 2026
Merged

domiebett merged 3 commits into
mainfrom
dkb/e2e-ssr-import-map

Conversation

@domiebett

@domiebett domiebett commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds an e2e check that a server-rendered Flex page prints one well-formed import map, ahead of every module, and that the embed hydrates. Until now only the import-map helpers had PHP unit tests; nothing checked the rendered page.

What changed

  • New test Flex SSR published page in flex-and-ssr.spec.ts, run as a logged-out reader on a published post with a Flex SSR block. It checks that:
    • the page has exactly one import map (Firefox honours only a page's first map, so a second one breaks module resolution there);
    • the map comes before every module script and module preload;
    • the map carries every specifier in the experience's manifest, each with its integrity hash;
    • the embed hydrates (data-flex-ready) with no page errors. This experience does not load a mapped module while hydrating, so this does not show that the map resolves.
  • The test fails when the experience's manifest has no imports or hashes, since the checks above would then pass without testing anything.
  • PublishedPostPage gains importMaps, importMap() and modulesBeforeImportMap(); FlexRender gains ssrHydrated.

Running

  • Locally against latest: the new test passes 3/3, and the Flex published render tests pass.
  • The test fails when the renderer is broken in each of these ways (each change reverted after):
    • printing its own map instead of joining WordPress's (2 maps);
    • not registering the experience's specifiers;
    • not carrying the integrity hashes;
    • not printing the hydration script.
  • With WordPress 6.9 and a block theme, WordPress prints the map in wp_head, so the footer hoist used for classic themes is not exercised here.

An SSR page prints one import map, ahead of every module, carrying the
experience's imports and integrity, and the embed hydrates.
@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Fail when the manifest has no imports or hashes to check, name the module
tags that come before the map, and fail clearly on a bad manifest response.
@domiebett
domiebett marked this pull request as ready for review October 22, 2026 16:30
Moves the check out of flex-and-ssr.spec.ts into flex-ssr-import-map.spec.ts,
with the manifest read and the map assertions as helpers beside the other
embed checks. The hydration wait gets the medium timeout, since the runtime
loads from the Ceros CDN.

@Cporter97 Cporter97 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@domiebett
domiebett merged commit 7b52565 into main Oct 22, 2026
13 checks passed
@domiebett
domiebett deleted the dkb/e2e-ssr-import-map branch October 22, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants