test: add Playwright E2E setup with CI workflow#2
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 authsetupproject. Frappe.localhostmultisite routing handled via127.0.0.1+Hostheader for API calls and Chromium--host-resolver-rulesfor navigations.e2e/tests/auth.setup.ts+e2e/helpers/— browser-fetchlogin 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 liveget_balancespath (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:🤖 Generated with Claude Code