Skip to content

test: add Playwright E2E setup with CI workflow#2

Merged
NagariaHussain merged 5 commits into
developfrom
test/e2e-playwright-setup
Jun 3, 2026
Merged

test: add Playwright E2E setup with CI workflow#2
NagariaHussain merged 5 commits into
developfrom
test/e2e-playwright-setup

Conversation

@NagariaHussain

Copy link
Copy Markdown
Contributor

What

Adds an end-to-end test harness for Ledger Lab, ported from the hive app's Playwright setup and adapted for an ERPNext-dependent Desk-page app run by a single Administrator user — plus one basic smoke test and a CI workflow so it runs on every PR.

Why

Ledger Lab had server-test CI only. This brings the same browser-driven E2E coverage hive uses, so dashboard regressions are caught in CI and the setup is reproducible locally.

What's included

  • playwright.config.ts + package.json — single Chromium project gated on a one-time auth setup project. Frappe .localhost multisite routing handled via 127.0.0.1 + Host header for API calls and Chromium --host-resolver-rules for navigations.
  • e2e/tests/auth.setup.ts + e2e/helpers/ — browser-fetch login that persists storage state + CSRF token, and a Frappe REST API helper toolkit (createDoc/getList/callMethod/…).
  • e2e/tests/dashboard.spec.ts — one basic smoke test for /app/ledger-lab: asserts the equation hero, the six root-type boxes, the Balance Sheet / P&L / feed sections, and the live get_balances path (proven by the equation status pill resolving to Balanced, with box values no longer the placeholder).
  • ledger_lab/e2e_seed.py — seeds a company + chart of accounts, a fiscal year, and one submitted Journal Entry, so a fresh CI site has live figures and a feed entry. Idempotent.
  • .github/workflows/ui-tests.yml — installs ERPNext + Ledger Lab, configures + seeds the site, starts bench, and runs Playwright; uploads the HTML report + traces on failure.

Verification

Run locally against ledger.localhost — both the auth setup and the dashboard test pass:

✓ [setup]    › auth.setup.ts › authenticate
✓ [chromium] › dashboard.spec.ts › renders the equation, the six boxes, and loads balanced figures
2 passed

🤖 Generated with Claude Code

NagariaHussain and others added 5 commits June 3, 2026 12:21
Port the end-to-end test harness from the hive app, adapted for Ledger
Lab (an ERPNext-dependent Desk-page app, single Administrator user):

- playwright.config.ts + package.json: Chromium project gated on a
  one-time auth setup; 127.0.0.1 + Host-header / host-resolver-rules
  routing for Frappe's .localhost multisite.
- e2e/tests/auth.setup.ts + e2e/helpers: browser-fetch login that saves
  storage state + CSRF, and a Frappe REST API helper toolkit.
- e2e/tests/dashboard.spec.ts: one basic smoke test for /app/ledger-lab
  (equation hero, six root-type boxes, BS/P&L/feed sections, and the
  live get_balances path proven by the "Balanced" status pill).
- ledger_lab/e2e_seed.py: seeds a company + chart of accounts, a fiscal
  year, and one submitted Journal Entry so a fresh CI site has live data.
- .github/workflows/ui-tests.yml: installs ERPNext + Ledger Lab, seeds,
  starts the server, and runs Playwright.

Verified locally against ledger.localhost: both setup + dashboard pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous seed created a Company directly, which failed in CI with
"Could not find Warehouse Type: Transit" — a bare `install-app erpnext`
(no setup wizard) never installs the preset records the company's hooks
depend on.

Use ERPNext's programmatic `setup_complete` entrypoint instead: its
fixtures stage installs the country presets (Warehouse Types, UOMs, …)
before creating the company, chart of accounts, fiscal year, and global
defaults. Guard against `make_records` silently swallowing a failed
insert by asserting the company materialized.

Validated against a real ERPNext (develop) inside a rolled-back
transaction: company + chart + fiscal year created and a balanced
Journal Entry posted (2 GL entries).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CI seeded a company but /app/ledger-lab still redirected to the Frappe
onboarding wizard: ERPNext's setup_complete stage-runner doesn't set the
global System Settings.setup_complete flag, which the desk uses to gate
every route. Set it in the seed.

Also give the dashboard's first content assertion a 30s timeout to
absorb desk cold-start on a fresh CI server.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The desk gate `frappe.is_setup_complete()` reads
`Installed Application.is_setup_complete` per app (frappe + erpnext),
not `System Settings.setup_complete`. Setting the latter left the
onboarding wizard intercepting /app/ledger-lab. Flip the per-app flag
on every installed app instead.

Verified against the local site: is_setup_complete() gates on the
frappe + erpnext rows; a fresh install has them at 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On a freshly-booted CI desk, navigating to /app to read the CSRF token
can trigger a client-side redirect that destroys the page's execution
context mid-evaluate, failing the whole auth setup. Save the cookie
storage state first (that's what authenticated tests need), then treat
CSRF retrieval as best-effort: longer wait, guarded evaluate, never
fatal. The API helpers already tolerate a missing CSRF token.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NagariaHussain NagariaHussain merged commit 4167254 into develop Jun 3, 2026
3 of 4 checks passed
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.

1 participant