Skip to content

test(docs): RSpec + Capybara + Playwright system suite for the dogfood site#51

Merged
mhenrixon merged 1 commit into
mainfrom
test-docs-system-specs
Jul 4, 2026
Merged

test(docs): RSpec + Capybara + Playwright system suite for the dogfood site#51
mhenrixon merged 1 commit into
mainfrom
test-docs-system-specs

Conversation

@mhenrixon

Copy link
Copy Markdown
Owner

Why

The gem's CI never exercised the /docs app, so the og:image 404 shipped with zero coverage — it was a bug that only manifests through a booted app's asset pipeline (a logical og_image path resolving to the served, digested /assets URL), which no isolated component spec can reach. This gives the dogfood site a real browser suite so that class of regression can't ship again.

Matches the stack you use everywhere else (cosmos / phlex-reactive / pgbus): RSpec + Capybara + Playwright (chromium). Replaces the throwaway minitest test from the fix PR.

What's covered

System specs (real browser + Puma + Propshaft):

  • seo_meta_tags_spec.rb — the 404 regression guard: visit /, assert og:image is a /assets URL, and that visiting it returns 200 (a shared link's image must actually load). Also og/twitter parity + per-page description.
  • docs_chrome_spec.rb — landing hero, a doc page (masthead + Rouge code block), active sidebar link, sidebar navigation.
  • theme_persistence_spec.rb — theme applies in place and survives navigation (docs-nav + localStorage, no flash).

Request specs (no browser — the JS-off invariant):

  • progressive_enhancement_spec.rb — complete HTML document, sidebar <details open>, server-side active nav, the .md twin, llms.txt.

Setup (mirrors the sibling repos)

  • Gemfile: rspec-rails, capybara + capybara-playwright-driver (require: false), rubocop-capybara/rubocop-rspec. package.json: playwright. bin/rspec binstub.
  • spec/spec_helper.rb, rails_helper.rb (DB-less — use_active_record = false), system_helper.rb; spec/system/support/{playwright,capybara}_setup.rb — Puma server, chromium, HEADLESS env, a viewport matrix (CAPYBARA_SCREEN) with a :desktop_only skip for the always-open-drawer sidebar specs.
  • spec/support/assets.rb precompiles once before a system/request run, so image_url (Propshaft's Static resolver) resolves og:image — mirroring the deploy-time assets:precompile condition, so the suite is self-sufficient.

CI

  • docs/config/ci.rb gains a Test: RSpec step (so bin/ci runs it).
  • .github/workflows/ci.yml gains a docs-site job: bundle in docs/, setup-bun, cache + install Playwright chromium, run rspec. BUNDLE_FROZEN: "false" (the path: ".." gemspec digest changes every commit). Commits docs/Gemfile.lock for reproducible installs — un-ignored, since it's a real deployable app (same as phlex-reactive/docs).

Verification

  • docs: bundle exec rspec15 examples, 0 failures from a clean asset state (CI parity).
  • docs: responsive matrix → desktop 10, mobile 8 (:desktop_only skipped).
  • docs: bin/rubocop34 files, no offenses.
  • gem: bundle exec rake714 examples, 0 failures, rubocop clean (untouched).

Refs #48.

https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX

…d site

The docs-kit gem's CI never exercised the /docs app, so the og:image 404
(a logical asset path that only breaks through a booted app's asset pipeline)
shipped with zero coverage. This adds a real browser suite to the dogfood site,
matching the stack the sibling gems use (cosmos/phlex-reactive/pgbus): rspec-rails
+ capybara + capybara-playwright-driver, chromium via Playwright.

## What's covered
- spec/system/seo_meta_tags_spec.rb — the regression guard for the 404: visit /,
  assert og:image is a /assets URL, and that VISITING it returns 200 (a shared
  link's image must actually load). Renders through the real server + Propshaft.
- spec/system/docs_chrome_spec.rb — landing hero, a doc page (masthead + Rouge
  code), active sidebar link (server-rendered), sidebar navigation.
- spec/system/theme_persistence_spec.rb — theme applies in place + survives
  navigation (docs-nav + localStorage, no flash).
- spec/requests/progressive_enhancement_spec.rb — the JS-off invariant: complete
  HTML document, sidebar <details open>, active nav server-side, the .md twin,
  llms.txt.

## Setup (matches the sibling repos)
- Gemfile: rspec-rails, capybara + capybara-playwright-driver (require: false),
  rubocop-capybara/rspec. package.json: playwright. bin/rspec binstub.
- spec/spec_helper.rb, rails_helper.rb (DB-less — use_active_record = false),
  system_helper.rb; spec/system/support/{playwright,capybara}_setup.rb
  (Puma server, chromium, HEADLESS env, viewport matrix with a desktop_only skip).
- spec/support/assets.rb precompiles once before a system/request run, so
  image_url (Propshaft Static resolver) resolves og:image — mirrors deploy-time.
- Replaces the throwaway minitest test/ from the previous fix.

## CI
- docs/config/ci.rb gains a "Test: RSpec" step (bin/ci).
- .github/workflows/ci.yml gains a docs-site job: bundle in docs/, setup-bun,
  cache + install Playwright chromium, run rspec. BUNDLE_FROZEN=false (the
  path-gem digest changes every commit). Commits docs/Gemfile.lock for
  reproducible installs (un-ignored — it's a real app, like phlex-reactive/docs).

## Verification
- [x] docs: bundle exec rspec — 15 examples, 0 failures (from a clean asset state)
- [x] docs: responsive matrix — desktop 10, mobile 8 (desktop_only skipped)
- [x] docs: bin/rubocop — 34 files, no offenses
- [x] gem: bundle exec rake — 714 examples, 0 failures, no offenses (untouched)

Refs #48

Claude-Session: https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX
@mhenrixon mhenrixon self-assigned this Jul 4, 2026
@mhenrixon mhenrixon added the enhancement New feature or request label Jul 4, 2026
@mhenrixon mhenrixon merged commit 5ac7a04 into main Jul 4, 2026
5 checks passed
@mhenrixon mhenrixon deleted the test-docs-system-specs branch July 4, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant