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

@@ -9,27 +9,25 @@
(use-fixtures :each wrap-setup)
#_(deftest edit-user
(testing "should allow editing a user"
(testing "should allow editing a user"
(let [{{:strs [user-id] } :tempids} @(d/transact conn [{:db/id "user-id" :user/name "Bryce"}])
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user :id user-id}} nil)]
(is (some? (:id result))
(= :power_user (:role result)))
(testing "Should allow adding clients"
(let [{{:strs [client-id] } :tempids} @(d/transact conn [{:db/id "client-id" :client/name "Bryce"}])
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
:id user-id
:clients [(str client-id)]}} nil)]
(is (= client-id (get-in result [:clients 0 :id])))))
(testing "Should allow adding clients"
(let [result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
:id user-id
:clients []}} nil)]
(is (not (seq (:clients result))))))
(testing "Should disallow normies"
(is (thrown? Exception (sut/edit-user {:id (user-token)} {:edit_user {:role :power_user
:id user-id
:clients []}} nil)))))))
(let [{{:strs [user-id]} :tempids} @(d/transact conn [{:db/id "user-id" :user/name "Bryce"}])
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user :id user-id}} nil)]
(is (some? (:id result))
(= :power_user (:role result)))
(testing "Should allow adding clients"
(let [{{:strs [client-id]} :tempids} @(d/transact conn [{:db/id "client-id" :client/name "Bryce"}])
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
:id user-id
:clients [(str client-id)]}} nil)]
(is (= client-id (get-in result [:clients 0 :id])))))
(testing "Should allow adding clients"
(let [result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
:id user-id
:clients []}} nil)]
(is (not (seq (:clients result))))))
(testing "Should disallow normies"
(is (thrown? Exception (sut/edit-user {:id (user-token)} {:edit_user {:role :power_user
:id user-id
:clients []}} nil)))))))