fixes tests.

This commit is contained in:
2023-08-31 23:43:19 -07:00
parent 7d251c8398
commit c98766873e
14 changed files with 49 additions and 46 deletions

0
data/inference-outcome.csv Normal file → Executable file
View File

0
data/solr/data/plaid_merchants/core.properties Normal file → Executable file
View File

View File

@@ -2,15 +2,20 @@
# Implement multi
# test headers->clients
# Still use single client in subs, but have it only be set if a single on is selected
X Implement multi
X test headers->clients
X Still use single client in subs, but have it only be set if a single on is selected
X Pass X-Clients header as :all :mine [id-1, id-2, id-3]
X Use X-Clients instead of client filter
# Remove the client specific filter from each graphql
X Remove the client specific filter from each graphql
# Test with single client user, all client user, admin, etc
# Synchronize with the backend for SSR, set in session, but hydrate to real clients in middleware
# Ensure that client selection still resets everything
X Synchronize with the backend for SSR, set in session, but hydrate to real clients in middleware
X Ensure that client selection still resets everything
# maybe set it up so that changing assignments works automatically without having to log out or in
# figure out how to not make this require a whole login
# bulk-code-transactions
X bulk-code-transactions
X all ssr pages, starting with plaid
# Make it work for everyone who refreshes tomorrow
X only show mine for admins
X company dropdown TODO - syncing with front end
# double check that transaction insights have been running all along

View File

@@ -45,8 +45,7 @@
:where '[[?e :payment/client ?c]]}
:args [db
(:exact-match-id args)
(map :db/id (:clients args))]
}
(map :db/id (:clients args))]}
(cond-> {:query {:find []
:in ['$]
:where []}
@@ -67,7 +66,7 @@
:where []}
:args [(:exact-match-id args)]})
(seq (:clients args))
true
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :payment/client ?xx]]}
:args [(map :db/id (:clients args))]})

View File

@@ -38,7 +38,7 @@
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
args)
(seq (:clients args))
true
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :expected-deposit/client ?xx]]}
:args [(set (map :db/id (:clients args)))]})

View File

@@ -99,7 +99,7 @@
:where ['[?e :invoice/due ?due]
'[(<= ?due ?end-due)]]}
:args [(coerce/to-date (:end (:due-range args)))]})
(seq (:clients args))
true
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :invoice/client ?xx]]}
:args [ (map :db/id (:clients args))]})

View File

@@ -27,7 +27,7 @@
:where []}
:args [db]}
(seq (:clients args))
true
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :journal-entry/client ?xx]]}
:args [(set (map :db/id (:clients args)))]})

View File

@@ -59,7 +59,7 @@
(merge-query {:query {:in '[[?e ...]]}
:args [potential-duplicates]})
(seq (:clients args))
true
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :transaction/client ?xx]]}
:args [(set (map :db/id (:clients args)))]})

View File

