From da0d892fb02a9f0dd6a311bb358d3c564b391b07 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 29 Oct 2024 13:55:50 +0100 Subject: [PATCH 01/13] wip --- src/nextjournal/clerk/builder.clj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index 5ecb15ec9..2b298b4c6 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -176,6 +176,10 @@ "--input-type=module" "--trace-warnings")) {:keys [out err exit]} result] + (println "SSR output") + (println "---") + (println result) + (println "---") (if (= 0 exit) (do (report-fn {:stage :done :duration duration}) From ab3c0697ff2bbb7d6418b5570f397bd39931916c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 29 Oct 2024 14:08:57 +0100 Subject: [PATCH 02/13] opts --- src/nextjournal/clerk/builder.clj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index 2b298b4c6..07421250e 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -176,6 +176,10 @@ "--input-type=module" "--trace-warnings")) {:keys [out err exit]} result] + (println "Static app Opts") + (println "---") + (prn static-app-opts) + (println "---") (println "SSR output") (println "---") (println result) From bee9ad855b5d8644d03f92c8b593c71e71f460be Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 29 Oct 2024 15:40:17 +0100 Subject: [PATCH 03/13] debug edn --- src/nextjournal/clerk/render.cljs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nextjournal/clerk/render.cljs b/src/nextjournal/clerk/render.cljs index 831176c0d..b6b666d5b 100644 --- a/src/nextjournal/clerk/render.cljs +++ b/src/nextjournal/clerk/render.cljs @@ -847,7 +847,12 @@ :status (.-status r) :headers (.-headers r)}))))) (then read-response+show-progress) - (then (fn [edn] (set-state! {:doc (read-string edn)}) {:ok true})) + (then (fn [edn] + (binding [*print-fn* *print-err-fn*] + (println "EDN!!!!") + (println edn) + (println "---")) + (set-state! {:doc (read-string edn)}) {:ok true})) (catch (fn [e] (js/console.error "Fetch failed" e) (set-state! {:doc {:nextjournal/viewer {:render-fn (constantly [:<>])} ;; FIXME: make :error top level on state :nextjournal/value {:error (viewer/present e)}}}) From 7fbd710b32b7ca28326417956eee1261b06c431a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 29 Oct 2024 19:54:16 +0100 Subject: [PATCH 04/13] wip --- shadow-cljs.edn | 2 +- src/nextjournal/clerk/sci_env.cljs | 2 +- ui_tests/ssr.cljs | 13 +++++++------ ui_tests/ssr.mjs | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 ui_tests/ssr.mjs diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 01ac70f3d..82a24a817 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -2,7 +2,7 @@ :dev-http {7778 {:roots ["public" "classpath:public"]}} :nrepl false :builds {:viewer {:target :esm - :runtime :browser ;; `:custom` needed when developing ssr, will see WebSocket errors without it + :runtime :custom #_:browser ;; `:custom` needed when developing ssr, will see WebSocket errors without it :output-dir "public/js" :release {:output-dir "build/"} :compiler-options {:source-map true} diff --git a/src/nextjournal/clerk/sci_env.cljs b/src/nextjournal/clerk/sci_env.cljs index 4c8f4ac81..93f8fa778 100644 --- a/src/nextjournal/clerk/sci_env.cljs +++ b/src/nextjournal/clerk/sci_env.cljs @@ -177,7 +177,7 @@ 'clojure.repl {'pst pst-stub}} (sci-copy-nss 'cljs.math - 'cljs.repl + #_'cljs.repl 'nextjournal.clerk.parser 'nextjournal.clerk.render 'nextjournal.clerk.render.code diff --git a/ui_tests/ssr.cljs b/ui_tests/ssr.cljs index 7651ba0d3..23fb2ce1c 100644 --- a/ui_tests/ssr.cljs +++ b/ui_tests/ssr.cljs @@ -3,12 +3,13 @@ Use this to iterate on it, then make sure the advanced bundle works in Graal via `nextjournal.clerk.ssr`." - (:require ["./../public/js/viewer.js" :as viewer] - ;; the above is the dev build, the one below the relase (generate it via `bb release:js`) - #_["./../build/viewer.js" :as viewer] - [babashka.cli :as cli] - [promesa.core :as p] - [nbb.core :refer [slurp]])) + (:require + ["./../public/js/viewer.js?q=3" :as viewer] + ;; the above is the dev build, the one below the relase (generate it via `bb release:js`) + #_["./../build/viewer.js" :as viewer] + [babashka.cli :as cli] + [promesa.core :as p] + [nbb.core :refer [slurp]])) (defn -main [& args] (p/let [{:keys [file edn url]} (:opts (cli/parse-args args {:alias {:u :url :f :file}})) diff --git a/ui_tests/ssr.mjs b/ui_tests/ssr.mjs new file mode 100644 index 000000000..9a4fddf8a --- /dev/null +++ b/ui_tests/ssr.mjs @@ -0,0 +1 @@ +import "./../public/js/viewer.js"; From dd97da2d74c1912a1d551502b9533eccb60b3061 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 15:54:51 +0100 Subject: [PATCH 05/13] ci --- src/nextjournal/clerk/builder.clj | 20 ++++++++++---------- src/nextjournal/clerk/render.cljs | 2 +- src/nextjournal/clerk/render/hooks.cljs | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index 07421250e..1252f4d75 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -167,7 +167,11 @@ "Shells out to node to generate server-side-rendered html." [{:as static-app-opts :keys [report-fn resource->url]}] (report-fn {:stage :ssr}) - (let [{duration :time-ms :keys [result]} + (let [doc (get (:path->doc static-app-opts) (:current-path static-app-opts)) + static-app-opts (-> (assoc static-app-opts :doc doc) + (dissoc :path->doc) + (assoc :render-router :serve)) + {duration :time-ms :keys [result]} (eval/time-ms (sh {:in (str "import '" (resource->url "/js/viewer.js") "';" "console.log(nextjournal.clerk.sci_env.ssr(" (pr-str (pr-str static-app-opts)) "))")} "node" @@ -176,14 +180,8 @@ "--input-type=module" "--trace-warnings")) {:keys [out err exit]} result] - (println "Static app Opts") - (println "---") - (prn static-app-opts) - (println "---") - (println "SSR output") - (println "---") - (println result) - (println "---") + #_(def s static-app-opts) + #_(prn static-app-opts) (if (= 0 exit) (do (report-fn {:stage :done :duration duration}) @@ -210,10 +208,11 @@ (fs/create-dirs (fs/parent out-html)) (spit (fs/file out-path (str (or (not-empty path) "index") ".edn")) (viewer/->edn doc)) + (prn :p path) (spit out-html (view/->html (-> static-app-opts - (dissoc :path->doc) (assoc :current-path path) (cond-> ssr? ssr!) + (dissoc :path->doc) cleanup)))))) (when browse? (browse/browse-url (if-let [server-url (and (= out-path "public/build") (webserver/server-url))] @@ -363,6 +362,7 @@ ;; test against cljs release `bb build:js` :resource->url {"/js/viewer.js" "./build/viewer.js"} :index "notebooks/rule_30.clj"}) + (spit "/tmp/foo.edn" s) (build-static-app! {:ssr? true :compile-css? true diff --git a/src/nextjournal/clerk/render.cljs b/src/nextjournal/clerk/render.cljs index b6b666d5b..1ba86ee3d 100644 --- a/src/nextjournal/clerk/render.cljs +++ b/src/nextjournal/clerk/render.cljs @@ -711,7 +711,7 @@ (defn ^:export set-state! [{:as state :keys [doc effects]}] (run-effects! effects) - (when (contains? state :doc) + (when doc (when (exists? js/window) ;; TODO: can we restore the scroll position when navigating back? (.scrollTo js/window #js {:top 0})) diff --git a/src/nextjournal/clerk/render/hooks.cljs b/src/nextjournal/clerk/render/hooks.cljs index 0a7844c9a..7982f21b3 100644 --- a/src/nextjournal/clerk/render/hooks.cljs +++ b/src/nextjournal/clerk/render/hooks.cljs @@ -58,6 +58,8 @@ (WrappedState. (react/useState init))) (defn- specify-atom! [ref-obj] + #_(js/console.log "ref" ref-obj (js/Object.isFrozen ref-obj)) + #_(prn :ref ref-obj) (specify! ref-obj IDeref (-deref [^js this] (.-current this)) @@ -72,6 +74,8 @@ ([o f a b] (reset! o (f o a b))) ([o f a b xs] (reset! o (apply f o a b xs)))))) +#_(prn :specify (specify-atom! (doto #js {} (js/Object.freeze)))) + (defn use-ref "React hook: useRef. Can also be used like an atom." ([] (use-ref nil)) From 2bd2468f788408ab0eef9e5748d4808a8bebb2f8 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 16:46:20 +0100 Subject: [PATCH 06/13] React dev workaround --- src/nextjournal/clerk/builder.clj | 30 +++++++++++++++++-------- src/nextjournal/clerk/render/hooks.cljs | 8 +++---- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index 1252f4d75..f9cd1d661 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -163,6 +163,25 @@ :path->doc path->doc :paths (vec (keys path->doc))))) +(defn- node-ssr! + [{:keys [viewer-js state] + :or {viewer-js + ;; for local REPL testing + "./public/js/viewer.js"}}] + (sh {:in (str "import '" viewer-js "';" + "globalThis.CLERK_SSR = true;" + "console.log(nextjournal.clerk.sci_env.ssr(" (pr-str (pr-str state)) "))")} + "node" + "--abort-on-uncaught-exception" + "--experimental-network-imports" + "--input-type=module" + "--trace-warnings")) + +(comment + (declare so) ;; captured in REPL in ssr! function + (node-ssr! {:state so}) + ) + (defn ssr! "Shells out to node to generate server-side-rendered html." [{:as static-app-opts :keys [report-fn resource->url]}] @@ -172,16 +191,9 @@ (dissoc :path->doc) (assoc :render-router :serve)) {duration :time-ms :keys [result]} - (eval/time-ms (sh {:in (str "import '" (resource->url "/js/viewer.js") "';" - "console.log(nextjournal.clerk.sci_env.ssr(" (pr-str (pr-str static-app-opts)) "))")} - "node" - "--abort-on-uncaught-exception" - "--experimental-network-imports" - "--input-type=module" - "--trace-warnings")) + (eval/time-ms (node-ssr! {:viewer-js (resource->url "/js/viewer.js") + :state static-app-opts})) {:keys [out err exit]} result] - #_(def s static-app-opts) - #_(prn static-app-opts) (if (= 0 exit) (do (report-fn {:stage :done :duration duration}) diff --git a/src/nextjournal/clerk/render/hooks.cljs b/src/nextjournal/clerk/render/hooks.cljs index 7982f21b3..83f6f203e 100644 --- a/src/nextjournal/clerk/render/hooks.cljs +++ b/src/nextjournal/clerk/render/hooks.cljs @@ -58,8 +58,6 @@ (WrappedState. (react/useState init))) (defn- specify-atom! [ref-obj] - #_(js/console.log "ref" ref-obj (js/Object.isFrozen ref-obj)) - #_(prn :ref ref-obj) (specify! ref-obj IDeref (-deref [^js this] (.-current this)) @@ -74,12 +72,12 @@ ([o f a b] (reset! o (f o a b))) ([o f a b xs] (reset! o (apply f o a b xs)))))) -#_(prn :specify (specify-atom! (doto #js {} (js/Object.freeze)))) - (defn use-ref "React hook: useRef. Can also be used like an atom." ([] (use-ref nil)) - ([init] (specify-atom! (react/useRef init)))) + ([init] (if js/CLERK_SSR + (atom init) + (specify-atom! (react/useRef init))))) (defn ^:private eval-fn "Invoke (f x) if f is a function, otherwise return f" From 31e340e8d40a1295e70c1c7fe093a2fcb95fadf5 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 17:31:30 +0100 Subject: [PATCH 07/13] clj-kondo --- src/nextjournal/clerk/builder.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index f9cd1d661..4f4f3c480 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -374,7 +374,6 @@ ;; test against cljs release `bb build:js` :resource->url {"/js/viewer.js" "./build/viewer.js"} :index "notebooks/rule_30.clj"}) - (spit "/tmp/foo.edn" s) (build-static-app! {:ssr? true :compile-css? true From 21e2729cc2ef6bfde42dc7cbc8f84c5c4b05c4e4 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 17:32:11 +0100 Subject: [PATCH 08/13] remove error logging --- src/nextjournal/clerk/render.cljs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/nextjournal/clerk/render.cljs b/src/nextjournal/clerk/render.cljs index 1ba86ee3d..9e4a3431c 100644 --- a/src/nextjournal/clerk/render.cljs +++ b/src/nextjournal/clerk/render.cljs @@ -848,10 +848,6 @@ :headers (.-headers r)}))))) (then read-response+show-progress) (then (fn [edn] - (binding [*print-fn* *print-err-fn*] - (println "EDN!!!!") - (println edn) - (println "---")) (set-state! {:doc (read-string edn)}) {:ok true})) (catch (fn [e] (js/console.error "Fetch failed" e) (set-state! {:doc {:nextjournal/viewer {:render-fn (constantly [:<>])} ;; FIXME: make :error top level on state From e2b165e0310fe91b0a90d42973d75034e012b6ed Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 17:39:44 +0100 Subject: [PATCH 09/13] reduce diff --- shadow-cljs.edn | 2 +- src/nextjournal/clerk/builder.clj | 1 - src/nextjournal/clerk/render.cljs | 2 +- src/nextjournal/clerk/sci_env.cljs | 3 ++- ui_tests/ssr.cljs | 13 ++++++------- ui_tests/ssr.mjs | 1 - 6 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 ui_tests/ssr.mjs diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 82a24a817..01ac70f3d 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -2,7 +2,7 @@ :dev-http {7778 {:roots ["public" "classpath:public"]}} :nrepl false :builds {:viewer {:target :esm - :runtime :custom #_:browser ;; `:custom` needed when developing ssr, will see WebSocket errors without it + :runtime :browser ;; `:custom` needed when developing ssr, will see WebSocket errors without it :output-dir "public/js" :release {:output-dir "build/"} :compiler-options {:source-map true} diff --git a/src/nextjournal/clerk/builder.clj b/src/nextjournal/clerk/builder.clj index 4f4f3c480..7b58de6a9 100644 --- a/src/nextjournal/clerk/builder.clj +++ b/src/nextjournal/clerk/builder.clj @@ -220,7 +220,6 @@ (fs/create-dirs (fs/parent out-html)) (spit (fs/file out-path (str (or (not-empty path) "index") ".edn")) (viewer/->edn doc)) - (prn :p path) (spit out-html (view/->html (-> static-app-opts (assoc :current-path path) (cond-> ssr? ssr!) diff --git a/src/nextjournal/clerk/render.cljs b/src/nextjournal/clerk/render.cljs index 9e4a3431c..59a60ae51 100644 --- a/src/nextjournal/clerk/render.cljs +++ b/src/nextjournal/clerk/render.cljs @@ -711,7 +711,7 @@ (defn ^:export set-state! [{:as state :keys [doc effects]}] (run-effects! effects) - (when doc + (when (contains? state :doc) (when (exists? js/window) ;; TODO: can we restore the scroll position when navigating back? (.scrollTo js/window #js {:top 0})) diff --git a/src/nextjournal/clerk/sci_env.cljs b/src/nextjournal/clerk/sci_env.cljs index 93f8fa778..dbe7b3855 100644 --- a/src/nextjournal/clerk/sci_env.cljs +++ b/src/nextjournal/clerk/sci_env.cljs @@ -15,6 +15,7 @@ [applied-science.js-interop :as j] [cljs.math] [cljs.reader] + [cljs.repl] [clojure.string :as str] [edamame.core :as edamame] [goog.object] @@ -177,7 +178,7 @@ 'clojure.repl {'pst pst-stub}} (sci-copy-nss 'cljs.math - #_'cljs.repl + 'cljs.repl 'nextjournal.clerk.parser 'nextjournal.clerk.render 'nextjournal.clerk.render.code diff --git a/ui_tests/ssr.cljs b/ui_tests/ssr.cljs index 23fb2ce1c..7651ba0d3 100644 --- a/ui_tests/ssr.cljs +++ b/ui_tests/ssr.cljs @@ -3,13 +3,12 @@ Use this to iterate on it, then make sure the advanced bundle works in Graal via `nextjournal.clerk.ssr`." - (:require - ["./../public/js/viewer.js?q=3" :as viewer] - ;; the above is the dev build, the one below the relase (generate it via `bb release:js`) - #_["./../build/viewer.js" :as viewer] - [babashka.cli :as cli] - [promesa.core :as p] - [nbb.core :refer [slurp]])) + (:require ["./../public/js/viewer.js" :as viewer] + ;; the above is the dev build, the one below the relase (generate it via `bb release:js`) + #_["./../build/viewer.js" :as viewer] + [babashka.cli :as cli] + [promesa.core :as p] + [nbb.core :refer [slurp]])) (defn -main [& args] (p/let [{:keys [file edn url]} (:opts (cli/parse-args args {:alias {:u :url :f :file}})) diff --git a/ui_tests/ssr.mjs b/ui_tests/ssr.mjs deleted file mode 100644 index 9a4fddf8a..000000000 --- a/ui_tests/ssr.mjs +++ /dev/null @@ -1 +0,0 @@ -import "./../public/js/viewer.js"; From 728ae6ec82f1066400592325fe4f3cfb35006e1f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 17:49:25 +0100 Subject: [PATCH 10/13] fix build --- src/nextjournal/clerk/render/hooks.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nextjournal/clerk/render/hooks.cljs b/src/nextjournal/clerk/render/hooks.cljs index 83f6f203e..0d372f1fa 100644 --- a/src/nextjournal/clerk/render/hooks.cljs +++ b/src/nextjournal/clerk/render/hooks.cljs @@ -75,7 +75,7 @@ (defn use-ref "React hook: useRef. Can also be used like an atom." ([] (use-ref nil)) - ([init] (if js/CLERK_SSR + ([init] (if (unchecked-get js/globalThis "CLERK_SSR") (atom init) (specify-atom! (react/useRef init))))) From c7f16af6972943090b265bc114e5eae39d34b2b9 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 18:41:41 +0100 Subject: [PATCH 11/13] Fix UI test --- .github/workflows/main.yml | 1 + ui_tests/playwright_tests.cljs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e953a10e3..aceccc47a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -270,6 +270,7 @@ jobs: run: | bb test:static-app :sha ${{ github.sha }} :skip-install true bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk/book/${{ github.sha }}/book/index.html :index false :selector "span:has-text(\"Book of Clerk\")" + bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk-ssr/build/${{ github.sha }}/index.html :index false :selector "h1:has-text(\"Rule 30\")" deploy: needs: [build-and-upload-viewer-resources, test] diff --git a/ui_tests/playwright_tests.cljs b/ui_tests/playwright_tests.cljs index f08434343..5718b5db9 100644 --- a/ui_tests/playwright_tests.cljs +++ b/ui_tests/playwright_tests.cljs @@ -52,9 +52,11 @@ (p/do (goto page url) (.waitForLoadState page "networkidle") (p/let [selector (or (:selector @!opts) "div") + _ (prn :selector selector) loc (.locator page selector) - loc (.first loc #js {:timeout 10000})] - (is (.isVisible loc #js {:timeout 10000}))))) + loc (.first loc #js {:timeout 10000}) + visible? (.isVisible loc #js {:timeout 10000})] + (is visible?)))) ([page url link] (p/let [txt (.innerText link)] (println "Visiting" (str url "#/" txt)) From 29e34b4c816c5627376193a912abd4d75eb384b1 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 11 Nov 2024 19:08:33 +0100 Subject: [PATCH 12/13] fix test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aceccc47a..8e65c7d6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -269,7 +269,7 @@ jobs: - name: Run Playwright tests against static assets run: | bb test:static-app :sha ${{ github.sha }} :skip-install true - bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk/book/${{ github.sha }}/book/index.html :index false :selector "span:has-text(\"Book of Clerk\")" + bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk/book/${{ github.sha }}/book/index.html :index false :selector "h1:has-text(\"Book of Clerk\")" bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk-ssr/build/${{ github.sha }}/index.html :index false :selector "h1:has-text(\"Rule 30\")" deploy: From 536e1feed07849adfc1986af1d87f9fe48641549 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 12 Nov 2024 11:41:08 +0100 Subject: [PATCH 13/13] fix tests --- ui_tests/playwright_tests.cljs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui_tests/playwright_tests.cljs b/ui_tests/playwright_tests.cljs index 5718b5db9..03883fa93 100644 --- a/ui_tests/playwright_tests.cljs +++ b/ui_tests/playwright_tests.cljs @@ -53,9 +53,10 @@ (.waitForLoadState page "networkidle") (p/let [selector (or (:selector @!opts) "div") _ (prn :selector selector) - loc (.locator page selector) + loc (.locator page selector #js {:timeout 10000}) loc (.first loc #js {:timeout 10000}) - visible? (.isVisible loc #js {:timeout 10000})] + _ (.waitFor loc #js {:state "visible"}) + visible? (.isVisible loc)] (is visible?)))) ([page url link] (p/let [txt (.innerText link)] @@ -63,7 +64,8 @@ (p/do (.click link) (p/let [loc (.locator page "div") loc (.first loc #js {:timeout 10000}) - visible? (.isVisible loc #js {:timeout 10000})] + _ (.waitFor loc #js {:state "visible"}) + visible? (.isVisible loc)] (is visible?)))))) (deftest index-page-test