ワンクリックで
e2e-testing
// Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.
// Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.
Evaluate themes for accessibility, contrast, and design issues. Use when auditing themes for WCAG compliance, checking color contrast ratios, or identifying visual/UX problems.
Create new themes for PropertyWebBuilder. Use when creating custom themes, styling websites, or modifying theme templates. Handles theme registration, view templates, CSS, and asset configuration.
Create and manage seed packs for PropertyWebBuilder. Use when creating new scenario-based seed data bundles, adding properties to packs, or setting up new tenant websites with pre-configured content.
Help with Rails testing including unit tests, integration tests, fixtures, and debugging test failures. Use when working on tests or debugging test issues.
| name | e2e-testing |
| description | Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures. |
This skill covers Playwright browser testing and Lighthouse performance auditing for PropertyWebBuilder.
# 1. Install Playwright browsers
npx playwright install
# 2. Reset and seed the E2E database
RAILS_ENV=e2e bin/rails playwright:reset
The E2E environment runs on port 3001 with two test tenants.
# Standard server (requires login)
RAILS_ENV=e2e bin/rails playwright:server
# Server with admin auth bypass (for UI testing without login)
RAILS_ENV=e2e bin/rails playwright:server_bypass_auth
Test Tenants:
Test Users (per tenant):
admin@tenant-a.test / password123user@tenant-a.test / password123# Full reset (drop, create, migrate, seed)
RAILS_ENV=e2e bin/rails playwright:reset
# Re-seed only (faster, keeps schema)
RAILS_ENV=e2e bin/rails playwright:seed
# Run all tests (server must be running)
npx playwright test
# Run with UI mode (interactive)
npx playwright test --ui
# Run with headed browser (see the browser)
npx playwright test --headed
# Run a specific test file
npx playwright test tests/e2e/public/property-search.spec.js
# Run tests matching a pattern
npx playwright test -g "property search"
# Run only admin tests
npx playwright test --project=chromium-admin
# Run only public tests
npx playwright test --project=chromium
# Run with debug mode (step through)
npx playwright test --debug
# Run with trace viewer
npx playwright test --trace on
# Show HTML report after run
npx playwright show-report
tests/e2e/
├── fixtures/
│ ├── test-data.js # TENANTS, ADMIN_USERS, ROUTES constants
│ └── helpers.js # loginAsAdmin, goToTenant, resetWebsiteSettings
├── public/ # Public-facing page tests (parallel)
│ ├── property-search.spec.js
│ ├── property-details.spec.js
│ └── contact-form.spec.js
├── admin/ # Admin tests (run serially)
│ ├── editor.spec.js
│ ├── properties-settings.spec.js
│ └── site-settings.spec.js
├── auth/ # Authentication tests
│ └── sessions.spec.js
└── global-setup.js # Verifies E2E database
const { test, expect } = require('@playwright/test');
const { TENANTS, ROUTES } = require('./fixtures/test-data');
const { goToTenant, loginAsAdmin } = require('./fixtures/helpers');
test.describe('Feature Name', () => {
test('should do something', async ({ page }) => {
await goToTenant(page, TENANTS.A, ROUTES.HOME);
await expect(page).toHaveTitle(/Expected Title/);
});
});
const { ADMIN_USERS, ROUTES } = require('../fixtures/test-data');
const { loginAsAdmin, goToAdminPage } = require('../fixtures/helpers');
test.describe('Admin Feature', () => {
test.beforeEach(async ({ page }) => {
// With auth bypass server:
await goToAdminPage(page, ADMIN_USERS.TENANT_A.tenant, ROUTES.ADMIN.DASHBOARD);
// OR with regular server:
await loginAsAdmin(page, ADMIN_USERS.TENANT_A);
});
test('should manage settings', async ({ page }) => {
// test code
});
});
// Navigation
await goToTenant(page, TENANTS.A, '/en/buy');
await goToAdminPage(page, tenant, '/site_admin');
// Authentication
await loginAsAdmin(page, ADMIN_USERS.TENANT_A);
await expectToBeLoggedIn(page);
await expectToBeOnLoginPage(page);
// Forms
await fillField(page, 'Email', 'test@example.com');
await submitFormWithCsrf(page, 'form.contact-form');
await saveAndWait(page, 'Save Changes');
// Test data reset
await resetWebsiteSettings(page, tenant);
await resetAllTestData(page, tenant);
// Environment check
const isE2e = await isE2eEnvironment(page, tenant);
# Run Lighthouse CI (starts server automatically)
npx lhci autorun
# Run against running server
npx lhci collect --url=http://localhost:3000/
npx lhci assert
The lighthouserc.js file configures:
URLs Audited:
Performance Budgets:
| Metric | Threshold | Level |
|---|---|---|
| Performance Score | ≥70% | error |
| Accessibility Score | ≥90% | error |
| Best Practices | ≥90% | warn |
| SEO Score | ≥90% | error |
| LCP | ≤4.0s | error |
| CLS | ≤0.25 | error |
| FCP | ≤2.5s | warn |
| TBT | ≤500ms | warn |
# After running lhci autorun, reports are in .lighthouseci/
open .lighthouseci/lhr-*.html
# Or view the uploaded report URL (shown in terminal)
Error: page.goto: net::ERR_CONNECTION_REFUSED
Fix: Start the E2E server first:
RAILS_ENV=e2e bin/rails playwright:server
Error: E2E database not initialized
Fix: Reset the database:
RAILS_ENV=e2e bin/rails playwright:reset
Error: Auth bypass not working! Redirected to login.
Fix: Use the auth bypass server:
RAILS_ENV=e2e bin/rails playwright:server_bypass_auth
Error: Could not find website for subdomain
Fix: Ensure you're using the correct tenant URLs:
http://tenant-a.e2e.localhost:3001http://tenant-b.e2e.localhost:3001Tests failing with unexpected data
Fix: Reset test data:
RAILS_ENV=e2e bin/rails playwright:reset
# Or via helper in test:
await resetAllTestData(page, TENANTS.A);
The .github/workflows/lighthouse.yml runs Lighthouse on push/PR:
- name: Setup E2E database
run: RAILS_ENV=e2e bin/rails playwright:reset
- name: Start E2E server
run: RAILS_ENV=e2e bin/rails playwright:server_bypass_auth &
- name: Run Playwright tests
run: npx playwright test
| Task | Command |
|---|---|
| Setup E2E database | RAILS_ENV=e2e bin/rails playwright:reset |
| Start E2E server | RAILS_ENV=e2e bin/rails playwright:server |
| Start server (no auth) | RAILS_ENV=e2e bin/rails playwright:server_bypass_auth |
| Run all E2E tests | npx playwright test |
| Run tests with UI | npx playwright test --ui |
| Debug failing test | npx playwright test --debug |
| View test report | npx playwright show-report |
| Run Lighthouse | npx lhci autorun |
| Reseed test data | RAILS_ENV=e2e bin/rails playwright:seed |