OWASP/OpenCRE

E2E: migrate frontend to Cypress (consolidate #729 + #774); keep Python Playwright

开放

#967 创建于 2026年7月8日

 (8 条评论) (0 个反应) (1 位负责人)Python (116 个派生)auto 404
good first issuehelp wanted

仓库指标

星标
 (167 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Goal

Consolidate frontend E2E from Jest/Puppeteer to Cypress; keep Python Playwright for backend/embeddings E2E (separate concern).

Context

Frontend browser E2E is effectively dead on main today:

  • yarn test:e2e runs Jest (package.json), but application/frontend/src/test/basic-e2e.test.ts is fully commented out (legacy Puppeteer)
  • .github/workflows/e2e.yml is entirely commented out — E2E does not run in CI
  • jest-puppeteer / puppeteer remain in package.json as dead tooling

Playwright in this repo is Python-only (application/prompt_client/ for embeddings/scraping). It is not the frontend E2E runner. make install-python must keep playwright install.

Two open PRs overlap on Cypress migration (see Pending merges):

  • #729 — restore Cypress under application/frontend/src/test/cypress/, re-enable e2e.yml
  • #774 — fuller migration: root cypress.config.js, cypress/e2e/smoke.cy.js, stabilized make e2e, switches test:e2e to cypress run

Related: #523 (fix e2e tests).

Implementation instructions

0. Playwright guardrail (dependency — do first)

  • Ensure playwright install stays in install-python (Makefile) — required for application/prompt_client/
  • Merge or cherry-pick branch chore/playwright-install-guardrail (commit 69049e36) before or as part of this work — documents the guardrail in Makefile + AGENTS.md
  • Do not remove Python Playwright when migrating frontend to Cypress

1. Document legacy Jest/Puppeteer coverage

Read application/frontend/src/test/basic-e2e.test.ts (commented) and record what routes/flows it covered. Historical coverage included:

Flow Route / behavior
Homepage search UI /#SearchBar visible, contains "Search"
No-results search / → search asdf → "No results match your search term"
Successful free-text search / → search crypto → results with standards + CREs
Standard browse /node/standard/ASVS — heading, pagination, section link, external reference, CRE link
CRE search by ID / → search 558-807 → CRE title, nested accordion
CRE filter (case-insensitive) /cre/558-807?applyFilters=true&filters=asvs and filters=ASVS
Smartlink redirect /smartlink/standard/CWE/1002/node/standard/CWE/sectionid/1002; /smartlink/standard/CWE/404 → external CWE URL

2. Migrate to Cypress

  • Use #774 as the base (Makefile e2e fixes, root cypress.config.js, smoke suite, package.json scripts)
  • Cherry-pick anything still useful from #729 if not duplicated
  • package.json: test:e2ecypress run; add cypress:open / cypress:run; add cypress devDependency
  • Root cypress.config.js + cypress/e2e/ suite (start with smoke, expand toward legacy coverage)
  • Remove obsolete cypress.json and commented/deleted basic-e2e.test.ts
  • make e2e: deterministic Flask on 127.0.0.1:5000, readiness wait, trap cleanup (from #774)
  • Prefer stable selectors (form#search-bar, semantic roles) over brittle CSS chains
  • Close #729 as superseded once consolidated PR merges

3. Wire Cypress into CI

  • Re-enable .github/workflows/e2e.yml (or equivalent job) so PRs run Cypress smoke E2E
  • Fix YAML indentation/structure (both #729 and #774 drafts need review — current e2e.yml on main is fully commented)
  • Ensure deploy workflows (deploy.yml, deploy-staging.yml) can depend on a green Test-e2e job again

4. Keep Python Playwright separate

  • Do not conflate Cypress (frontend) with Python Playwright (embeddings/scraping)
  • Python tests under application/tests/ that use Playwright (e.g. prompt_client_pdf_embeddings_test.py, embedding registration tests) must still pass

5. Cleanup (in scope or follow-up PR)

  • Remove or fully replace deprecated Jest E2E config (jest-puppeteer, puppeteer in package.json) without leaving dead tooling
  • Document local run instructions (see success criteria)

Success criteria

All must pass before closing this issue:

  • Route/feature coverage at least equivalent to historical Jest/Puppeteer E2E — minimum smoke (homepage search form, search → /search/{term}, browse /root_cres); stretch goal: port the flows in the table above (standard browse, CRE search/filter, smartlink)
  • Clean code: follows existing frontend conventions; no flaky tests; sensible selectors; documented how to run locally (make e2e, yarn cypress:open)
  • E2E restored in CI: Cypress job green on PRs (.github/workflows/e2e.yml or equivalent)
  • Python Playwright tests still run and passplaywright install in make install-python unchanged; embedding/scraping tests unaffected
  • make frontend / yarn build passes
  • README or AGENTS.md notes how to run Cypress locally
  • Deprecated Jest E2E tooling removed or fully replaced — no commented-out Puppeteer suite, no test:e2ejest on main
  • make lint passes
  • make e2e passes locally (Cypress smoke: 3+ tests green)
  • Only one open Cypress migration PR; #729 closed as superseded

Pending merges

Item Status
chore/playwright-install-guardrail (69049e36) Remote branch exists; no open PR; not on main
#774 Open — recommended base for consolidated work
#729 Open — supersede/close after consolidation
#732 Open — Cypress Makefile integration (stale, Test check failing)
.github/workflows/e2e.yml on main Fully commented out — E2E not in CI

PRs to merge/close

PR Action
#774 Base for consolidated migration (after playwright guardrail)
#729 Close as superseded
chore/playwright-install-guardrail Open PR and merge first (or include in consolidated PR)

贡献者指南