Skip to content

DS-2430: Add VRT and E2E tests for ontario-page-alert#187

Open
MeaghanCarrieres wants to merge 3 commits intoDS-2274/create-nextjs-visual-regression-testing-pocfrom
meaghan/test/DS-2430/add-page-alert-tests-nextjs-app
Open

DS-2430: Add VRT and E2E tests for ontario-page-alert#187
MeaghanCarrieres wants to merge 3 commits intoDS-2274/create-nextjs-visual-regression-testing-pocfrom
meaghan/test/DS-2430/add-page-alert-tests-nextjs-app

Conversation

@MeaghanCarrieres
Copy link
Collaborator

This MR adds Next.js SSR support for the Ontario Design System React component library, resolves styling issues with slotted page alert content, and introduces VRT + E2E test coverage for the ontario-page-alert component.

Changes

app-nextjs

  • Configured Sass pkg: resolution using new exported pkgImporter
  • Added local ontario-theme.scss wrapper:
    • forwards global theme with $asset-base-path
    • includes slotted styles for callouts/asides and page alerts
  • Imported theme wrapper in layout.tsx
  • Added VRT coverage for page alert variants
  • Added E2E tests validating:
    • variant rendering
    • slot vs prop behaviour
    • edge cases (missing heading, invalid type fallback)
    • hydration behaviour in Next.js

Component Library

  • Updated ontario-page-alert "type" prop to include reflect: true
    • ensures attribute presence for CSS selectors targeting slotted content

React Component Library

  • Added reusable pkgImporter helper for Next.js Sass resolution
  • Exported helper via package exports
  • Updated README with Next.js installation and configuration guidance

Why this change was needed

  1. Next.js does not resolve Sass pkg: imports by default, causing theme and slotted styles to fail compilation.
  2. Slotted page-alert styles rely on attribute selectors (ontario-page-alert[type="error"]), requiring the prop to be reflected to the DOM.
  3. SSR support is required for correct hydration and declarative shadow DOM behaviour in Next.js.
  4. Additional test coverage ensures page alert variants and slot styling regressions are caught.

Result

  • Next.js app builds and hydrates successfully
  • Theme and slotted styles compile correctly
  • Page alert styling behaves as expected across variants
  • Consumers now have documented Next.js setup steps
  • Page alert behaviour is protected by VRT and E2E coverage

…verage

- Ensure invalid or missing `type` values fall back to `informational`
- Align runtime behaviour with console warning message
- Update page alert demo to include edge cases
- Add Playwright E2E tests for type rendering, content, links, and defaults
- Fix E2E selectors for shadow DOM + slotted content
@MeaghanCarrieres MeaghanCarrieres added component-library Component Library package impacted component-library-react React Component Library package impacted next-poc labels Feb 24, 2026
Copy link
Collaborator

@smorrisods smorrisods left a comment

Choose a reason for hiding this comment

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

Sorry, @MeaghanCarrieres apparently I didn't submit my comments 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, you had to write your own?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I had to write one to get it to work for the Next app!

return { file: require.resolve(`${dir}/_${base}.scss`) };
} catch {}

return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

All errors are swallowed here. If nothing resolves it might be worth us knowing. One idea is to add logging but take in an option debug parameter that can let us enable the logging if needed.

Comment on lines +41 to +47
@forward 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/theme.scss' with (
$asset-base-path: '/assets'
);

// Include slotted styles
@use 'pkg:@ongov/ontario-design-system-component-library-react/styles/slotted-styles/callouts-asides.scss';
@use 'pkg:@ongov/ontario-design-system-component-library-react/styles/slotted-styles/page-alerts.scss';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it is worth putting into the React lib and then just documenting how to update the asset path with with. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean having this file as something importable by the react library but adding a customization for the asset-base-path value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component-library Component Library package impacted component-library-react React Component Library package impacted next-poc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants