(ns ird.p2p.db.browser.runner
"Entry point of the browser test build (shadow-cljs :browser-test): runs
the browser test namespaces with cljs.test and leaves the summary on
`window.__ird_test` for the Node harness to read. The page loads the
vendor chunk before this build (it installs Buffer, which the byte
helpers use as their namespaces load); `init` checks the import helper
resolves before running anything."
(:require [cljs.test :as t]
[ird.p2p.db.browser.harness :as h]
[ird.p2p.db.browser.replication-test]))
(def ^:private print-summary (get-method t/report [::t/default :summary]))
(defmethod t/report [::t/default :summary] [m]
(print-summary m)
(set! (.-__ird_test js/window) (clj->js (select-keys m [:test :pass :fail :error]))))
(defn init []
(h/configure!)
(-> (js/ird_dyn_import "helia")
(.then (fn [_] (t/run-tests 'ird.p2p.db.browser.replication-test)))
(.catch (fn [e]
(js/console.error "the vendor chunk failed to load:" e)
(set! (.-__ird_test js/window) #js {:test 0 :pass 0 :fail 0 :error 1})))))