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:
@@ -23,37 +23,37 @@
|
||||
(with-open [s (io/input-stream (io/resource "sample-ezcater.xlsx"))]
|
||||
(is (seq (sut/stream->sales-orders s))))
|
||||
(with-open [s (io/input-stream (io/resource "sample-ezcater.xlsx"))]
|
||||
(is (= #:sales-order
|
||||
{:vendor :vendor/ccp-ezcater
|
||||
:service-charge -95.9
|
||||
:date #inst "2023-04-03T18:30:00"
|
||||
:reference-link "ZA2-320"
|
||||
:charges
|
||||
[#:charge{:type-name "CARD"
|
||||
:date #inst "2023-04-03T18:30:00"
|
||||
:client test-client
|
||||
:location "DT"
|
||||
:external-id
|
||||
(str "ezcater/charge/" test-client "-DT-ZA2-320-0")
|
||||
:processor :ccp-processor/ezcater
|
||||
:total 516.12
|
||||
:tip 0.0}]
|
||||
:client test-client
|
||||
:tip 0.0
|
||||
:tax 37.12
|
||||
:external-id (str "ezcater/order/" test-client "-DT-ZA2-320")
|
||||
:total 516.12
|
||||
:line-items
|
||||
[#:order-line-item{:external-id
|
||||
(str "ezcater/order/" test-client "-DT-ZA2-320-0")
|
||||
:item-name "EZCater Catering"
|
||||
:category "EZCater Catering"
|
||||
:discount 0.0
|
||||
:tax 37.12
|
||||
:total 516.12}]
|
||||
:discount 0.0
|
||||
:location "DT"
|
||||
:returns 0.0}
|
||||
(last (first (filter (comp #{:order} first)
|
||||
(sut/stream->sales-orders s)))))))))))
|
||||
(is (= #:sales-order
|
||||
{:vendor :vendor/ccp-ezcater
|
||||
:service-charge -95.9
|
||||
:date #inst "2023-04-03T18:30:00"
|
||||
:reference-link "ZA2-320"
|
||||
:charges
|
||||
[#:charge{:type-name "CARD"
|
||||
:date #inst "2023-04-03T18:30:00"
|
||||
:client test-client
|
||||
:location "DT"
|
||||
:external-id
|
||||
(str "ezcater/charge/" test-client "-DT-ZA2-320-0")
|
||||
:processor :ccp-processor/ezcater
|
||||
:total 516.12
|
||||
:tip 0.0}]
|
||||
:client test-client
|
||||
:tip 0.0
|
||||
:tax 37.12
|
||||
:external-id (str "ezcater/order/" test-client "-DT-ZA2-320")
|
||||
:total 516.12
|
||||
:line-items
|
||||
[#:order-line-item{:external-id
|
||||
(str "ezcater/order/" test-client "-DT-ZA2-320-0")
|
||||
:item-name "EZCater Catering"
|
||||
:category "EZCater Catering"
|
||||
:discount 0.0
|
||||
:tax 37.12
|
||||
:total 516.12}]
|
||||
:discount 0.0
|
||||
:location "DT"
|
||||
:returns 0.0}
|
||||
(last (first (filter (comp #{:order} first)
|
||||
(sut/stream->sales-orders s)))))))))))
|
||||
|
||||
|
||||
@@ -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))))
|
||||
|
||||
Reference in New Issue
Block a user