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:
@@ -55,33 +55,33 @@ Line items are added and removed dynamically without page reload:
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 2.1 | It should require client selection | Integration | [ ] |
|
||||
| 2.2 | It should require invoice date | Integration | [ ] |
|
||||
| 2.3 | It should require recipient name in "To" field | Integration | [ ] |
|
||||
| 2.4 | It should require invoice number | Integration | [ ] |
|
||||
| 2.5 | It should require at least one line item with description, quantity, and unit price | Integration | [ ] |
|
||||
| 2.6 | It should make recipient address street2 optional | Unit | [ ] |
|
||||
| 2.7 | It should strip whitespace from street2 and treat empty as nil | Unit | [ ] |
|
||||
| 2.8 | It should coerce line items from nested form parameters into a vector | Unit | [ ] |
|
||||
| 2.1 | It should require client selection | Integration | [x] |
|
||||
| 2.2 | It should require invoice date | Integration | SKIPPED |
|
||||
| 2.3 | It should require recipient name in "To" field | Integration | SKIPPED |
|
||||
| 2.4 | It should require invoice number | Integration | SKIPPED |
|
||||
| 2.5 | It should require at least one line item with description, quantity, and unit price | Integration | SKIPPED |
|
||||
| 2.6 | It should make recipient address street2 optional | Unit | [x] |
|
||||
| 2.7 | It should strip whitespace from street2 and treat empty as nil | Unit | [x] |
|
||||
| 2.8 | It should coerce line items from nested form parameters into a vector | Unit | [x] |
|
||||
| 2.9 | It should display validation errors next to the offending fields | UI | [ ] |
|
||||
| 2.10 | It should redisplay the form with entered data preserved when validation fails | Integration | [ ] |
|
||||
| 2.10 | It should redisplay the form with entered data preserved when validation fails | Integration | [x] |
|
||||
|
||||
### Submission Behaviors
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 3.1 | It should filter out line items with empty descriptions before calculation | Unit | [ ] |
|
||||
| 3.2 | It should calculate each line item total as `unit-price * quantity` | Unit | [ ] |
|
||||
| 3.3 | It should calculate subtotal as the sum of all line item totals | Unit | [ ] |
|
||||
| 3.4 | It should calculate tax as `subtotal * (tax-rate / 100)` | Unit | [ ] |
|
||||
| 3.5 | It should calculate total as `subtotal + tax` | Unit | [ ] |
|
||||
| 3.6 | It should format monetary values as `$X,XXX.XX` strings before sending to Lambda | Unit | [ ] |
|
||||
| 3.7 | It should format the invoice date as `normal-date` string before sending to Lambda | Unit | [ ] |
|
||||
| 3.8 | It should invoke the `genpdf` Lambda function with a JSON payload | Integration | [ ] |
|
||||
| 3.9 | It should extract the S3 URL from the Lambda response | Integration | [ ] |
|
||||
| 3.1 | It should filter out line items with empty descriptions before calculation | Unit | [x] |
|
||||
| 3.2 | It should calculate each line item total as `unit-price * quantity` | Unit | [x] |
|
||||
| 3.3 | It should calculate subtotal as the sum of all line item totals | Unit | [x] |
|
||||
| 3.4 | It should calculate tax as `subtotal * (tax-rate / 100)` | Unit | [x] |
|
||||
| 3.5 | It should calculate total as `subtotal + tax` | Unit | [x] |
|
||||
| 3.6 | It should format monetary values as `$X,XXX.XX` strings before sending to Lambda | Unit | [x] |
|
||||
| 3.7 | It should format the invoice date as `normal-date` string before sending to Lambda | Unit | [x] |
|
||||
| 3.8 | It should invoke the `genpdf` Lambda function with a JSON payload | Integration | SKIPPED |
|
||||
| 3.9 | It should extract the S3 URL from the Lambda response | Integration | SKIPPED |
|
||||
| 3.10 | It should display a modal with "Download your invoice" and a link to the S3 URL | UI | [ ] |
|
||||
| 3.11 | Given the Lambda invocation fails, then it should display an error without showing a modal | Integration | [ ] |
|
||||
| 3.12 | Given all line items are empty, then subtotal should be `0.0`, tax should be `0.0`, and total should be `0.0` | Unit | [ ] |
|
||||
| 3.11 | Given the Lambda invocation fails, then it should display an error without showing a modal | Integration | SKIPPED |
|
||||
| 3.12 | Given all line items are empty, then subtotal should be `0.0`, tax should be `0.0`, and total should be `0.0` | Unit | [x] |
|
||||
|
||||
---
|
||||
|
||||
@@ -91,7 +91,7 @@ Line items are added and removed dynamically without page reload:
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 4.1 | It should fetch a new empty line item row via HTMX when "Add line" is clicked | Integration | [ ] |
|
||||
| 4.1 | It should fetch a new empty line item row via HTMX when "Add line" is clicked | Integration | [x] |
|
||||
| 4.2 | It should append the new row to the line items grid | UI | [ ] |
|
||||
| 4.3 | It should render each row with hidden db/id, description input, quantity money-input, unit-price money-input, and delete button | UI | [ ] |
|
||||
| 4.4 | It should allow adding multiple line items | UI | [ ] |
|
||||
@@ -109,10 +109,10 @@ Line items are added and removed dynamically without page reload:
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 6.1 | It should handle negative quantities in line item calculations | Unit | [ ] |
|
||||
| 6.2 | It should show `$0.00` for line items with zero unit price | Unit | [ ] |
|
||||
| 6.3 | It should format large monetary values with comma separators (e.g., `$1,234.56`) | Unit | [ ] |
|
||||
| 6.4 | It should format nil monetary values as `$0.00` | Unit | [ ] |
|
||||
| 6.1 | It should handle negative quantities in line item calculations | Unit | [x] |
|
||||
| 6.2 | It should show `$0.00` for line items with zero unit price | Unit | [x] |
|
||||
| 6.3 | It should format large monetary values with comma separators (e.g., `$1,234.56`) | Unit | [x] |
|
||||
| 6.4 | It should format nil monetary values as `$0.00` | Unit | [x] |
|
||||
|
||||
---
|
||||
|
||||
@@ -122,19 +122,19 @@ Line items are added and removed dynamically without page reload:
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 7.1 | It should invoke `genpdf` Lambda with a JSON payload containing invoice data | Integration | [ ] |
|
||||
| 7.2 | It should include formatted monetary strings in the Lambda payload | Unit | [ ] |
|
||||
| 7.3 | It should include the invoice date as a `normal-date` string in the Lambda payload | Unit | [ ] |
|
||||
| 7.4 | It should extract the S3 URL from a successful Lambda response | Integration | [ ] |
|
||||
| 7.1 | It should invoke `genpdf` Lambda with a JSON payload containing invoice data | Integration | SKIPPED |
|
||||
| 7.2 | It should include formatted monetary strings in the Lambda payload | Unit | SKIPPED |
|
||||
| 7.3 | It should include the invoice date as a `normal-date` string in the Lambda payload | Unit | SKIPPED |
|
||||
| 7.4 | It should extract the S3 URL from a successful Lambda response | Integration | SKIPPED |
|
||||
| 7.5 | It should present the S3 URL as a clickable download link in the modal | UI | [ ] |
|
||||
|
||||
### Error Handling Behaviors
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 8.1 | Given the Lambda returns invalid JSON, then it should propagate an error | Integration | [ ] |
|
||||
| 8.1 | Given the Lambda returns invalid JSON, then it should propagate an error | Integration | SKIPPED |
|
||||
| 8.2 | Given the S3 URL is inaccessible, then the link should still be presented but may fail on click | UI | [ ] |
|
||||
| 8.3 | Given a very large invoice payload, then Lambda payload size limits may apply | Integration | [ ] |
|
||||
| 8.3 | Given a very large invoice payload, then Lambda payload size limits may apply | Integration | SKIPPED |
|
||||
|
||||
---
|
||||
|
||||
@@ -144,26 +144,26 @@ Line items are added and removed dynamically without page reload:
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 9.1 | It should redirect unauthenticated users to `/login` | Integration | [ ] |
|
||||
| 9.2 | It should redirect unauthenticated users back to `/outgoing-invoice/new` after login | Integration | [ ] |
|
||||
| 9.3 | It should apply `wrap-secure` middleware to all routes | Integration | [ ] |
|
||||
| 9.4 | It should apply `wrap-trim-client-ids` middleware to requests | Integration | [ ] |
|
||||
| 9.1 | It should redirect unauthenticated users to `/login` | Integration | [x] |
|
||||
| 9.2 | It should redirect unauthenticated users back to `/outgoing-invoice/new` after login | Integration | [x] |
|
||||
| 9.3 | It should apply `wrap-secure` middleware to all routes | Integration | [x] |
|
||||
| 9.4 | It should apply `wrap-trim-client-ids` middleware to requests | Integration | [x] |
|
||||
|
||||
### Client Selection Behaviors
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 10.1 | It should populate the client typeahead from the `:company-search` endpoint | Integration | [ ] |
|
||||
| 10.2 | It should only show clients the authenticated user has access to | Integration | [ ] |
|
||||
| 10.1 | It should populate the client typeahead from the `:company-search` endpoint | Integration | [x] |
|
||||
| 10.2 | It should only show clients the authenticated user has access to | Integration | [x] |
|
||||
|
||||
### Tax Behaviors
|
||||
|
||||
| # | Behavior | Test Strategy | Status |
|
||||
|---|----------|---------------|--------|
|
||||
| 11.1 | It should treat a whole number tax (e.g., 10) as 10% | Unit | [ ] |
|
||||
| 11.2 | It should treat a decimal tax (e.g., 8.25) as 8.25% | Unit | [ ] |
|
||||
| 11.3 | It should allow tax rates over 100% | Unit | [ ] |
|
||||
| 11.4 | It should calculate total equal to subtotal when tax is zero | Unit | [ ] |
|
||||
| 11.1 | It should treat a whole number tax (e.g., 10) as 10% | Unit | [x] |
|
||||
| 11.2 | It should treat a decimal tax (e.g., 8.25) as 8.25% | Unit | [x] |
|
||||
| 11.3 | It should allow tax rates over 100% | Unit | [x] |
|
||||
| 11.4 | It should calculate total equal to subtotal when tax is zero | Unit | [x] |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user