🐛 Make history safer for tests

This commit is contained in:
alonso.torres 2026-06-10 12:20:54 +02:00
parent dc2e2c081e
commit ae2c2fa024
6 changed files with 14 additions and 10 deletions

View File

@ -88,7 +88,7 @@
(let [page (dsh/lookup-page state file-id page-id)
uris (into #{} xf:collect-file-media (:objects page))]
(rx/merge
(rx/of (ptk/data-event :page-initialized page-id))
(rx/of (ptk/data-event ::initialized page-id))
(->> (rx/from uris)
(rx/map #(http/fetch-data-uri % false))
(rx/ignore))

View File

@ -27,6 +27,7 @@
[app.main.data.workspace.colors :as dwc]
[app.main.data.workspace.groups :as dwg]
[app.main.data.workspace.media :as dwm]
[app.main.data.workspace.pages :as dwpg]
[app.main.data.workspace.selection :as dws]
[app.main.data.workspace.variants :as dwv]
[app.main.data.workspace.wasm-text :as dwwt]
@ -581,7 +582,7 @@
(js/Promise.
(fn [resolve _]
(->> st/stream
(rx/filter (ptk/type? :page-initialized))
(rx/filter (ptk/type? ::dwpg/initialized))
(rx/filter #(= (deref %) id))
(rx/take 1)
(rx/subs! #(resolve nil)))

View File

@ -19,6 +19,7 @@
[app.main.data.workspace :as dw]
[app.main.data.workspace.guides :as dwgu]
[app.main.data.workspace.interactions :as dwi]
[app.main.data.workspace.pages :as dwpg]
[app.main.repo :as rp]
[app.main.router :as-alias rt]
[app.main.store :as st]
@ -278,7 +279,7 @@
(js/Promise.
(fn [resolve _]
(->> st/stream
(rx/filter (ptk/type? :page-initialized))
(rx/filter (ptk/type? ::dwpg/initialized))
(rx/filter #(= (deref %) id))
(rx/take 1)
(rx/subs! #(resolve nil)))

View File

@ -40,7 +40,7 @@ goog.scope(function() {
};
self.set_token_BANG_ = function(instance, token) {
instance.setToken(token);
instance?.setToken(token);
}
self.replace_token_BANG_ = function(instance, token) {

View File

@ -842,10 +842,11 @@
([uri name]
(open-new-window uri name "noopener,noreferrer"))
([uri name features]
(when-let [new-window (.open js/window (str uri) name features)]
(when (not= name "_blank")
(when-let [location (.-location new-window)]
(.reload location))))))
(when (exists? js/window)
(when-let [new-window (.open js/window (str uri) name features)]
(when (not= name "_blank")
(when-let [location (.-location new-window)]
(.reload location)))))))
(defn browser-back
[]

View File

@ -7,6 +7,7 @@
(ns frontend-tests.plugins.page-test
(:require
[app.common.test-helpers.files :as cthf]
[app.main.data.workspace.pages :as dwpg]
[app.main.store :as st]
[app.plugins.api :as api]
[app.util.object :as obj]
@ -28,10 +29,10 @@
(defn- mock-page-initialized
"Simulates the two effects of initialize-page* without routing:
updates current-page-id in state, then emits the public :page-initialized event."
updates current-page-id in state, then emits the public ::dwpg/initialized event."
[store page-id]
(ptk/emit! store #(assoc % :current-page-id page-id))
(ptk/emit! store (ptk/data-event :page-initialized page-id)))
(ptk/emit! store (ptk/data-event ::dwpg/initialized page-id)))
(t/deftest test-open-page-returns-promise
(let [{:keys [context]} (setup)