Skip to content

test(ui): add cross-browser Shadow DOM coverage - #420

Merged
abharms merged 22 commits into
journey-to-the-shadow-domfrom
test/shadow-dom-cross-browser
Sep 24, 2026
Merged

abharms merged 22 commits into
journey-to-the-shadow-domfrom
test/shadow-dom-cross-browser

Conversation

@abharms

@abharms abharms commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add focused Shadow DOM Storybook coverage for Firefox and Playwright WebKit
  • stabilize cross-browser timing, iframe lifecycle, direction, overlay, focus, dismissal, consumer-boundary, and realistic lifecycle scenarios
  • preserve the existing Chromium integration suite and document the one-time Safari smoke validation

Jira

YPE-5946 — Add cross-browser Shadow DOM coverage

Validation

  • pnpm lint
  • Chromium focused browser suite: 24/24 passed (22 Shadow DOM stories plus 2 document-root spacing regressions)
  • Firefox focused browser suite: 24/24 passed (22 Shadow DOM stories plus 2 document-root spacing regressions)
  • WebKit focused browser suite: 24/24 passed (22 Shadow DOM stories plus 2 document-root spacing regressions)
  • one-time Safari 26.6.2 SafariDriver smoke: 22/22 Shadow DOM stories passed in isolated sessions; document-root spacing was verified separately

Notes

  • target branch is journey-to-the-shadow-dom
  • screen-reader validation remains out of scope, as specified by YPE-5946
  • includes an empty changeset because this is test/CI/documentation work

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR expands focused Shadow DOM Storybook coverage across Chromium, Firefox, and Playwright WebKit while recording isolated Safari validation.

  • Adds a Firefox/WebKit CI matrix for the focused Shadow DOM suite.
  • Stabilizes cross-browser story timing, iframe lifecycle, focus, dismissal, overlay, direction, and realistic remount scenarios.
  • Adjusts host-reset scoping and generated spacing utilities to preserve SDK spacing in document and shadow roots.
  • Documents browser coverage, Safari observations, and remaining assistive-technology validation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Storybook Shadow DOM stories] --> B{Browser target}
  B --> C[Chromium integration suite]
  B --> D[Firefox focused suite]
  B --> E[Playwright WebKit focused suite]
  C --> F[Lifecycle and isolation assertions]
  D --> F
  E --> F
  G[Isolated SafariDriver smoke] --> F
Loading

Reviews (21) · Last reviewed commit: "test(ui): reuse Storybook wait helper"

@changeset-bot

changeset-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 03d7661

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-react-ui Patch
vite-react Patch
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T20:46:11.133724Z 03d7661 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…test/shadow-dom-cross-browser

# Conflicts:
#	docs/shadow-dom-isolation-plan.md
#	packages/ui/src/components/bible-version-picker.shadow-isolation.stories.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4a04a7a3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/ui/package.json Outdated
"build-storybook": "pnpm generate:i18n && pnpm build:css && pnpm build:storybook-css && storybook build",
"test:integration": "vitest run"
"test:integration": "vitest run",
"test:shadow-browser": "VITEST_STORY_TAG=shadow-dom vitest run --project storybook"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add the invalid-opener story to the browser suite