@@ -454,6 +454,7 @@
(let [transaction (d-transactions/get-by-id (:transaction_id args))
_ (assert-can-see-client (:id context) (:transaction/client transaction))
[payments _] (d-checks/get-graphql {:client-id (:db/id (:transaction/client transaction))
:clients [{:db/id (:db/id (:transaction/client transaction))}]
:bank-account-id (:db/id (:transaction/bank-account transaction))
:amount (- (:transaction/amount transaction))
:status :payment-status/pending

View File

@@ -256,6 +256,7 @@
(let [ids (some-> args
:filters
(<-graphql)
(assoc :clients (:clients args))
(update :status enum->keyword "invoice-status")
(assoc :per-page Integer/MAX_VALUE)
d-invoices/raw-graphql-ids

View File

@@ -10,9 +10,7 @@
(t/deftest plaid->transaction
(t/testing "Should invert amount if a credit account"
(t/is (= 123.45 (:transaction/amount (sut/plaid->transaction base-transaction {}))))
(t/is (= -123.45 (:transaction/amount (sut/plaid->transaction (assoc base-transaction :account {:type "credit"}) {})))))
(t/testing "Should assign a plaid merchant if a merchant is found"
(t/is (= "Home Depot" (-> (sut/plaid->transaction (assoc base-transaction
:merchant_name "Home Depot")

View File

@@ -3,7 +3,7 @@
[venia.core :as v]
[clojure.test :as t :refer [deftest is testing use-fixtures]]
[datomic.api :as dc]
[auto-ap.integration.util :refer [wrap-setup admin-token user-token]]
[auto-ap.integration.util :refer [wrap-setup admin-token user-token setup-test-data test-transaction]]
[auto-ap.datomic :refer [conn]]))
@@ -28,21 +28,19 @@
(use-fixtures :each wrap-setup)
(deftest transaction-page
(testing "transaction page"
@(dc/transact conn
[(new-client {:db/id "client"})
(new-transaction {:transaction/client "client"})])
(let [{:strs [test-client-id]} (setup-test-data [(test-transaction :transaction/description-original "hi")])]
(testing "It should find all transactions"
(let [result (:transaction-page (:data (sut/query (admin-token) "{ transaction_page(filters: {client_id: null}) { count, start, data { id } }}")))]
(let [result (:transaction-page (:data (sut/query (admin-token) "{ transaction_page(filters: {}) { count, start, data { id } }}" {:clients [{:db/id test-client-id}]})))]
(is (= 1 (:count result)))
(is (= 0 (:start result)))
(is (= 1 (count (:data result))))))
(testing "Users should not see transactions they don't own"
(let [result (:transaction-page (:data (sut/query (user-token) "{ transaction_page(filters: {client_id: null}) { count, start, data { id } }}")))]
(let [result (:transaction-page (:data (sut/query (user-token) "{ transaction_page(filters: {}) { count, start, data { id } }}" {:clients []})))]
(is (= 0 (:count result)))
(is (= 0 (:start result)))
(is (= 0 (count (:data result))))))))
(is (= 0 (count (:data result)))))))))
(deftest invoice-page
@@ -52,13 +50,13 @@
(new-invoice {:invoice/client "client"
:invoice/status :invoice-status/paid})])
(testing "It should find all invoices"
(let [result (first (:invoice-page (:data (sut/query (admin-token) "{ invoice_page(filters: {client_id: null, status:paid}) { count, start, invoices { id } }}"))))]
(let [result (first (:invoice-page (:data (sut/query (admin-token) "{ invoice_page(filters: { status:paid}) { count, start, invoices { id } }}"))))]
(is (= 1 (:count result)))
(is (= 0 (:start result)))
(is (= 1 (count (:invoices result))))))
(testing "Users should not see transactions they don't own"
(let [result (first (:invoice-page (:data (sut/query (user-token) "{ invoice_page(filters: {client_id: null}) { count, start, invoices { id } }}"))))]
(let [result (first (:invoice-page (:data (sut/query (user-token) "{ invoice_page(filters: {}) { count, start, invoices { id } }}"))))]
(is (= 0 (:count result)))
(is (= 0 (:start result)))
(is (= 0 (count (:data result))))))))

View File

@@ -53,29 +53,29 @@
:paid_to "Someone",
:_payment [],
:check_number 1000}],
(map #(dissoc % :date) (:payments (first (sut/get-payment-page {:id (admin-token)} {} nil))))))
(map #(dissoc % :date) (:payments (first (sut/get-payment-page {:clients [{:db/id client-id}]} {} nil))))))
(testing "Should omit clients that can't be seen"
(is (not (seq (:payments (first (sut/get-payment-page {:id (user-token -1)} {} nil))))))
(is (not (seq (:payments (first (sut/get-payment-page {:id (user-token -1)} {:filters {:client_id client-id}} nil)))))))
(is (not (seq (:payments (first (sut/get-payment-page {:clients nil} {} nil))))))
(is (not (seq (:payments (first (sut/get-payment-page {:clients []} {:filters {:client_id client-id}} nil)))))))
(testing "Should include clients that can be seen"
(is (-> (sut/get-payment-page {:id (user-token client-id)} {} nil)
(is (-> (sut/get-payment-page {:clients [{:db/id client-id}]} {} nil)
first
:payments
seq)))
(testing "Should filter to date ranges"
(is (-> (sut/get-payment-page {:id (user-token client-id)} {:filters {:date_range {:start #inst "2000-01-01"}}} nil)
(is (-> (sut/get-payment-page {:clients [{:db/id client-id}]} {:filters {:date_range {:start #inst "2000-01-01"}}} nil)
first
:payments
seq))
(is (-> (sut/get-payment-page {:id (user-token client-id)} {:filters {:date_range {:start #inst "2022-01-01"}}} nil)
(is (-> (sut/get-payment-page {:clients [{:db/id client-id}]} {:filters {:date_range {:start #inst "2022-01-01"}}} nil)
first
:payments
seq))
(is (not (-> (sut/get-payment-page {:id (user-token client-id)} {:filters {:date_range {:start #inst "2022-01-02"}}} nil)
(is (not (-> (sut/get-payment-page {:clients [{:db/id client-id}]} {:filters {:date_range {:start #inst "2022-01-02"}}} nil)
first
:payments
seq)))
(is (-> (sut/get-payment-page {:id (user-token client-id)} {:filters {:date_range {:end #inst "2022-01-02"}}} nil)
(is (-> (sut/get-payment-page {:clients [{:db/id client-id}]} {:filters {:date_range {:end #inst "2022-01-02"}}} nil)
first
:payments
seq))))
@@ -307,7 +307,8 @@
(deftest get-potential-payments
(testing "should match payments for a transaction"
(let [{:strs [transaction-id
payment-id]} (setup-test-data [(test-payment
payment-id
test-client-id]} (setup-test-data [(test-payment
:db/id "payment-id"
:payment/status :payment-status/pending
:payment/amount 100.0
@@ -316,7 +317,7 @@
:db/id "transaction-id"
:transaction/amount -100.0
:transaction/date #inst "2021-06-01")])]
(is (= [payment-id] (->> (sut/get-potential-payments {:id (admin-token)}
(is (= [payment-id] (->> (sut/get-potential-payments {:id (admin-token) :clients [{:db/id test-client-id}]}
{:transaction_id transaction-id}
nil)
(map :id))))))

View File

@@ -162,7 +162,7 @@
:invoice/status :invoice-status/unpaid)
(test-account :db/id "new-account-id")])]
(is (some? (sut/void-invoices {:id (admin-token)}
(is (some? (sut/void-invoices {:id (admin-token) :clients [{:db/id test-client-id}]}
{:filters {:client_id test-client-id}}
nil)))
(is (= :invoice-status/voided