fixes tests.
This commit is contained in:
0
data/inference-outcome.csv
Normal file → Executable file
0
data/inference-outcome.csv
Normal file → Executable file
0
data/solr/data/plaid_merchants/core.properties
Normal file → Executable file
0
data/solr/data/plaid_merchants/core.properties
Normal file → Executable file
21
notes.txt
21
notes.txt
@@ -2,15 +2,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Implement multi
|
X Implement multi
|
||||||
# test headers->clients
|
X test headers->clients
|
||||||
# Still use single client in subs, but have it only be set if a single on is selected
|
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 Pass X-Clients header as :all :mine [id-1, id-2, id-3]
|
||||||
X Use X-Clients instead of client filter
|
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
|
# 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
|
X Synchronize with the backend for SSR, set in session, but hydrate to real clients in middleware
|
||||||
# Ensure that client selection still resets everything
|
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
|
# 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
|
X bulk-code-transactions
|
||||||
# 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
|
||||||
|
|||||||
@@ -45,8 +45,7 @@
|
|||||||
:where '[[?e :payment/client ?c]]}
|
:where '[[?e :payment/client ?c]]}
|
||||||
:args [db
|
:args [db
|
||||||
(:exact-match-id args)
|
(:exact-match-id args)
|
||||||
(map :db/id (:clients args))]
|
(map :db/id (:clients args))]}
|
||||||
}
|
|
||||||
(cond-> {:query {:find []
|
(cond-> {:query {:find []
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where []}
|
:where []}
|
||||||
@@ -67,7 +66,7 @@
|
|||||||
:where []}
|
:where []}
|
||||||
:args [(:exact-match-id args)]})
|
:args [(:exact-match-id args)]})
|
||||||
|
|
||||||
(seq (:clients args))
|
true
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :payment/client ?xx]]}
|
:where ['[?e :payment/client ?xx]]}
|
||||||
:args [(map :db/id (:clients args))]})
|
:args [(map :db/id (:clients args))]})
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
|
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
|
||||||
args)
|
args)
|
||||||
|
|
||||||
(seq (:clients args))
|
true
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :expected-deposit/client ?xx]]}
|
:where ['[?e :expected-deposit/client ?xx]]}
|
||||||
:args [(set (map :db/id (:clients args)))]})
|
:args [(set (map :db/id (:clients args)))]})
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
:where ['[?e :invoice/due ?due]
|
:where ['[?e :invoice/due ?due]
|
||||||
'[(<= ?due ?end-due)]]}
|
'[(<= ?due ?end-due)]]}
|
||||||
:args [(coerce/to-date (:end (:due-range args)))]})
|
:args [(coerce/to-date (:end (:due-range args)))]})
|
||||||
(seq (:clients args))
|
true
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :invoice/client ?xx]]}
|
:where ['[?e :invoice/client ?xx]]}
|
||||||
:args [ (map :db/id (:clients args))]})
|
:args [ (map :db/id (:clients args))]})
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
:where []}
|
:where []}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
|
|
||||||
(seq (:clients args))
|
true
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :journal-entry/client ?xx]]}
|
:where ['[?e :journal-entry/client ?xx]]}
|
||||||
:args [(set (map :db/id (:clients args)))]})
|
:args [(set (map :db/id (:clients args)))]})
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
(merge-query {:query {:in '[[?e ...]]}
|
(merge-query {:query {:in '[[?e ...]]}
|
||||||
:args [potential-duplicates]})
|
:args [potential-duplicates]})
|
||||||
|
|
||||||
(seq (:clients args))
|
true
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :transaction/client ?xx]]}
|
:where ['[?e :transaction/client ?xx]]}
|
||||||
:args [(set (map :db/id (:clients args)))]})
|
:args [(set (map :db/id (:clients args)))]})
|
||||||
|
|||||||
@@ -454,6 +454,7 @@
|
|||||||
(let [transaction (d-transactions/get-by-id (:transaction_id args))
|
(let [transaction (d-transactions/get-by-id (:transaction_id args))
|
||||||
_ (assert-can-see-client (:id context) (:transaction/client transaction))
|
_ (assert-can-see-client (:id context) (:transaction/client transaction))
|
||||||
[payments _] (d-checks/get-graphql {:client-id (:db/id (: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))
|
:bank-account-id (:db/id (:transaction/bank-account transaction))
|
||||||
:amount (- (:transaction/amount transaction))
|
:amount (- (:transaction/amount transaction))
|
||||||
:status :payment-status/pending
|
:status :payment-status/pending
|
||||||
|
|||||||
@@ -256,6 +256,7 @@
|
|||||||
(let [ids (some-> args
|
(let [ids (some-> args
|
||||||
:filters
|
:filters
|
||||||
(<-graphql)
|
(<-graphql)
|
||||||
|
(assoc :clients (:clients args))
|
||||||
(update :status enum->keyword "invoice-status")
|
(update :status enum->keyword "invoice-status")
|
||||||
(assoc :per-page Integer/MAX_VALUE)
|
(assoc :per-page Integer/MAX_VALUE)
|
||||||
d-invoices/raw-graphql-ids
|
d-invoices/raw-graphql-ids
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
(t/deftest plaid->transaction
|
(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/testing "Should assign a plaid merchant if a merchant is found"
|
||||||
(t/is (= "Home Depot" (-> (sut/plaid->transaction (assoc base-transaction
|
(t/is (= "Home Depot" (-> (sut/plaid->transaction (assoc base-transaction
|
||||||
:merchant_name "Home Depot")
|
:merchant_name "Home Depot")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
[venia.core :as v]
|
[venia.core :as v]
|
||||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||||
[datomic.api :as dc]
|
[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]]))
|
[auto-ap.datomic :refer [conn]]))
|
||||||
|
|
||||||
|
|
||||||
@@ -28,21 +28,19 @@
|
|||||||
(use-fixtures :each wrap-setup)
|
(use-fixtures :each wrap-setup)
|
||||||
(deftest transaction-page
|
(deftest transaction-page
|
||||||
(testing "transaction page"
|
(testing "transaction page"
|
||||||
@(dc/transact conn
|
(let [{:strs [test-client-id]} (setup-test-data [(test-transaction :transaction/description-original "hi")])]
|
||||||
[(new-client {:db/id "client"})
|
|
||||||
(new-transaction {:transaction/client "client"})])
|
(testing "It should find all transactions"
|
||||||
|
(let [result (:transaction-page (:data (sut/query (admin-token) "{ transaction_page(filters: {}) { count, start, data { id } }}" {:clients [{:db/id test-client-id}]})))]
|
||||||
(testing "It should find all transactions"
|
(is (= 1 (:count result)))
|
||||||
(let [result (:transaction-page (:data (sut/query (admin-token) "{ transaction_page(filters: {client_id: null}) { count, start, data { id } }}")))]
|
(is (= 0 (:start result)))
|
||||||
(is (= 1 (:count result)))
|
(is (= 1 (count (:data result))))))
|
||||||
(is (= 0 (:start result)))
|
|
||||||
(is (= 1 (count (:data result))))))
|
|
||||||
|
|
||||||
(testing "Users should not see transactions they don't own"
|
(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 (:count result)))
|
||||||
(is (= 0 (:start result)))
|
(is (= 0 (:start result)))
|
||||||
(is (= 0 (count (:data result))))))))
|
(is (= 0 (count (:data result)))))))))
|
||||||
|
|
||||||
|
|
||||||
(deftest invoice-page
|
(deftest invoice-page
|
||||||
@@ -52,13 +50,13 @@
|
|||||||
(new-invoice {:invoice/client "client"
|
(new-invoice {:invoice/client "client"
|
||||||
:invoice/status :invoice-status/paid})])
|
:invoice/status :invoice-status/paid})])
|
||||||
(testing "It should find all invoices"
|
(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 (= 1 (:count result)))
|
||||||
(is (= 0 (:start result)))
|
(is (= 0 (:start result)))
|
||||||
(is (= 1 (count (:invoices result))))))
|
(is (= 1 (count (:invoices result))))))
|
||||||
|
|
||||||
(testing "Users should not see transactions they don't own"
|
(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 (:count result)))
|
||||||
(is (= 0 (:start result)))
|
(is (= 0 (:start result)))
|
||||||
(is (= 0 (count (:data result))))))))
|
(is (= 0 (count (:data result))))))))
|
||||||
|
|||||||
@@ -53,29 +53,29 @@
|
|||||||
:paid_to "Someone",
|
:paid_to "Someone",
|
||||||
:_payment [],
|
:_payment [],
|
||||||
:check_number 1000}],
|
: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"
|
(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 {:clients nil} {} 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 []} {:filters {:client_id client-id}} nil)))))))
|
||||||
(testing "Should include clients that can be seen"
|
(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
|
first
|
||||||
:payments
|
:payments
|
||||||
seq)))
|
seq)))
|
||||||
(testing "Should filter to date ranges"
|
(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
|
first
|
||||||
:payments
|
:payments
|
||||||
seq))
|
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
|
first
|
||||||
:payments
|
:payments
|
||||||
seq))
|
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
|
first
|
||||||
:payments
|
:payments
|
||||||
seq)))
|
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
|
first
|
||||||
:payments
|
:payments
|
||||||
seq))))
|
seq))))
|
||||||
@@ -307,7 +307,8 @@
|
|||||||
(deftest get-potential-payments
|
(deftest get-potential-payments
|
||||||
(testing "should match payments for a transaction"
|
(testing "should match payments for a transaction"
|
||||||
(let [{:strs [transaction-id
|
(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"
|
:db/id "payment-id"
|
||||||
:payment/status :payment-status/pending
|
:payment/status :payment-status/pending
|
||||||
:payment/amount 100.0
|
:payment/amount 100.0
|
||||||
@@ -316,7 +317,7 @@
|
|||||||
:db/id "transaction-id"
|
:db/id "transaction-id"
|
||||||
:transaction/amount -100.0
|
:transaction/amount -100.0
|
||||||
:transaction/date #inst "2021-06-01")])]
|
: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}
|
{:transaction_id transaction-id}
|
||||||
nil)
|
nil)
|
||||||
(map :id))))))
|
(map :id))))))
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
:invoice/status :invoice-status/unpaid)
|
:invoice/status :invoice-status/unpaid)
|
||||||
(test-account :db/id "new-account-id")])]
|
(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}}
|
{:filters {:client_id test-client-id}}
|
||||||
nil)))
|
nil)))
|
||||||
(is (= :invoice-status/voided
|
(is (= :invoice-status/voided
|
||||||
|
|||||||
Reference in New Issue
Block a user