fixes tests.
This commit is contained in:
@@ -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"})])
|
||||
|
||||
(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))))))
|
||||
(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: {}) { 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 } }}")))]
|
||||
(is (= 0 (:count result)))
|
||||
(is (= 0 (:start result)))
|
||||
(is (= 0 (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: {}) { count, start, data { id } }}" {:clients []})))]
|
||||
(is (= 0 (:count result)))
|
||||
(is (= 0 (:start 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))))))))
|
||||
|
||||
Reference in New Issue
Block a user