-
Notifications
You must be signed in to change notification settings - Fork 0
Infrastructure/implement e2e tests #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
95 commits
Select commit
Hold shift + click to select a range
930f1e5
Refactor homepage to use new baseTest pattern
webstackdev efa9f37
Refactor all tests to use new baseTest pattern
webstackdev b4cb3c7
Update state initialization and error handling in bootstrap
webstackdev 0fc7c47
Improve error handling in Head component stores feature
webstackdev 4440178
Remove JSON.stringify in themes store to stop escaping quotes on name
webstackdev 668ec97
Update Scripts state bootstrap to use window property for errors in e2e
webstackdev 53698c5
Update dev error handlers to use window prop system for e2e notification
webstackdev 13039c5
Refactor smoke e2e tests to use Page Object Model base class
webstackdev 7ed6dab
Refactor pages in 02-pages to use new page object model
webstackdev 93fdef2
Refactor pages in 04-components to use new page object model
webstackdev bc78b82
Add robots directive in head, JSON-LD Schema data
webstackdev e1d7fa0
Refactor 05-metadata tests to POM and remove obsolete tests from 04-comp
webstackdev 3ab23f8
Move API endpoints from Vercel ./api folder to Astro SSR endpoints
webstackdev dcb11e5
Move social-cards Astro SSR API endpoint to folder and add tests
webstackdev 357c335
Implement and troubleshoot e2e tests for API endpoints
webstackdev 1e21de3
Implement e2e tests in 03-forms and 09-pwa with @wip still to do
webstackdev 72902aa
Implement core-web-vitals e2e test with passing scores
webstackdev d93a413
Fix many failures in unit tests due to config changes, but still skipped
webstackdev 52065a1
First pass at implementing accessibility e2e tests
webstackdev 72b4445
Dependency patch versions upgrade
webstackdev c94e479
Deps upgrade - minor of Astro, major of Vercel adapter, major of Zod
webstackdev 608d6df
Add axe-playwright, commit home page errs, notes on accessibility tests
webstackdev 1103b53
ARIA Required Children on carousel
webstackdev 7ade5d3
Normalize CSS theme variable names and implement single source of truth
webstackdev 912d3c0
Convert rgba values in theme.css to hex values
webstackdev e5d659e
Respect theme colors in logo and wordmarks in header
webstackdev cc490e9
Change padding of header
webstackdev 0187133
Spacing improvements to themepicker icon and boxes
webstackdev c8a6968
Fix color and animation of main-nav elements
webstackdev dbdca87
Fix script execution error on theme picker activation after navigation
webstackdev f2633d5
Fix animation error on nav menu items when element loses hover
webstackdev 2d46452
Change page names for about and contact for breadcrumbs and title
webstackdev acf2301
Fix mobile nav, add event system to pause animations
webstackdev 87e52c5
Add a demo article showcasing all MDX components
webstackdev ae76b4e
Style tweak to desktop nav
webstackdev 935471c
Adjust breadcrumbs padding
webstackdev c121201
Fixes to mobile nav
webstackdev 8d2a30e
Normalize company and contacta data into one file
webstackdev c99555e
Fix unit test errors
webstackdev 4607238
Fixes to desktop footer
webstackdev 0459469
Fixes to mobile footer
webstackdev 82e0858
Fixes to desktop cookie consent modal
webstackdev b46bcc8
Fixes to mobile cookie consent
webstackdev 3fd2e92
Update dependencies
webstackdev 54d6404
Fix typescript errors from npm run check
webstackdev 8d696db
Fix typescript errors, update GitHub Action and Husky pre-commit hook…
webstackdev 31482bd
Refactor style theme variables to use Tailwind @theme inline
webstackdev b494267
Docs updates
webstackdev 4a6cda5
Break Base and Markdown layout elements out into Layout component dir…
webstackdev e823d23
Move CSS styles from :root to Tailwind @theme
webstackdev f1740e2
Add stories component for internal use on styling reviews
webstackdev 2b45c7c
Revert "Add stories component for internal use on styling reviews"
webstackdev 3fc5530
Revert "Move CSS styles from :root to Tailwind @theme"
webstackdev 30ca667
Fix gremlin breaking CSS compilation
webstackdev b1f29b5
Update mobile nav e2e tests with changes made to nav
webstackdev 7e85d13
Update footer e2e tests with clearCookieConsent helper and implement …
webstackdev a29f819
Fix to mobile nav menu test to work on all browsers
webstackdev 3865a15
Fix to manifest test, skip on Firefox since it triggers a download di…
webstackdev 6e375dc
Update deps
webstackdev 2af259e
Fix error in critical paths e2e that assumed desktop on mobile
webstackdev cd32920
Fix error in homepage page e2e CTA section test to separate desktop a…
webstackdev e8341d4
Fix error in dynamic-pages e2e tests related to Firefox handling of m…
webstackdev 08a3777
Fix test logic for several GDPR e2e test scenarios
webstackdev 5f79feb
Remove browser validation on newsletter consent form for consistent u…
webstackdev 9ec5e40
Fix assorted implementation errors with keyboard navigation on site
webstackdev 4407676
Refactor nanostores state to persist across page transitions using As…
webstackdev 649cd35
Fixing collateral damage from recent e2e fixes
webstackdev 073fa47
Refactor script loading system to pattern suggested by Astro for view…
webstackdev 5724dad
Fix flaky selector causing intermittent errors on webkit
webstackdev ab60821
Broken tests: theme picker stays open across navigation
webstackdev 8adcac8
Broken tests: theme picker stays persists theme color across navigation
webstackdev 43d97d8
Fix e2e tests related to theme picker refactor
webstackdev 299214a
Fix to cookieConsent unit test after store refactor
webstackdev 42f7de6
Fix skipped unit test cases in cookie consent
webstackdev bf519b3
Remove unneeded skip test files
webstackdev a96a992
Delete skipked tests in js-cookie.spec.ts
webstackdev f96aeec
Update functions signature for vi mock
webstackdev 66fb11a
Fix noisy console output in test environment for Mastodon handler
webstackdev d69c35a
Improve mock event listener in Forms/Download client spec
webstackdev 5a264b6
Remove debug logging from Carousel component
webstackdev 41f433f
Mock logger in Forms/Download component
webstackdev 7af872f
Migrate to ClientRouter from deprecated ViewTransitions component
webstackdev 64dda0c
Mock console for Favicon build
webstackdev 8e49677
Remove debug logging from contact API implementation
webstackdev de28605
Add mock console to newsletter component tests
webstackdev 7cf880d
Add mock console to downloads api test
webstackdev 7966749
Remove debug messages from Testimonials carousel
webstackdev 30be768
Fix mock in Social Embed
webstackdev 5a3b7c7
Remove debug logging from the scripts loader
webstackdev 744d0b9
Remove debug logging from scripts loader
webstackdev bdec8d1
Remove debug logging from cookies consent test
webstackdev dc63e88
Implement @wip cookie consent e2e tests
webstackdev 8458847
Fix test case in testimonials component to account for remocking logging
webstackdev f1698ca
Implement skipped testimonials component e2e tests
webstackdev b58a8ea
@wip theme picker work
webstackdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Fast code quality checks (TypeScript + Linting) | ||
| name: Code Quality Check | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| quality-check: | ||
| name: Code Quality Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22.x" | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run TypeScript check | ||
| run: npm run check | ||
|
|
||
| - name: Run linting | ||
| run: npm run lint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # Theme System - Work in Progress | ||
|
|
||
| ## Current Status | ||
|
|
||
| ### What's Working | ||
| - ✅ Theme picker tests: 9/10 @ready (63 tests passing across 7 browsers) | ||
| - ✅ Manual theme selection and persistence works correctly | ||
| - ✅ Theme switching via theme picker UI works | ||
| - ✅ View Transitions correctly maintain theme across page navigations | ||
| - ✅ CSS architecture refactored: `@theme inline` uses `var()` references instead of hard-coded values | ||
|
|
||
| ### What's Broken | ||
| - ❌ **System preference (prefers-color-scheme) not respected on first visit in real browser** | ||
| - Test passes but real usage fails | ||
| - Opening site in new incognito window with dark mode preference shows light theme | ||
| - Google.com correctly shows dark, but our site doesn't | ||
|
|
||
| - ❌ **Theme picker buttons should show their own theme's colors** | ||
| - Dark theme button should use `--dark-color-*` variables | ||
| - Default theme button should use `--light-color-*` variables | ||
| - Currently all buttons use light theme colors (partially fixed but needs completion) | ||
|
|
||
| ## Root Cause Analysis | ||
|
|
||
| ### System Preference Issue | ||
|
|
||
| The problem is a **race condition** between: | ||
| 1. HEAD inline script (synchronous) - correctly sets `data-theme="dark"` based on `prefers-color-scheme` | ||
| 2. `persistentAtom` restore (asynchronous) - overwrites theme back to 'default' | ||
|
|
||
| **Sequence of events:** | ||
| ``` | ||
| 1. HEAD script runs → checks localStorage (empty) → checks prefersDark=true → sets data-theme="dark" ✓ | ||
| 2. persistentAtom initializes with default value 'default' | ||
| 3. Our init code runs with setTimeout(100ms) | ||
| 4. persistentAtom's restore() completes (async) → fires .listen() → overwrites to 'default' ✗ | ||
| ``` | ||
|
|
||
| **Current fix attempt:** | ||
| - Using `isInitialized` flag to prevent `.listen()` from applying themes until init completes | ||
| - Using `setTimeout(100ms)` to delay init until after `persistentAtom.restore()` completes | ||
| - **Problem:** The timing is unreliable - 100ms might not be enough on slower devices | ||
|
|
||
| **Test vs Reality:** | ||
| - Playwright test passes because it's using `emulateMedia({ colorScheme: 'dark' })` | ||
| - Real browser behavior is different - the race condition manifests differently | ||
| - Test needs to be improved to catch this real-world bug | ||
|
|
||
| ## Files Modified | ||
|
|
||
| ### Theme Initialization | ||
| - `src/components/Scripts/state/store/themes.ts` (lines 127-180) | ||
| - Changed from `.subscribe()` to `.listen()` to avoid immediate firing | ||
| - Added `isInitialized` flag to gate theme applications | ||
| - Added `setTimeout(100)` to wait for `persistentAtom.restore()` | ||
| - **HAS DEBUG LOGGING** - needs to be removed before commit | ||
|
|
||
| ### Theme Picker UI | ||
| - `src/components/ThemePicker/Themes.astro` (lines 97-120) | ||
| - **NOT YET FIXED** - still needs to map theme.id to color prefix | ||
| - Should use `--${colorPrefix}-color-*` variables per button | ||
|
|
||
| ### HEAD Script | ||
| - `src/components/Head/index.astro` (lines 56-63) | ||
| - Correctly checks `prefers-color-scheme` and sets `data-theme` | ||
| - Logic: stored theme (if not 'default') > system preference > 'default' | ||
|
|
||
| ### CSS Architecture | ||
| - `src/styles/themes.css` | ||
| - ✅ Lines 65-105: `@theme inline` refactored to use `var()` references | ||
| - ✅ All theme-specific colors defined at `:root` level | ||
| - Has `--light-color-*`, `--dark-color-*`, and base `--color-*` variables | ||
|
|
||
| ## Next Steps | ||
|
|
||
| ### High Priority | ||
| 1. **Fix system preference detection** | ||
| - Option A: Find more reliable way to detect when `persistentAtom.restore()` completes | ||
| - Option B: Use `MutationObserver` to watch for theme changes from restore | ||
| - Option C: Initialize theme BEFORE importing `persistentAtom` | ||
| - Option D: Use regular `atom` for store, manually sync to localStorage after restore completes | ||
| - Option E: Don't rely on setTimeout - use `requestIdleCallback` or similar | ||
|
|
||
| 2. **Fix theme picker button colors** | ||
| - Complete the Themes.astro fix to show each theme's own colors | ||
| - Map `theme.id` to color variable prefix: 'default' → 'light', 'dark' → 'dark' | ||
| - Update color swatches to use theme-specific variables | ||
|
|
||
| 3. **Remove debug logging** | ||
| - `src/components/Scripts/state/store/themes.ts` has console.log statements | ||
| - Clean these up before final commit | ||
|
|
||
| ### Test Improvements | ||
| 4. **Make test match real browser behavior** | ||
| - Current test uses `emulateMedia()` which might not trigger same race condition | ||
| - Consider testing with actual localStorage clearing and page reload | ||
| - Add test that validates theme immediately on page load (before JS runs) | ||
|
|
||
| ## Technical Constraints | ||
|
|
||
| - **MUST use `persistentAtom`** - required for View Transitions to maintain theme across navigations | ||
| - **CANNOT use regular `atom`** - will lose persistence across page navigations | ||
| - HEAD script must run synchronously to prevent FOUC (Flash of Unstyled Content) | ||
| - Theme must be applied before page renders (critical for UX) | ||
|
|
||
| ## Code Locations | ||
|
|
||
| - Theme store: `src/components/Scripts/state/store/themes.ts` | ||
| - Theme picker UI: `src/components/ThemePicker/Themes.astro` | ||
| - Theme picker element: `src/components/ThemePicker/theme-picker-element.ts` | ||
| - HEAD script: `src/components/Head/index.astro` (lines 56-63) | ||
| - CSS themes: `src/styles/themes.css` | ||
| - E2E tests: `test/e2e/specs/04-components/theme-picker.spec.ts` (line 134 is failing test) | ||
|
|
||
| ## Questions to Answer | ||
|
|
||
| 1. When exactly does `persistentAtom.restore()` complete? | ||
| 2. Is there an event or promise we can wait for? | ||
| 3. Should we implement our own localStorage persistence instead of using `persistentAtom`? | ||
| 4. Can we leverage the `@media (prefers-color-scheme: dark)` CSS to avoid needing JS for system preference? | ||
|
|
||
| ## Useful Context | ||
|
|
||
| - The `@media (prefers-color-scheme: dark)` CSS rule at lines 337-373 in themes.css correctly applies dark theme | ||
| - This CSS works WITHOUT JavaScript | ||
| - The issue is the JS is overriding this CSS by setting `data-theme="default"` | ||
| - Maybe we should NOT set `data-theme` at all when using system preference? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium