whisper-money/tests/Browser
Víctor Falcón c4987b7f05
test(open-banking): e2e coverage for Enable Banking connection flows (#509)
## Why

Bank connection via Enable Banking is a critical flow that must keep
working in **both onboarding and settings**, including reconnecting an
expired consent. This adds regression coverage so it never silently
breaks.

## What

Two complementary layers:

### 1. CI regression — mocked Pest browser tests
`tests/Browser/BankConnectionFlowTest.php` drives the full UI →
`authorize` → `callback` → account mapping → sync flow for all three
scenarios, with the banking provider faked
(`tests/Support/FakeBankingProvider.php`). Deterministic, no external
calls.

-  connect from onboarding (accounts auto-created)
-  connect from settings (+ account mapping)
-  reconnect an expired connection (re-matches accounts by IBAN)

**Runs on CI** in the existing `browser-tests` job (distributed across
shards automatically as a new test; `shards.json` timing entry will be
added next time `update-browser-shards` runs).

### 2. Live-sandbox verification — standalone Playwright script
`tests/Browser/live/connect-bank.mjs` runs the same three flows against
the **real Enable Banking sandbox** (Banco de Sabadell + BBVA) via the
dev server, for on-demand / nightly checks. Backed by a local-only
helper command `app/Console/Commands/E2eBankingFixtureCommand.php`.

**Does not run on CI** (needs the dev server, live sandbox, and
secrets). See `tests/Browser/live/README.md`.

#### Why the live flow can't be a normal Pest test
Enable Banking only redirects to the fixed registered URI
(`https://whisper.money.local/open-banking/callback`). A
`RefreshDatabase` Pest test runs an ephemeral server on a random port
with a transactional DB the external redirect can never reach. The
script instead drives the persistent dev server, captures the
`code`+`state` the bank redirects with, and replays the callback against
the dev server (the callback is stateless — keyed by `state_token`).

## Verification

- Mocked Pest tests: **3 passing**.
- Live script: **all 3 scenarios PASS** against the real sandbox
(Sabadell → 5 accounts + 328 tx synced; BBVA onboarding → 7 accounts;
expired → reconnect refreshes `valid_until` and retains accounts).
- `pint --test`, eslint, prettier clean.

> Note: while verifying locally, the dev DB was missing the
`state_token` migration (`2026_06_05_185212`), which made
`/open-banking/authorize` 500. Worth confirming it's applied in other
environments.
2026-06-09 11:58:50 +02:00
..
assets Improve automation rules and sync error handling 2025-12-01 10:30:22 +01:00
live test(open-banking): e2e coverage for Enable Banking connection flows (#509) 2026-06-09 11:58:50 +02:00
.gitignore Add category type field support (#2) 2025-12-01 20:19:47 +01:00
AccountsPageTest.php test: expand browser coverage for accounts and linked loans (#277) 2026-04-13 09:33:18 +01:00
AmountInputTest.php fix(transactions): fix toolbar overflow on mobile and shorten button label (#175) 2026-03-01 17:57:59 +00:00
AuthenticationTest.php Support soft-deleted users with reusable emails (#316) 2026-04-22 11:41:41 +01:00
AutomationRuleBuilderTest.php feat: parent/child category tree (#474) 2026-06-03 19:30:12 +02:00
BankAccountsTest.php feat(loans): backfill historical balances on loan creation (#322) 2026-04-24 13:09:34 +01:00
BankConnectionFlowTest.php test(open-banking): e2e coverage for Enable Banking connection flows (#509) 2026-06-09 11:58:50 +02:00
BudgetCrudTest.php feat(budgets): track multiple categories and labels per budget (#466) 2026-06-01 12:32:23 +02:00
BudgetsFeatureNavigationTest.php feat(budgets): track multiple categories and labels per budget (#466) 2026-06-01 12:32:23 +02:00
CashflowCategoryNavigationTest.php feat(cashflow): make income/expense category rows clickable to transactions (#234) 2026-03-17 10:57:40 +00:00
CategoriesTest.php fix(categories): expose cashflow setting on create (#448) 2026-05-29 11:05:04 +02:00
ImportTransactionsTest.php Remove encryption from browser tests and demo user (#129) 2026-02-17 11:45:27 +01:00
OnboardingFlowTest.php feat(open-banking): finalize bank connection without a session via state token (#498) 2026-06-06 12:12:07 +02:00
RealEstateAccountTest.php refactor(real-estate): remove Pennant gating (#308) 2026-04-20 13:31:49 +01:00
TransactionsTest.php Fix label creation dropdown refresh (#363) 2026-05-07 10:26:43 +01:00