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

@@ -24,12 +24,12 @@
:account/name "Food"})
(defn invoice-count-for-client [c]
(or
(first (first (dc/q '[:find (count ?i)
(or
(first (first (dc/q '[:find (count ?i)
:in $ ?c
:where [?i :invoice/client ?c]]
(dc/db conn) c)))
0))
0))
(def invoice {:customer-identifier "ABC"
:date (coerce/to-date-time #inst "2021-01-01")
@@ -49,11 +49,10 @@
(t/testing "Should only import the same invoice once"
(t/is (thrown? Exception (sut/import-uploaded-invoice user [(assoc invoice :customer-identifier "ABC")])))
(t/is (thrown? Exception (sut/import-uploaded-invoice user [(assoc invoice
:customer-identifier "ABC"
:total "456.32")]))))
:customer-identifier "ABC"
:total "456.32")]))))
(t/testing "Should override location"
(sut/import-uploaded-invoice user [(assoc invoice
@@ -61,26 +60,26 @@
:customer-identifier "ABC"
:invoice-number "789")])
(t/is (= #{["DE"]} (dc/q '[:find ?l
:where [?i :invoice/invoice-number "789"]
[?i :invoice/expense-accounts ?ea]
[?ea :invoice-expense-account/location ?l]]
(dc/db conn)))))
:where [?i :invoice/invoice-number "789"]
[?i :invoice/expense-accounts ?ea]
[?ea :invoice-expense-account/location ?l]]
(dc/db conn)))))
(t/testing "Should code invoice"
(let [{{:strs [my-default-account coded-vendor]} :tempids} @(dc/transact conn
[{:vendor/name "Coded"
:db/id "coded-vendor"
:vendor/terms 12
:vendor/default-account "my-default-account"}
{:db/id "my-default-account"
:account/name "My default-account"}])]
[{:vendor/name "Coded"
:db/id "coded-vendor"
:vendor/terms 12
:vendor/default-account "my-default-account"}
{:db/id "my-default-account"
:account/name "My default-account"}])]
(sut/import-uploaded-invoice user [(assoc invoice
:invoice-number "456"
:customer-identifier "ABC"
:vendor-code "Coded")])
:invoice-number "456"
:customer-identifier "ABC"
:vendor-code "Coded")])
(let [[[result]] (dc/q '[:find (pull ?i [*])
:where [?i :invoice/invoice-number "456"]]
(dc/db conn))]
:where [?i :invoice/invoice-number "456"]]
(dc/db conn))]
(t/is (= coded-vendor (:db/id (:invoice/vendor result))))
(t/is (= [my-default-account]
(map (comp :db/id :invoice-expense-account/account) (:invoice/expense-accounts result))))