test(invoice): add integration tests for invoice behaviors

- Fix schema ordering: move :journal-entry-line/running-balance to schema.edn
- Add invoice_behaviors_test.clj covering:
  - Permission gates (26.5, 26.6, 26.8)
  - Lock date blocking (27.1, 27.3)
  - New invoice validation (8.1, 8.5)
  - Edit invoice (11.1, 11.3)
  - Bulk edit (15.4)
  - Single/bulk void (16.3, 16.4, 17.1)
  - Unvoid restoring from history (18.1)
  - Undo autopay (19.1)
  - Invoice list filtering (2.6, 2.8, 2.10, 2.14)
  - Invoice list sorting (3.5, 3.7, 3.10)
  - Invoice list pagination (4.1, 4.3)
  - Legacy route redirects (28.1)
- Mock Solr in wrap-setup fixture to prevent Connection refused
- Fix setup-test-data to merge user-provided entities with defaults
- Fix InMemSolrClient.index_documents to handle entity IDs
- Fix ezcater_xls test to use dynamic entity IDs
- Update invoice.md behavior checklist with completed items
This commit is contained in:
2026-05-04 23:10:46 -07:00
parent da7897c0d6
commit ececdc8f5f
7 changed files with 697 additions and 81 deletions

View File

@@ -5,7 +5,8 @@
(defn wrap-setup
[f]
(with-redefs [auto-ap.datomic/uri "datomic:mem://test"]
(with-redefs [auto-ap.datomic/uri "datomic:mem://test"
auto-ap.solr/impl (auto-ap.solr/->InMemSolrClient (atom {}))]
(dc/create-database auto-ap.datomic/uri)
(with-redefs [auto-ap.datomic/conn (dc/connect auto-ap.datomic/uri)]
(transact-schema conn)
@@ -28,6 +29,13 @@
:user/name "TEST USER"
:user/clients [{:db/id client-id}]}))
(defn user-token-no-access []
{:user "TEST USER"
:exp (time/plus (time/now) (time/days 1))
:user/role "user"
:user/name "TEST USER"
:user/clients []})
@@ -101,16 +109,18 @@
(dissoc x :id))
(defn setup-test-data [data]
(:tempids @(dc/transact conn (into data
[(test-account :db/id "test-account-id")
(test-client :db/id "test-client-id"
:client/bank-accounts [(test-bank-account :db/id "test-bank-account-id")])
(test-vendor :db/id "test-vendor-id")
{:db/id "accounts-payable-id"
:account/name "Accounts Payable"
:db/ident :account/accounts-payable
:account/numeric-code 21000
:account/account-set "default"}]))))
(let [defaults [(test-account :db/id "test-account-id")
(test-client :db/id "test-client-id"
:client/bank-accounts [(test-bank-account :db/id "test-bank-account-id")])
(test-vendor :db/id "test-vendor-id")
{:db/id "accounts-payable-id"
:account/name "Accounts Payable"
:db/ident :account/accounts-payable
:account/numeric-code 21000
:account/account-set "default"}]
user-ids (set (keep :db/id data))
merged (into [] (concat data (remove #(user-ids (:db/id %)) defaults)))]
(:tempids @(dc/transact conn merged))))
(defn apply-tx [data]
(:db-after @(dc/transact conn data)))