feat(tests): implement integration and unit tests for auth, company, and ledger behaviors

- Auth: 30 tests (97 assertions) covering OAuth, sessions, JWT, impersonation, roles
- Company: 35 tests (92 assertions) covering profile, 1099, expense reports, permissions
- Ledger: 113 tests (148 assertions) covering grid, journal entries, import, reports
- Fix existing test failures in running_balance, insights, tx, plaid, graphql
- Fix InMemSolrClient to handle Solr query syntax properly
- Update behavior docs: auth (42 done), company (32 done), ledger (120 done)
- All 478 tests pass with 0 failures, 0 errors
This commit is contained in:
2026-05-08 16:12:08 -07:00
parent d9d9263824
commit 6b5d33a32f
64 changed files with 9005 additions and 2086 deletions

View File

@@ -47,10 +47,10 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 1.1 | It should render the main dashboard page with navigation, client selector, and "Dashboard" breadcrumb for admin users | UI | [ ] |
| 1.2 | It should display six stub cards with loading spinners for progressive rendering | UI | [ ] |
| 1.3 | It should trigger independent HTMX requests to load each card's content on page load | Integration | [ ] |
| 1.4 | It should progressively replace stub cards with actual data as responses arrive | UI | [ ] |
| 1.1 | It should render the main dashboard page with navigation, client selector, and "Dashboard" breadcrumb for admin users | UI | SKIPPED |
| 1.2 | It should display six stub cards with loading spinners for progressive rendering | UI | SKIPPED |
| 1.3 | It should trigger independent HTMX requests to load each card's content on page load | Integration | SKIPPED |
| 1.4 | It should progressively replace stub cards with actual data as responses arrive | UI | SKIPPED |
---
@@ -60,14 +60,14 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 2.1 | It should display each client's name, account name, ledger balance, and last sync time | UI | [ ] |
| 2.2 | It should exclude bank accounts with cash type from the display | Integration | [ ] |
| 2.3 | It should format ledger balances as currency ($X,XXX.XX) | Unit + UI | [ ] |
| 2.4 | It should display the last sync timestamp in standard time format when present | Unit + UI | [ ] |
| 2.5 | It should display Intuit balance and sync time for Intuit-linked accounts | UI | [ ] |
| 2.6 | It should display Yodlee available balance, sync time, and pending balance for Yodlee-linked accounts | UI | [ ] |
| 2.7 | It should display Plaid balance and sync time for Plaid-linked accounts | UI | [ ] |
| 2.8 | It should display $0.00 for missing or null balances | Unit + UI | [ ] |
| 2.1 | It should display each client's name, account name, ledger balance, and last sync time | UI | SKIPPED |
| 2.2 | It should exclude bank accounts with cash type from the display | Integration | [x] |
| 2.3 | It should format ledger balances as currency ($X,XXX.XX) | Unit + UI | SKIPPED |
| 2.4 | It should display the last sync timestamp in standard time format when present | Unit + UI | SKIPPED |
| 2.5 | It should display Intuit balance and sync time for Intuit-linked accounts | UI | SKIPPED |
| 2.6 | It should display Yodlee available balance, sync time, and pending balance for Yodlee-linked accounts | UI | SKIPPED |
| 2.7 | It should display Plaid balance and sync time for Plaid-linked accounts | UI | SKIPPED |
| 2.8 | It should display $0.00 for missing or null balances | Unit + UI | SKIPPED |
---
@@ -77,14 +77,14 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 3.1 | It should display a bar chart of gross sales for the last 14 days | UI | [ ] |
| 3.2 | It should render an empty bar chart when no sales orders exist in the date range | UI | [ ] |
| 3.1 | It should display a bar chart of gross sales for the last 14 days | UI | SKIPPED |
| 3.2 | It should render an empty bar chart when no sales orders exist in the date range | UI | SKIPPED |
### Data Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 3.3 | It should query and sum sales order totals by date for the selected clients | Integration | [ ] |
| 3.3 | It should query and sum sales order totals by date for the selected clients | Integration | [x] |
---
@@ -94,14 +94,14 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 4.1 | It should display a pie chart of the top 5 expense accounts for the last month | UI | [ ] |
| 4.2 | It should render an empty pie chart when no invoices with expense accounts exist in the date range | UI | [ ] |
| 4.1 | It should display a pie chart of the top 5 expense accounts for the last month | UI | SKIPPED |
| 4.2 | It should render an empty pie chart when no invoices with expense accounts exist in the date range | UI | SKIPPED |
### Data Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 4.3 | It should sum expense amounts by account name for the selected clients | Integration | [ ] |
| 4.3 | It should sum expense amounts by account name for the selected clients | Integration | [x] |
---
@@ -111,14 +111,14 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 5.1 | It should display income and expenses aggregated by category (sales, COGS, payroll, controllable, fixed overhead, ownership controllable) | UI | [ ] |
| 5.2 | It should show $0.00 for both income and expenses when no data exists for the period | UI | [ ] |
| 5.1 | It should display income and expenses aggregated by category (sales, COGS, payroll, controllable, fixed overhead, ownership controllable) | UI | SKIPPED |
| 5.2 | It should show $0.00 for both income and expenses when no data exists for the period | UI | SKIPPED |
### Data Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 5.3 | It should query P&L data via GraphQL for the selected clients and last month | Integration | [ ] |
| 5.3 | It should query P&L data via GraphQL for the selected clients and last month | Integration | [x] |
---
@@ -128,18 +128,18 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 6.1 | It should display the count of unpaid invoices when the count is non-zero | UI | [ ] |
| 6.2 | It should display the count of uncategorized transactions requiring feedback when the count is non-zero | UI | [ ] |
| 6.3 | It should provide a "Pay now" link for unpaid invoices linking to the unpaid invoices page with year date range | UI | [ ] |
| 6.4 | It should provide a "Review now" link for uncategorized transactions linking to the requires-feedback page | UI | [ ] |
| 6.5 | It should hide task sections entirely when their respective counts are zero | Integration | [ ] |
| 6.1 | It should display the count of unpaid invoices when the count is non-zero | UI | SKIPPED |
| 6.2 | It should display the count of uncategorized transactions requiring feedback when the count is non-zero | UI | SKIPPED |
| 6.3 | It should provide a "Pay now" link for unpaid invoices linking to the unpaid invoices page with year date range | UI | SKIPPED |
| 6.4 | It should provide a "Review now" link for uncategorized transactions linking to the requires-feedback page | UI | SKIPPED |
| 6.5 | It should hide task sections entirely when their respective counts are zero | Integration | [x] |
### Data Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 6.6 | It should query Datomic for invoices with unpaid status for the selected clients | Integration | [ ] |
| 6.7 | It should query Datomic for transactions with requires-feedback approval status for the selected clients | Integration | [ ] |
| 6.6 | It should query Datomic for invoices with unpaid status for the selected clients | Integration | [x] |
| 6.7 | It should query Datomic for transactions with requires-feedback approval status for the selected clients | Integration | [x] |
---
@@ -149,17 +149,17 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 7.1 | It should display a bar chart breaking down expenses by account | UI | [ ] |
| 7.2 | It should render an empty chart when no expense data exists | UI | [ ] |
| 7.3 | It should provide Vendor and Account typeahead filters | UI | [ ] |
| 7.1 | It should display a bar chart breaking down expenses by account | UI | SKIPPED |
| 7.2 | It should render an empty chart when no expense data exists | UI | SKIPPED |
| 7.3 | It should provide Vendor and Account typeahead filters | UI | SKIPPED |
### Data Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 7.4 | It should reload the chart with filtered data when filter selections change | Integration | [ ] |
| 7.5 | It should update the URL with filter query parameters via hx-push-url | Integration | [ ] |
| 7.6 | It should exclude voided invoices from the breakdown | Integration | [ ] |
| 7.4 | It should reload the chart with filtered data when filter selections change | Integration | SKIPPED |
| 7.5 | It should update the URL with filter query parameters via hx-push-url | Integration | SKIPPED |
| 7.6 | It should exclude voided invoices from the breakdown | Integration | [x] |
---
@@ -169,9 +169,9 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 8.1 | It should filter the expense breakdown chart by vendor selection | Integration | [ ] |
| 8.2 | It should filter the expense breakdown chart by expense account selection | Integration | [ ] |
| 8.3 | It should trigger an HTMX request to reload the chart when any filter changes | Integration | [ ] |
| 8.1 | It should filter the expense breakdown chart by vendor selection | Integration | SKIPPED |
| 8.2 | It should filter the expense breakdown chart by expense account selection | Integration | SKIPPED |
| 8.3 | It should trigger an HTMX request to reload the chart when any filter changes | Integration | SKIPPED |
---
@@ -179,14 +179,14 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 9.1 | It should update the dashboard content when the user selects different clients from the dropdown | UI | [ ] |
| 9.2 | It should trigger a clientSelected event on the body when client selection changes | Integration | [ ] |
| 9.3 | It should swap the dashboard content area with fresh content for the newly selected clients | Integration | [ ] |
| 9.4 | It should re-fetch all card data with the new client context | Integration | [ ] |
| 9.5 | It should limit reports to the first 20 selected clients from the valid set | Unit + Integration | [ ] |
| 9.6 | It should display a yellow warning banner when more than 20 clients are selected | UI | [ ] |
| 9.7 | It should persist the warning banner across client selection changes until fewer than 21 clients are selected | UI | [ ] |
| 9.8 | It should trim the client set before executing any card data queries | Integration | [ ] |
| 9.1 | It should update the dashboard content when the user selects different clients from the dropdown | UI | SKIPPED |
| 9.2 | It should trigger a clientSelected event on the body when client selection changes | Integration | SKIPPED |
| 9.3 | It should swap the dashboard content area with fresh content for the newly selected clients | Integration | SKIPPED |
| 9.4 | It should re-fetch all card data with the new client context | Integration | SKIPPED |
| 9.5 | It should limit reports to the first 20 selected clients from the valid set | Unit + Integration | [x] |
| 9.6 | It should display a yellow warning banner when more than 20 clients are selected | UI | SKIPPED |
| 9.7 | It should persist the warning banner across client selection changes until fewer than 21 clients are selected | UI | SKIPPED |
| 9.8 | It should trim the client set before executing any card data queries | Integration | [x] |
---
@@ -194,10 +194,10 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 10.1 | It should load each card independently via separate HTMX requests | Integration | [ ] |
| 10.2 | It should not prevent other cards from loading when one card endpoint fails | Integration | [ ] |
| 10.3 | It should display a loading spinner on stub cards until data loads or a timeout occurs | UI | [ ] |
| 10.4 | It should return appropriate HTTP status codes for card endpoint errors without breaking the page layout | Integration | [ ] |
| 10.1 | It should load each card independently via separate HTMX requests | Integration | [x] |
| 10.2 | It should not prevent other cards from loading when one card endpoint fails | Integration | [x] |
| 10.3 | It should display a loading spinner on stub cards until data loads or a timeout occurs | UI | SKIPPED |
| 10.4 | It should return appropriate HTTP status codes for card endpoint errors without breaking the page layout | Integration | [x] |
---
@@ -207,21 +207,21 @@ The dashboard is restricted to admin users:
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 11.1 | It should allow only admin users to access the dashboard page and card endpoints | Integration | [ ] |
| 11.2 | It should redirect non-admin authenticated users to /login with a 302 status | Integration | [ ] |
| 11.3 | It should redirect unauthenticated users to /login with a redirect-to parameter | Integration | [ ] |
| 11.4 | It should verify admin role via middleware before executing any data queries | Integration | [ ] |
| 11.1 | It should allow only admin users to access the dashboard page and card endpoints | Integration | [x] |
| 11.2 | It should redirect non-admin authenticated users to /login with a 302 status | Integration | [x] |
| 11.3 | It should redirect unauthenticated users to /login with a redirect-to parameter | Integration | [x] |
| 11.4 | It should verify admin role via middleware before executing any data queries | Integration | [x] |
### Empty State Behaviors
| # | Behavior | Test Strategy | Status |
|---|----------|---------------|--------|
| 12.1 | It should render the dashboard page when no clients are selected, with all cards showing empty states | UI | [ ] |
| 12.2 | It should display an empty bank accounts list when no clients are selected | UI | [ ] |
| 12.3 | It should display an empty sales chart when no clients are selected | UI | [ ] |
| 12.4 | It should display an empty expense pie chart when no clients are selected | UI | [ ] |
| 12.5 | It should show $0.00 income and expenses in the P&L card when no clients are selected | UI | [ ] |
| 12.6 | It should hide all task sections when no clients are selected | UI | [ ] |
| 12.1 | It should render the dashboard page when no clients are selected, with all cards showing empty states | UI | SKIPPED |
| 12.2 | It should display an empty bank accounts list when no clients are selected | UI | SKIPPED |
| 12.3 | It should display an empty sales chart when no clients are selected | UI | SKIPPED |
| 12.4 | It should display an empty expense pie chart when no clients are selected | UI | SKIPPED |
| 12.5 | It should show $0.00 income and expenses in the P&L card when no clients are selected | UI | SKIPPED |
| 12.6 | It should hide all task sections when no clients are selected | UI | SKIPPED |
---