Skip to content

[haxcms-nodejs] Expand E2E UI tests (edit/export/page-mgmt) + document QA process - #17

Merged
btopro merged 1 commit into
mainfrom
e2e-expansion-2939
Jul 22, 2026
Merged

[haxcms-nodejs] Expand E2E UI tests (edit/export/page-mgmt) + document QA process#17
btopro merged 1 commit into
mainfrom
e2e-expansion-2939

Conversation

@btopro

@btopro btopro commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Expands the E2E UI test suite (established in PR #16) with three new workflows covering the remaining core user tasks from issue #2939, and documents the suite in AGENTS.md so future agents run it as part of their QA workflow.

Tracks: haxtheweb/issues#2939

New E2E tests

All reuse the existing 5-layer harness + helpers, all on the fixed site HAXSITEAUTOMATEDTESTING:

Test Task Key assertions
edit-content.e2e.test.cjs Edit & save content in HAX editor PATCH /x/api/v1/content/:idOrSlug (saveNode) → 200; typed content present in the page HTML file on disk; a11y scan of editor chrome; visual baseline (editor in edit mode)
export-site.e2e.test.cjs Export/download site as zip POST /sites/:siteName/download → 200 + data.link ends .zip + data.name; zip exists at _published/haxsiteautomatedtesting.zip with PK magic bytes; a11y + visual baselines
page-management.e2e.test.cjs Add + delete a page POST /x/api/v1/items (createNode) → 200 + data.id + data.title; DELETE /x/api/v1/items/:id → 200; page removed from site.json manifest + items list; a11y + visual baselines

Selector map extended

test/e2e/helpers/selectors.cjs now includes editor, export, and outline selector groups plus saveNode/createNode/deleteNode/saveOutline/downloadSite API paths, verified by a headless discovery pass (test/e2e/helpers/.discovery-editor.cjs).

QA process documentation (AGENTS.md)

  • Testing Instructions rewritten to document all three test tiers: test:e2e (UI workflow tests via headless Chrome), test:api-conformance (API contract tests), and npm test (generic), with prerequisites and a pointer to test/e2e/README.md.
  • Pre-commit checks updated to require npm run test:e2e before/after changes that touch the app-hax dashboard, site editor, or system/site API routes, and npm run test:api-conformance after API route changes.
  • New "QA process for agents" subsection with the 5-step workflow future agents should follow: establish a green baseline before writing, re-run after, review visual warnings, reuse helpers for new tests, run both suites for full coverage — plus the key gotchas (light-DOM login, HAXCMS_ROOT trailing slash, variable-depth editor shadow DOM).

Test results

Full suite (all 6 E2E tests):

# tests 33
# pass 32
# fail 0
# skipped 1

(The 1 skip is the optional login negative-path subtest from PR #16.)

How to run

npm run test:e2e          # run all E2E tests
npm run test:e2e:update   # regenerate visual baselines (after intentional UI changes)

Prerequisites: Chrome/Chromium on the host (auto-detected; override with PUPPETEER_EXECUTABLE_PATH). Full docs in test/e2e/README.md.

Notable findings during implementation

  • Editor content body: haxcms-site-editor renders inside the active theme at a variable shadow-DOM depth, so deepQuery can't reach it. The edit-content test uses a recursive shadow-DOM walk to find hax-body and calls its importContent(html) method to type.
  • Export confirmation modal: clicking the simple-toolbar-button host for "Download" doesn't fire the click — the handler lives on the inner <button> in its shadowRoot. The export test clicks the inner button (same escalation pattern as the archive test).
  • Page delete: the NodeJS backend's HAXCMSSite.deleteNode() only splices the item out of manifest.items + saves site.json — it does NOT delete the pages/item-<uuid>/ directory (left orphaned by design). The page-management test asserts the truthful behavior (page removed from manifest + items list), not a directory-removal that doesn't happen.
  • Create/delete via global events: the most reliable way to trigger createNode/deleteNode is dispatching haxcms-create-node/haxcms-delete-node global events (which the site-editor listens for), rather than driving the outline designer UI directly.

Co-Authored-By: Oz oz-agent@warp.dev

…t QA process

Adds three new E2E workflows to the suite established in PR #16, covering the
remaining core user tasks from issue #2939, and documents the E2E suite in
AGENTS.md so future agents run it as part of their QA workflow.

New E2E tests (all reuse the existing 5-layer harness + helpers, all on the
fixed site HAXSITEAUTOMATEDTESTING):
- edit-content: open the HAX site editor, type content via importContent, save,
  assert PATCH /x/api/v1/content/:idOrSlug 200 + typed content present in the
  page HTML file on disk. Uses a recursive shadow-DOM walk to reach hax-body
  (haxcms-site-editor renders inside the active theme at a variable depth).
- export-site: trigger download via the site card more-vert menu, assert
  POST /sites/:siteName/download 200 + data.link ends .zip + zip exists at
  _published/haxsiteautomatedtesting.zip with PK magic bytes.
- page-management: add a page via the haxcms-create-node global event (POST
  /x/api/v1/items 200 + data.id + title), delete it via haxcms-delete-node
  (DELETE /x/api/v1/items/:id 200), and verify the page is removed from the
  site.json manifest + items list. (Note: the backend intentionally leaves
  the page directory on disk after delete — the test asserts the truthful
  manifest/items behavior, not a directory-removal that doesn't happen.)

Selector map extended (test/e2e/helpers/selectors.cjs) with editor, export, and
outline selector groups + saveNode/createNode/deleteNode/saveOutline/downloadSite
API paths, verified by a headless discovery pass (.discovery-editor.cjs).

QA process documentation (AGENTS.md):
- Rewrote Testing Instructions to document all three test tiers (test:e2e,
  test:api-conformance, npm test) with prerequisites.
- Updated Pre-commit checks to require test:e2e before/after dashboard/editor/
  route changes and test:api-conformance after API route changes.
- Added a 'QA process for agents' subsection with the 5-step workflow future
  agents should follow (establish green baseline, re-run after changes, review
  visual warnings, reuse helpers for new tests, run both suites for full
  coverage) plus the key gotchas (light-DOM login, HAXCMS_ROOT trailing slash,
  variable-depth editor shadow DOM).

Full suite: 33 tests, 32 pass, 0 fail, 1 skipped.

Tracks: haxtheweb/issues#2939

Co-Authored-By: Oz <oz-agent@warp.dev>
Copilot AI review requested due to automatic review settings July 22, 2026 19:30
@codesandbox

codesandbox Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands the existing test/e2e puppeteer-driven workflow suite to cover additional core HAXcms UI tasks (edit/save content, export/download site, add/delete page) and updates contributor/agent documentation to standardize QA expectations.

Changes:

  • Added 3 new E2E UI workflow tests for editor save, site export, and page management.
  • Extended the centralized selector/API-path map and added an editor-focused discovery script.
  • Updated AGENTS.md and test/e2e/README.md to document the full QA/test workflow and new test coverage.

Reviewed changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
AGENTS.md Documents the 3-tier testing strategy and a concrete QA workflow for agents/contributors.
test/e2e/README.md Updates E2E documentation to include the new workflows and discovery script.
test/e2e/helpers/selectors.cjs Adds selector groups + API path constants for editor/export/outline flows.
test/e2e/helpers/.discovery-editor.cjs Adds a discovery script to validate editor/export/outline DOM and request shapes.
test/e2e/edit-content.e2e.test.cjs New workflow test for editing and saving content via the site editor.
test/e2e/export-site.e2e.test.cjs New workflow test for downloading a site zip via the dashboard UI.
test/e2e/page-management.e2e.test.cjs New workflow test for creating and deleting a page, plus outline-dialog a11y/visual capture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

(outlineDiff.diffPercent * 100).toFixed(3) + '% (WARN only, non-fatal)',
)
}
}, { timeout: 360000 })
Comment on lines +8 to +11
// /x/api/v1/items cross-check that the page is present -> DELETE the page via the
// VERIFIED global `haxcms-delete-node` event (DELETE /x/api/v1/items/:id) ->
// disk cross-check (page directory removed) -> open the outline editor dialog ->
// a11y scan scoped to the outline dialog -> visual baseline 'page-management-outline'.
Comment on lines +65 to +74
// --- HAXCMS_ROOT harness workaround ---------------------------------------
// The E2E harness sets process.env.HAXCMS_ROOT to runtimeRoot WITHOUT a
// trailing slash. HAXCMS.js captures a module-level const HAXCMS_ROOT at load
// time, and createSite() uses STRING concatenation (HAXCMS_ROOT + sitesDirectory)
// which yields "runtimeRoot_sites" (missing path separator) instead of
// "runtimeRoot/_sites". loadSite() and downloadSite() use the INSTANCE property
// HAXCMS.HAXCMS_ROOT, so patching the instance property fixes those routes.
// We cannot patch the module-level const, so after create we relocate the site
// dir from "runtimeRoot_sites" into "runtimeRoot/_sites" so the patched
// load/download routes find it. Same workaround as archive-site test.
Comment on lines +82 to +84
// Relocate the just-created site from the module-const write path
// (runtimeRoot + "_sites" = "runtimeRoot_sites") into the path.join path
// (runtimeRoot/_sites) so the patched load/download routes find it.
@btopro
btopro merged commit 41f60d8 into main Jul 22, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants