♻️ Replace mount with integrant.

This commit is contained in:
Andrey Antukh 2020-12-24 14:32:19 +01:00 committed by Alonso Torres
parent 31d7aacec1
commit 9f12456456
76 changed files with 2403 additions and 2215 deletions

View file

@ -9,58 +9,54 @@
(ns app.tests.helpers
(:require
[expound.alpha :as expound]
[app.common.pages :as cp]
[app.common.uuid :as uuid]
[app.config :as cfg]
[app.db :as db]
[app.main :as main]
[app.media-storage]
[app.media]
[app.migrations]
[app.rpc.mutations.files :as files]
[app.rpc.mutations.profile :as profile]
[app.rpc.mutations.projects :as projects]
[app.rpc.mutations.teams :as teams]
[app.util.blob :as blob]
[app.util.storage :as ust]
[clojure.java.io :as io]
[clojure.spec.alpha :as s]
[promesa.core :as p]
[datoteka.core :as fs]
[cuerdas.core :as str]
[mount.core :as mount]
[datoteka.core :as fs]
[environ.core :refer [env]]
[app.common.pages :as cp]
[app.services]
[app.services.mutations.profile :as profile]
[app.services.mutations.projects :as projects]
[app.services.mutations.teams :as teams]
[app.services.mutations.files :as files]
[app.migrations]
[app.media]
[app.media-storage]
[app.db :as db]
[app.util.blob :as blob]
[app.common.uuid :as uuid]
[app.util.storage :as ust]
[app.config :as cfg])
[integrant.core :as ig]
[promesa.core :as p])
(:import org.postgresql.ds.PGSimpleDataSource))
(defn testing-datasource
[]
(doto (PGSimpleDataSource.)
(.setServerName "postgres")
(.setDatabaseName "penpot_test")
(.setUser "penpot")
(.setPassword "penpot")))
(def ^:dynamic *system* nil)
(def ^:dynamic *pool* nil)
(defn state-init
[next]
(let [config (cfg/read-test-config env)]
(let [config (-> (main/build-system-config @cfg/test-config)
(dissoc :app.srepl/server
:app.http/server
:app.http/router
:app.notifications/handler
:app.http.auth/google
:app.http.auth/gitlab
:app.worker/scheduler
:app.worker/executor
:app.worker/worker))
_ (ig/load-namespaces config)
system (-> (ig/prep config)
(ig/init))]
(try
(let [pool (testing-datasource)]
(-> (mount/only #{#'app.config/config
#'app.db/pool
#'app.redis/client
#'app.redis/conn
#'app.media/semaphore
#'app.services/query-services
#'app.services/mutation-services
#'app.migrations/migrations
#'app.media-storage/assets-storage
#'app.media-storage/media-storage})
(mount/swap {#'app.config/config config
#'app.db/pool pool})
(mount/start)))
(next)
(binding [*system* system
*pool* (:app.db/pool system)]
(next))
(finally
(mount/stop)))))
(ig/halt! system)))))
(defn database-reset
[next]
@ -68,7 +64,7 @@
" FROM information_schema.tables "
" WHERE table_schema = 'public' "
" AND table_name != 'migrations';")]
(db/with-atomic [conn db/pool]
(db/with-atomic [conn *pool*]
(let [result (->> (db/exec! conn [sql])
(map :table-name))]
(db/exec! conn [(str "TRUNCATE "
@ -77,14 +73,12 @@
(try
(next)
(finally
(ust/clear! app.media-storage/media-storage)
(ust/clear! app.media-storage/assets-storage))))
(ust/clear! (:app.media-storage/storage *system*)))))
(defn mk-uuid
[prefix & args]
(uuid/namespaced uuid/zero (apply str prefix args)))
;; --- Profile creation
(defn create-profile
[conn i]
@ -157,12 +151,27 @@
{:error (handle-error e#)
:result nil})))
(defn mutation!
[{:keys [::type] :as data}]
(let [method-fn (get-in *system* [:app.rpc/rpc :methods :mutation type])]
(try-on!
(method-fn (dissoc data ::type)))))
(defn query!
[{:keys [::type] :as data}]
(let [method-fn (get-in *system* [:app.rpc/rpc :methods :query type])]
(try-on!
(method-fn (dissoc data ::type)))))
;; --- Utils
(defn print-error!
[error]
(let [data (ex-data error)]
(cond
(= :spec-validation (:code data))
(println (:explain data))
(expound/printer (:data data))
(= :service-error (:type data))
(print-error! (.getCause ^Throwable error))

View file

@ -7,7 +7,7 @@
;;
;; Copyright (c) 2020 UXBOX Labs SL
(ns app.tests.test_common_geom
(ns app.tests.test-common-geom
(:require
[clojure.test :as t]
[app.common.geom.point :as gpt]

View file

@ -15,11 +15,12 @@
[app.common.pages :refer [make-minimal-shape]]
[clojure.test :as t]))
(def default-path [{:command :move-to :params {:x 0 :y 0}}
{:command :line-to :params {:x 20 :y 20}}
{:command :line-to :params {:x 30 :y 30}}
{:command :curve-to :params {:x 40 :y 40 :c1x 35 :c1y 35 :c2x 45 :c2y 45}}
{:command :close-path}])
(def default-path
[{:command :move-to :params {:x 0 :y 0}}
{:command :line-to :params {:x 20 :y 20}}
{:command :line-to :params {:x 30 :y 30}}
{:command :curve-to :params {:x 40 :y 40 :c1x 35 :c1y 35 :c2x 45 :c2y 45}}
{:command :close-path}])
(defn add-path-data [shape]
(let [content (:content shape default-path)
@ -55,7 +56,6 @@
(= shape-before shape-after))
:rect :path))
(t/testing "Transform shape with translation modifiers"
(t/are [type]
@ -139,7 +139,7 @@
(get-in shape-after [:selrect :height])))
(t/is (> (get-in shape-after [:selrect :height]) 0)))
:rect :path))
(t/testing "Transform shape with rotation modifiers"
(t/are [type]
(let [modifiers {:rotation 30}

View file

@ -27,21 +27,3 @@
(t/is (contains? result :to))
#_(t/is (contains? result :reply-to))
(t/is (vector? (:body result)))))
;; (t/deftest email-sending-and-sendmail-job
;; (let [res @(emails/send! emails/register {:to "example@app.io" :name "foo"})]
;; (t/is (nil? res)))
;; (with-mock mock
;; {:target 'app.jobs.sendmail/impl-sendmail
;; :return (p/resolved nil)}
;; (let [res @(app.jobs.sendmail/send-emails {})]
;; (t/is (= 1 res))
;; (t/is (:called? @mock))
;; (t/is (= 1 (:call-count @mock))))
;; (let [res @(app.jobs.sendmail/send-emails {})]
;; (t/is (= 0 res))
;; (t/is (:called? @mock))
;; (t/is (= 1 (:call-count @mock))))))

View file

@ -14,8 +14,6 @@
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]
[app.services.mutations :as sm]
[app.services.queries :as sq]
[app.tests.helpers :as th]
[app.util.storage :as ust]))
@ -23,20 +21,20 @@
(t/use-fixtures :each th/database-reset)
(t/deftest files-crud
(let [prof (th/create-profile db/pool 1)
(let [prof (th/create-profile th/*pool* 1)
team-id (:default-team-id prof)
proj-id (:default-project-id prof)
file-id (uuid/next)
page-id (uuid/next)]
(t/testing "create file"
(let [data {::sm/type :create-file
(let [data {::th/type :create-file
:profile-id (:id prof)
:project-id proj-id
:id file-id
:is-shared false
:name "test file"}
out (th/try-on! (sm/handle data))]
:name "foobar"
:is-shared false}
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -46,11 +44,11 @@
(t/is (= proj-id (:project-id result))))))
(t/testing "rename file"
(let [data {::sm/type :rename-file
(let [data {::th/type :rename-file
:id file-id
:name "new name"
:profile-id (:id prof)}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(let [result (:result out)]
@ -58,10 +56,10 @@
(t/is (= (:name data) (:name result))))))
(t/testing "query files"
(let [data {::sq/type :files
(let [data {::th/type :files
:project-id proj-id
:profile-id (:id prof)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -73,10 +71,10 @@
(t/is (= 1 (count (get-in result [0 :data :pages])))))))
(t/testing "query single file without users"
(let [data {::sq/type :file
(let [data {::th/type :file
:profile-id (:id prof)
:id file-id}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -88,38 +86,32 @@
(t/is (nil? (:users result))))))
(t/testing "delete file"
(let [data {::sm/type :delete-file
(let [data {::th/type :delete-file
:id file-id
:profile-id (:id prof)}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (nil? (:result out)))))
(t/testing "query single file after delete"
(let [data {::sq/type :file
(let [data {::th/type :file
:profile-id (:id prof)
:id file-id}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(let [error (:error out)
error-data (ex-data error)]
(t/is (th/ex-info? error))
(t/is (= (:type error-data) :service-error))
(t/is (= (:name error-data) :app.services.queries.files/file)))
(let [error (ex-cause (:error out))
(let [error (:error out)
error-data (ex-data error)]
(t/is (th/ex-info? error))
(t/is (= (:type error-data) :not-found)))))
(t/testing "query list files after delete"
(let [data {::sq/type :files
(let [data {::th/type :files
:project-id proj-id
:profile-id (:id prof)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))

View file

@ -13,8 +13,6 @@
[datoteka.core :as fs]
[app.common.uuid :as uuid]
[app.db :as db]
[app.services.mutations :as sm]
[app.services.queries :as sq]
[app.tests.helpers :as th]
[app.util.storage :as ust]))
@ -22,22 +20,22 @@
(t/use-fixtures :each th/database-reset)
(t/deftest media-crud
(let [prof (th/create-profile db/pool 1)
(let [prof (th/create-profile th/*pool* 1)
team-id (:default-team-id prof)
proj (th/create-project db/pool (:id prof) team-id 1)
file (th/create-file db/pool (:id prof) (:id proj) false 1)
proj (th/create-project th/*pool* (:id prof) team-id 1)
file (th/create-file th/*pool* (:id prof) (:id proj) false 1)
object-id-1 (uuid/next)
object-id-2 (uuid/next)]
(t/testing "create media object from url to file"
(let [url "https://raw.githubusercontent.com/uxbox/uxbox/develop/sample_media/images/unsplash/anna-pelzer.jpg"
data {::sm/type :add-media-object-from-url
data {::th/type :add-media-object-from-url
:id object-id-1
:profile-id (:id prof)
:file-id (:id file)
:is-local true
:url url}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -57,14 +55,14 @@
:tempfile (th/tempfile "app/tests/_files/sample.jpg")
:content-type "image/jpeg"
:size 312043}
data {::sm/type :upload-media-object
data {::th/type :upload-media-object
:id object-id-2
:profile-id (:id prof)
:file-id (:id file)
:is-local true
:name "testfile"
:content content}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -78,71 +76,4 @@
(t/is (string? (get-in out [:result :path])))
(t/is (string? (get-in out [:result :thumb-path])))))
#_(t/testing "list media objects by file"
(let [data {::sq/type :media-objects
:profile-id (:id prof)
:file-id (:id file)
:is-local true}
out (th/try-on! (sq/handle data))]
(th/print-result! out)
;; Result is ordered by creation date descendent
(t/is (= object-id-2 (get-in out [:result 0 :id])))
(t/is (= "testfile" (get-in out [:result 0 :name])))
(t/is (= "image/jpeg" (get-in out [:result 0 :mtype])))
(t/is (= 800 (get-in out [:result 0 :width])))
(t/is (= 800 (get-in out [:result 0 :height])))
(t/is (string? (get-in out [:result 0 :path])))
(t/is (string? (get-in out [:result 0 :thumb-path])))))
#_(t/testing "single media object"
(let [data {::sq/type :media-object
:profile-id (:id prof)
:id object-id-2}
out (th/try-on! (sq/handle data))]
;; (th/print-result! out)
(t/is (= object-id-2 (get-in out [:result :id])))
(t/is (= "testfile" (get-in out [:result :name])))
(t/is (= "image/jpeg" (get-in out [:result :mtype])))
(t/is (= 800 (get-in out [:result :width])))
(t/is (= 800 (get-in out [:result :height])))
(t/is (string? (get-in out [:result :path])))))
#_(t/testing "delete media objects"
(let [data {::sm/type :delete-media-object
:profile-id (:id prof)
:id object-id-1}
out (th/try-on! (sm/handle data))]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (nil? (:result out)))))
#_(t/testing "query media object after delete"
(let [data {::sq/type :media-object
:profile-id (:id prof)
:id object-id-1}
out (th/try-on! (sq/handle data))]
;; (th/print-result! out)
(let [error (:error out)]
(t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :service-error)))
(let [error (ex-cause (:error out))]
(t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :not-found)))))
#_(t/testing "query media objects after delete"
(let [data {::sq/type :media-objects
:profile-id (:id prof)
:file-id (:id file)
:is-local true}
out (th/try-on! (sq/handle data))]
;; (th/print-result! out)
(let [result (:result out)]
(t/is (= 1 (count result))))))
))

View file

@ -15,50 +15,44 @@
[cuerdas.core :as str]
[datoteka.core :as fs]
[app.db :as db]
[app.services.mutations :as sm]
[app.services.queries :as sq]
[app.services.mutations.profile :as profile]
;; [app.services.mutations.profile :as profile]
[app.tests.helpers :as th]))
(t/use-fixtures :once th/state-init)
(t/use-fixtures :each th/database-reset)
(t/deftest profile-login
(let [profile (th/create-profile db/pool 1)]
(let [profile (th/create-profile th/*pool* 1)]
(t/testing "failed"
(let [event {::sm/type :login
(let [data {::th/type :login
:email "profile1.test@nodomain.com"
:password "foobar"
:scope "foobar"}
out (th/try-on! (sm/handle event))]
out (th/mutation! data)]
;; (th/print-result! out)
#_(th/print-result! out)
(let [error (:error out)]
(t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :service-error)))
(let [error (ex-cause (:error out))]
(t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :validation))
(t/is (th/ex-of-code? error :wrong-credentials)))))
(t/testing "success"
(let [event {::sm/type :login
(let [data {::th/type :login
:email "profile1.test@nodomain.com"
:password "123123"
:scope "foobar"}
out (th/try-on! (sm/handle event))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (= (:id profile) (get-in out [:result :id])))))))
(t/deftest profile-query-and-manipulation
(let [profile (th/create-profile db/pool 1)]
(let [profile (th/create-profile th/*pool* 1)]
(t/testing "query profile"
(let [data {::sq/type :profile
(let [data {::th/type :profile
:profile-id (:id profile)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -70,20 +64,21 @@
(t/testing "update profile"
(let [data (assoc profile
::sm/type :update-profile
:profile-id (:id profile)
::th/type :update-profile
:fullname "Full Name"
:lang "en"
:theme "dark")
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (nil? (:result out)))))
(t/testing "query profile after update"
(let [data {::sq/type :profile
(let [data {::th/type :profile
:profile-id (:id profile)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -94,25 +89,25 @@
(t/is (= "dark" (:theme result))))))
(t/testing "update photo"
(let [data {::sm/type :update-profile-photo
(let [data {::th/type :update-profile-photo
:profile-id (:id profile)
:file {:filename "sample.jpg"
:size 123123
:tempfile "tests/app/tests/_files/sample.jpg"
:content-type "image/jpeg"}}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
))))
(t/is (nil? (:error out)))))
))
#_(t/deftest profile-deletion
(let [prof (th/create-profile db/pool 1)
(let [prof (th/create-profile th/*pool* 1)
team (:default-team prof)
proj (:default-project prof)
file (th/create-file db/pool (:id prof) (:id proj) 1)
page (th/create-page db/pool (:id prof) (:id file) 1)]
file (th/create-file th/*pool* (:id prof) (:id proj) 1)
page (th/create-page th/*pool* (:id prof) (:id file) 1)]
;; (t/testing "try to delete profile not marked for deletion"
;; (let [params {:props {:profile-id (:id prof)}}
@ -198,14 +193,14 @@
))
(t/deftest registration-domain-whitelist
(let [whitelist "gmail.com, hey.com, ya.ru"]
(t/testing "allowed email domain"
(t/is (true? (profile/email-domain-in-whitelist? whitelist "username@ya.ru")))
(t/is (true? (profile/email-domain-in-whitelist? "" "username@somedomain.com"))))
;; (t/deftest registration-domain-whitelist
;; (let [whitelist "gmail.com, hey.com, ya.ru"]
;; (t/testing "allowed email domain"
;; (t/is (true? (profile/email-domain-in-whitelist? whitelist "username@ya.ru")))
;; (t/is (true? (profile/email-domain-in-whitelist? "" "username@somedomain.com"))))
(t/testing "not allowed email domain"
(t/is (false? (profile/email-domain-in-whitelist? whitelist "username@somedomain.com"))))))
;; (t/testing "not allowed email domain"
;; (t/is (false? (profile/email-domain-in-whitelist? whitelist "username@somedomain.com"))))))
;; TODO: profile deletion with teams
;; TODO: profile deletion with owner teams

View file

@ -13,8 +13,6 @@
[promesa.core :as p]
[app.db :as db]
[app.http :as http]
[app.services.mutations :as sm]
[app.services.queries :as sq]
[app.tests.helpers :as th]
[app.common.uuid :as uuid]))
@ -22,17 +20,17 @@
(t/use-fixtures :each th/database-reset)
(t/deftest projects-crud
(let [prof (th/create-profile db/pool 1)
team (th/create-team db/pool (:id prof) 1)
(let [prof (th/create-profile th/*pool* 1)
team (th/create-team th/*pool* (:id prof) 1)
project-id (uuid/next)]
(t/testing "create a project"
(let [data {::sm/type :create-project
(let [data {::th/type :create-project
:id project-id
:profile-id (:id prof)
:team-id (:id team)
:name "test project"}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -40,10 +38,10 @@
(t/is (= (:name data) (:name result))))))
(t/testing "query a list of projects"
(let [data {::sq/type :projects
(let [data {::th/type :projects
:team-id (:id team)
:profile-id (:id prof)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -53,11 +51,11 @@
(t/is "test project" (get-in result [0 :name])))))
(t/testing "rename project"
(let [data {::sm/type :rename-project
(let [data {::th/type :rename-project
:id project-id
:name "renamed project"
:profile-id (:id prof)}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(let [result (:result out)]
@ -66,20 +64,20 @@
(t/is (= (:profile-id data) (:id prof))))))
(t/testing "delete project"
(let [data {::sm/type :delete-project
(let [data {::th/type :delete-project
:id project-id
:profile-id (:id prof)}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (nil? (:result out)))))
(t/testing "query a list of projects after delete"
(let [data {::sq/type :projects
(let [data {::th/type :projects
:team-id (:id team)
:profile-id (:id prof)}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))

View file

@ -13,9 +13,6 @@
[datoteka.core :as fs]
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]
[app.services.mutations :as sm]
[app.services.queries :as sq]
[app.tests.helpers :as th]
[app.util.storage :as ust]))
@ -23,21 +20,21 @@
(t/use-fixtures :each th/database-reset)
(t/deftest retrieve-bundle
(let [prof (th/create-profile db/pool 1)
prof2 (th/create-profile db/pool 2)
(let [prof (th/create-profile th/*pool* 1)
prof2 (th/create-profile th/*pool* 2)
team-id (:default-team-id prof)
proj-id (:default-project-id prof)
file (th/create-file db/pool (:id prof) proj-id false 1)
file (th/create-file th/*pool* (:id prof) proj-id false 1)
token (atom nil)]
(t/testing "authenticated with page-id"
(let [data {::sq/type :viewer-bundle
(let [data {::th/type :viewer-bundle
:profile-id (:id prof)
:file-id (:id file)
:page-id (get-in file [:data :pages 0])}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -49,11 +46,11 @@
(t/is (contains? result :project)))))
(t/testing "generate share token"
(let [data {::sm/type :create-file-share-token
(let [data {::th/type :create-file-share-token
:profile-id (:id prof)
:file-id (:id file)
:page-id (get-in file [:data :pages 0])}
out (th/try-on! (sm/handle data))]
out (th/mutation! data)]
;; (th/print-result! out)
(t/is (nil? (:error out)))
@ -62,51 +59,45 @@
(reset! token (:token result)))))
(t/testing "not authenticated with page-id"
(let [data {::sq/type :viewer-bundle
(let [data {::th/type :viewer-bundle
:profile-id (:id prof2)
:file-id (:id file)
:page-id (get-in file [:data :pages 0])}
out (th/try-on! (sq/handle data))]
out (th/query! data)]
;; (th/print-result! out)
(let [error (:error out)
error-data (ex-data error)]
(t/is (th/ex-info? error))
(t/is (= (:type error-data) :service-error))
(t/is (= (:name error-data) :app.services.queries.viewer/viewer-bundle)))
(let [error (ex-cause (:error out))
error-data (ex-data error)]
(t/is (th/ex-info? error))
(t/is (= (:type error-data) :validation))
(t/is (= (:code error-data) :not-authorized)))))
(t/testing "authenticated with token & profile"
(let [data {::sq/type :viewer-bundle
:profile-id (:id prof2)
:token @token
:file-id (:id file)
:page-id (get-in file [:data :pages 0])}
out (th/try-on! (sq/handle data))]
;; (t/testing "authenticated with token & profile"
;; (let [data {::sq/type :viewer-bundle
;; :profile-id (:id prof2)
;; :token @token
;; :file-id (:id file)
;; :page-id (get-in file [:data :pages 0])}
;; out (th/try-on! (sq/handle data))]
;; (th/print-result! out)
;; ;; (th/print-result! out)
(let [result (:result out)]
(t/is (contains? result :page))
(t/is (contains? result :file))
(t/is (contains? result :project)))))
;; (let [result (:result out)]
;; (t/is (contains? result :page))
;; (t/is (contains? result :file))
;; (t/is (contains? result :project)))))
(t/testing "authenticated with token"
(let [data {::sq/type :viewer-bundle
:token @token
:file-id (:id file)
:page-id (get-in file [:data :pages 0])}
out (th/try-on! (sq/handle data))]
;; (t/testing "authenticated with token"
;; (let [data {::sq/type :viewer-bundle
;; :token @token
;; :file-id (:id file)
;; :page-id (get-in file [:data :pages 0])}
;; out (th/try-on! (sq/handle data))]
;; (th/print-result! out)
;; ;; (th/print-result! out)
(let [result (:result out)]
(t/is (contains? result :page))
(t/is (contains? result :file))
(t/is (contains? result :project)))))
;; (let [result (:result out)]
;; (t/is (contains? result :page))
;; (t/is (contains? result :file))
;; (t/is (contains? result :project)))))
))