added auditing.
This commit is contained in:
@@ -23,7 +23,67 @@
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
(defn user-token []
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id 1}]})
|
||||
|
||||
(defn new-client [args]
|
||||
(merge {:client/name "Test client"
|
||||
:client/code (.toString (java.util.UUID/randomUUID))
|
||||
:client/locations ["AB"]}
|
||||
args))
|
||||
|
||||
(defn new-transaction [args]
|
||||
(merge {:transaction/amount 100.0
|
||||
:transaction/id (.toString (java.util.UUID/randomUUID))}
|
||||
args))
|
||||
|
||||
(defn new-invoice [args]
|
||||
(merge {:invoice/total 100.0
|
||||
:invoice/invoice-number (.toString (java.util.UUID/randomUUID))}
|
||||
args))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
(deftest transaction-page
|
||||
(testing "transaction page"
|
||||
@(d/transact (d/connect uri)
|
||||
[(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: {client_id: null}) { count, start, data { 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 } }}")))]
|
||||
(is (= 0 (:count result)))
|
||||
(is (= 0 (:start result)))
|
||||
(is (= 0 (count (:data result))))))))
|
||||
|
||||
|
||||
(deftest invoice-page
|
||||
(testing "invoice page"
|
||||
@(d/transact (d/connect uri)
|
||||
[(new-client {:db/id "client"})
|
||||
(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(client_id: null, 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(client_id: null) { count, start, invoices { id } }}"))))]
|
||||
(is (= 0 (:count result)))
|
||||
(is (= 0 (:start result)))
|
||||
(is (= 0 (count (:data result))))))))
|
||||
|
||||
(deftest ledger-page
|
||||
(testing "ledger"
|
||||
(testing "it should find ledger entries"
|
||||
|
||||
Reference in New Issue
Block a user