This command runs only stories tagged shadow-dom, but RapidCloseReopenIgnoresInvalidOpenerEvidence in shadow-overlay-production-seam.shadow-isolation.stories.tsx retains only tags: ['!dev']. Consequently, the Firefox/WebKit matrix silently skips the scenario covering disconnected openers and openers moved into the light DOM, another shadow root, or another document, even though docs/shadow-dom-isolation-plan.md now says those rapid-reopen journeys receive Firefox and WebKit coverage. Add the selection tag to that story so regressions in this cross-root/document behavior are exercised by the new jobs.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cae444479d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +764 to +767
void expect(
focused === overlay ||
(focused !== null && currentDialog !== null && currentDialog.contains(focused)),
).toBe(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require observing focus during overlay-only retention

When polling does not run until the replacement dialog has already reopened, the currentDialog branch lets this step pass without ever verifying focus during the overlay-only interval. A regression that briefly drops focus to the document after the first dialog unmounts would therefore escape the new cross-browser coverage as long as the reopened dialog later receives focus. Make the close/reopen gap deterministic and require currentDialog to be absent and the retained overlay to own focus before proceeding to the reopen step.

AGENTS.md reference: packages/ui/AGENTS.md:L63-L65

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 744bf47459

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import { createRoot, type Root } from 'react-dom/client';
import { expect, waitFor } from 'storybook/test';
import { waitFor } from 'storybook/test';
import { expect } from 'vitest';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep story assertions independent of the Vitest runner

When these stories are opened through ordinary pnpm storybook rather than the Vitest browser project, no Vitest worker context exists, so the runner-only vitest export fails when the play assertions execute. The same import was added to all seven edited Shadow DOM story files, leaving their standalone Storybook interactions broken even though the Vitest jobs pass. Keep the portable expect from storybook/test, or use runner-neutral checks inside polling callbacks.

AGENTS.md reference: packages/ui/AGENTS.md:L59-L61

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c097d66034

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/ui/.storybook/vitest.setup.ts Outdated
Comment on lines +23 to +24
globalThis.addEventListener('unhandledrejection', (event) => {
if (event.reason instanceof Event) event.preventDefault();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Narrow rejection suppression to the fonts request

This listener suppresses every unhandled rejection whose reason is an Event, not just the optional Fonts API stylesheet failure described above it. If another React stylesheet/resource load fails—or application code rejects with a load event—preventDefault() hides that failure from Vitest, allowing the browser suite to pass despite an unexpected resource regression. Check that the event originated from the expected Fonts API link before suppressing it.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7339f4144

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +364 to +366
const unexpectedConsoleErrors = consoleError.mock.calls.filter(
([firstArgument]) => !(firstArgument instanceof Event),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Narrow the lifecycle console-error exemption

Although the setup-level rejection filter is now scoped to the Fonts API stylesheet, this new per-story filter still discards every console.error whose first argument is an Event. During either realistic lifecycle story, an unrelated stylesheet, image, or resource failure reported as an event will therefore satisfy the “no unexpected console errors” assertion and let the cross-browser suite pass. Match the expected Fonts API link here as well instead of exempting all events.

Useful? React with 👍 / 👎.

@abharms

abharms commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: c799eb6565

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cameronapak cameronapak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

YPE-5946

Summary

Standards: 0 must-fix. Spec: 0 must-fix. Primary concern: none. One non-blocking suggestion to reuse Storybook's existing wait utility.

Review evidence
  • Scope: reviewed the PR HEAD against its merge-base, YPE-5946, repository guidance, story selection, runtime CSS changes, and prior bot feedback.
  • Source trace: the dedicated Firefox/WebKit matrix selects the 22 Shadow DOM stories and two document-root spacing regressions; the default Chromium integration selection remains unchanged. Earlier bot concerns are addressed in the current code.
  • CI: Storybook Tests reported 24/24 focused tests passing in each Firefox and WebKit job and 649/649 integration tests passing. These are CI results, not locally rerun tests.
  • Limits: the actual Safari 26.6.2 smoke result is author-reported in the PR documentation, not independently reproduced here. Screen-reader validation is deferred per ticket. The suggested wait-utility substitution has not been tested; verify it in all three browsers before adopting it.
  • Event: APPROVE.

Written by Code Reviewer bot on behalf of Cam.

Comment thread packages/ui/src/test/storybook-dom.ts Outdated
const deadline = Date.now() + timeout;
let lastError: unknown;

while (Date.now() <= deadline) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Could this delegate to Storybook's waitFor with a five-second timeout instead of maintaining a polling loop?

For Agents: reuse the existing wait utility

Storybook 10.5.10 re-exports Testing Library's waitFor, which handles promise-returning callbacks and accepts { timeout: 5_000 }. Keep this helper as a local five-second-default wrapper so its callers need not change. That removes the custom deadline/retry/sleep logic; the current loop cannot time out while a callback promise remains pending. The Firefox CI run after this loop was introduced still failed, so the history does not establish that the loop is needed to fix those failures. The tradeoff is Storybook's instrumented scheduling: please run the focused Chromium, Firefox, and WebKit suites before switching. This is a cleanup suggestion, not a blocker.

Written by Code Reviewer bot on behalf of Cam.

// The --ci flag will skip prompts and not open a browser
storybookScript: 'pnpm storybook --no-open',
tags: { include: ['integration'] },
tags: { include: storyTags },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

praise: Selecting focused story tags through the existing Storybook project keeps the Chromium integration default intact while adding Firefox and WebKit coverage.

For Agents: focused browser selection

The integration fallback remains the default, while the new job supplies the shadow-dom,cross-browser tag set. This avoids a separate browser-specific Storybook project and its duplicated setup.

Written by Code Reviewer bot on behalf of Cam.

@abharms
abharms merged commit baa9b30 into journey-to-the-shadow-dom Sep 24, 2026
22 checks passed
@abharms
abharms deleted the test/shadow-dom-cross-browser branch September 24, 2026 20:49
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