Skip to content

Add automated E2E tests for frontend (Playwright)#126

Open
davidperezgar wants to merge 2 commits intotrunkfrom
claude/add-frontend-e2e-tests-JdZOA
Open

Add automated E2E tests for frontend (Playwright)#126
davidperezgar wants to merge 2 commits intotrunkfrom
claude/add-frontend-e2e-tests-JdZOA

Conversation

@davidperezgar
Copy link
Copy Markdown
Contributor

@davidperezgar davidperezgar commented Mar 29, 2026

Summary

Closes #125

Adds a complete Playwright E2E test suite for all FrontBlocks frontend JavaScript components. Tests run against standalone HTML fixtures that mirror the exact HTML each PHP class outputs on a real WordPress/GeneratePress frontend page — no WordPress install required.


HTML Fixtures (tests/e2e/fixtures/)

Each fixture is crafted to match the actual HTML rendered by the corresponding PHP class on the WordPress frontend:

File PHP class / hook
accordion.html GenerateBlocks accordion block
reading-progress.html ReadingProgress::render() via wp_footer
counter.html Counter.phpfrontblocks-counter-active on text blocks
sticky-column.html StickyColumn.phpfrontblocks-sticky-wrapper on grid
back-button.html BackButton::render_button() <button> via wp_footer
carousel.html Carousel.php — three variants: arrows, bullets, slider type
marquee.html Headline.php — three speed presets (fast / medium / slow)
wordpress-frontend-page.html Full realistic WP page combining all components

The wordpress-frontend-page.html fixture is a complete GeneratePress-style page with site header, article content, and footer — demonstrating exactly how all blocks coexist on a real production page.


Test Specs (7 files, ~75 tests)

Spec Coverage
accordion.spec.ts Open/close, aria-expanded, multi-item, toggle cycle
reading-progress.spec.ts Init state, scroll update, 100% cap, aria-valuenow
counter.spec.ts Target value, prefix/suffix, non-zero start, no double-animation
sticky-column.spec.ts Activate on scroll, deactivate on scroll-up, top offset
back-button.spec.ts Hidden on first visit, shows after navigation + scroll, hides at top
carousel.spec.ts Glide.js DOM structure, arrow/bullet nav, aria-labels, slider type, WP page integration
marquee.spec.ts Init, copy count, CSS animation, speed presets, MutationObserver dynamic init, WP page integration
wordpress-frontend-page.spec.ts Full-page integration — all components together + accessibility checks

CI Workflow (.github/workflows/e2e.yml)

  • Matrix strategy — runs in parallel on Chromium and Firefox
  • Browser cache — avoids re-downloading on repeat runs
  • Uploads HTML report as artifact (14-day retention)
  • Uploads traces / screenshots / videos on failure (7-day retention)
  • concurrency group cancels in-progress runs on new push
  • Triggers on PRs to trunk, release/**, feature/**, claude/**

npm scripts added

npm run test:e2e          # headless
npm run test:e2e:headed   # with browser window
npm run test:e2e:ui       # Playwright UI mode

Test plan

  • npm ci succeeds
  • npx playwright install --with-deps chromium firefox succeeds
  • npm run test:e2e — all tests pass
  • HTML report generated at tests/e2e/playwright-report/
  • GitHub Actions E2E workflow runs and goes green on this PR

https://claude.ai/code/session_01Nyp3kpBW1eYMQj3mjEubjx

claude added 2 commits March 26, 2026 07:16
Sets up a complete E2E test suite using Playwright to cover the plugin's
frontend JavaScript behaviour without requiring a WordPress install. Tests
run against standalone HTML fixtures that load the actual plugin JS files.

- Install @playwright/test and serve as dev dependencies
- Add playwright.config.ts with a static file server (serve)
- Add tsconfig.json for TypeScript test support
- Add HTML fixtures: accordion, reading-progress, counter, sticky-column, back-button
- Add test specs (25 tests across 5 files) covering:
  * Accordion open/close, aria-expanded, multiple items
  * Reading progress bar initialisation, scroll update, 100% cap
  * Counter animation target value, prefix/suffix, non-zero start
  * Sticky column activation/deactivation on scroll, top-offset
  * Back button visibility logic based on navigation history and scroll
- Add npm scripts: test:e2e, test:e2e:ui, test:e2e:headed
- Add .github/workflows/e2e.yml CI workflow (runs on PRs to trunk)
- Update .gitignore to exclude Playwright report/result artefacts

Closes #125

https://claude.ai/code/session_01Nyp3kpBW1eYMQj3mjEubjx
New HTML fixtures mirror the exact HTML that each FrontBlocks PHP class
outputs on a real WordPress/GeneratePress frontend page, enabling E2E tests
without a WordPress installation.

New fixtures:
- tests/e2e/fixtures/carousel.html      – three carousel variants (arrows, bullets, slider)
- tests/e2e/fixtures/marquee.html       – three marquee speed presets
- tests/e2e/fixtures/wordpress-frontend-page.html – full realistic WP page combining
  all components: reading progress, back button, carousel, counters, sticky column,
  accordion, and marquee in one document

New test specs (49 new tests):
- tests/e2e/carousel.spec.ts           – Glide.js mount, DOM structure, arrow/bullet
                                          navigation, aria-labels, slider type
- tests/e2e/marquee.spec.ts            – initialisation, copy count, CSS animation,
                                          speed presets, MutationObserver dynamic init
- tests/e2e/wordpress-frontend-page.spec.ts – full-page integration: all components
                                          on one page, accessibility checks

Updated:
- tests/e2e/fixtures/back-button.html  – corrected to use <button> (matches PHP output)
- playwright.config.ts                 – add outputDir, video retention on failure
- .github/workflows/e2e.yml            – matrix strategy (chromium + firefox), browser
                                          cache step, separate trace/screenshot artifact,
                                          concurrency cancel-in-progress, claude/** trigger

Closes #125

https://claude.ai/code/session_01Nyp3kpBW1eYMQj3mjEubjx
@davidperezgar davidperezgar changed the title Add Playwright E2E tests for frontend components Add automated E2E tests for frontend (Playwright) Mar 29, 2026
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.

Add automated E2E tests for frontend

2 participants