diff --git a/sx/sx/applications/htmx/runner.sx b/sx/sx/applications/htmx/runner.sx index e472b787..3c8c4809 100644 --- a/sx/sx/applications/htmx/runner.sx +++ b/sx/sx/applications/htmx/runner.sx @@ -24,15 +24,29 @@ "true")) true (do (hs-wait 200) (wait-boot)))))) - (reload-frame - (fn - () - (let - ((w (host-get (dom-query "#test-iframe") "contentWindow"))) - (host-call (host-get w "location") "reload") - (hs-wait 1000) - (wait-boot) - (hs-wait 500)))) + (begin + (reload-frame + (fn + () + (let + ((w (host-get (dom-query "#test-iframe") "contentWindow"))) + (host-call (host-get w "location") "reload") + (hs-wait 1000) + (wait-boot) + (hs-wait 500)))) + (wait-for-el + (fn + (sel max-tries) + (let + ((doc (get-doc)) + (el (when doc (host-call doc "querySelector" sel)))) + (if + el + el + (if + (<= max-tries 0) + nil + (do (hs-wait 200) (wait-for-el sel (- max-tries 1))))))))) (run-action (fn (action) @@ -106,7 +120,7 @@ (reset! results (assoc (deref results) name "running")) (reload-frame) (let - ((test-ok (cek-try (fn () (for-each run-action (get test :actions)) true) (fn (e) (do (reset! results (assoc (deref results) name "fail")) (console-log (str "FAIL " name ": " e)) false))))) + ((test-ok (cek-try (fn () (let ((actions (get test :actions))) (when (not (empty? actions)) (let ((first-sel (nth (first actions) 1))) (when (string? first-sel) (let ((found (wait-for-el first-sel 15))) (when (nil? found) (error (str "Timeout waiting for: " first-sel))))))) (for-each run-action actions)) true) (fn (e) (do (reset! results (assoc (deref results) name "fail")) (console-log (str "FAIL " name ": " e)) false))))) (when test-ok (reset! results (assoc (deref results) name "pass"))))))