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

@@ -53,28 +53,26 @@
(t/testing "It should find the order from ezcater"
(with-redefs [sut/get-caterer (fn [k]
(t/is (= k "91541331-d7ae-4634-9e8b-ccbbcfb2ce70"))
{
:ezcater-integration/_caterers {:ezcater-integration/api-key "bmlrdHNpZ2FyaXNAZ21haWwuY29tOmQwMzQwMjYzOWI2ODQxNmVkMjdmZWYxMWFhZTk3YzU1MDlmNTcyNjYwMDAzOTA5MDE2OGMzODllNDBjNTVkZGE"}
{:ezcater-integration/_caterers {:ezcater-integration/api-key "bmlrdHNpZ2FyaXNAZ21haWwuY29tOmQwMzQwMjYzOWI2ODQxNmVkMjdmZWYxMWFhZTk3YzU1MDlmNTcyNjYwMDAzOTA5MDE2OGMzODllNDBjNTVkZGE"}
:ezcater-location/_caterer [{:ezcater-location/location "DT"
:client/_ezcater-locations {:client/code "ABC"}}]
})]
:client/_ezcater-locations {:client/code "ABC"}}]})]
(t/is (= known-order
(sut/lookup-order sample-event))))))
(t/deftest order->sales-order
(t/testing "It should use the date"
(t/is (= #clj-time/date-time "2022-01-01T00:00:00-08:00"
(-> known-order
(assoc-in [:event :timestamp]
"2022-01-01T08:00:00Z")
(sut/order->sales-order)
(:sales-order/date ))))
(-> known-order
(assoc-in [:event :timestamp]
"2022-01-01T08:00:00Z")
(sut/order->sales-order)
(:sales-order/date))))
(t/is (= #clj-time/date-time "2022-06-01T00:00:00-07:00"
(-> known-order
(assoc-in [:event :timestamp]
"2022-06-01T07:00:00Z")
(sut/order->sales-order)
(:sales-order/date )))))
(:sales-order/date)))))
(t/testing "It should simulate a single line item for everything"
(t/is (= 1
(-> known-order
@@ -83,49 +81,48 @@
count)))
(t/is (= #{"EZCater Catering"}
(->> known-order
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/category)
set))))
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/category)
set))))
(t/testing "It should generate an external-id"
(t/is (= "ezcater/order/ABC-DT-9ab05fee-a9c5-483b-a7f2-14debde4b7a8"
(:sales-order/external-id (sut/order->sales-order known-order)))))
(t/testing "Should capture amounts"
(t/is (= 35.09 (-> known-order
sut/order->sales-order
:sales-order/tax)))
(t/is (= 0.0 (-> known-order
sut/order->sales-order
:sales-order/tip))))
sut/order->sales-order
:sales-order/tip))))
(t/testing "Should calculate 7% commision on ezcater orders"
(t/is (dollars= 7.0
(-> known-order
(assoc :orderSourceType "EZCATER")
(assoc-in [:totals :subTotal :subunits] 10000)
sut/commision)))
(t/is (dollars= 7.0
(-> known-order
(assoc :orderSourceType "EZCATER")
(assoc-in [:totals :subTotal :subunits] 10000)
sut/commision)))
(t/testing "Should inlclude delivery fee in commision"
(t/is (dollars= 14.0
(-> known-order
(assoc :orderSourceType "EZCATER")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/is (dollars= 14.0
(-> known-order
(assoc :orderSourceType "EZCATER")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/testing "Should calculate 15% commision on marketplace orders"
(t/is (dollars= 15.0
(-> known-order
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
sut/commision)))
(t/is (dollars= 15.0
(-> known-order
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
sut/commision)))
(t/testing "Should inlclude delivery fee in commision"
(t/is (dollars= 30.0
(-> known-order
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/is (dollars= 30.0
(-> known-order
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/testing "Should calculate 2.75% ccp fee"
(t/is (dollars= 8.97
(-> known-order
@@ -138,7 +135,7 @@
(t/is (dollars= 454.09
(-> known-order
sut/order->sales-order
:sales-order/total))))
:sales-order/total))))
(t/testing "Should derive adjustments food-total + sales-tax - caterer-total - service fee - ccp fee"
(t/is (dollars= -42.99
(-> known-order