THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

🐛 Fix frontend tests

pull/850/head
Andrés Moya 3 weeks ago
committed by Andrey Antukh
parent
commit
dd6bd6bbff
  1. 2
      common/app/common/pages/spec.cljc
  2. 2
      frontend/src/app/main/data/workspace/common.cljs
  3. 28
      frontend/src/app/util/globals.js
  4. 3
      frontend/src/app/util/http.cljs
  5. 5
      frontend/src/app/util/i18n.cljs

2
common/app/common/pages/spec.cljc

@ -16,7 +16,7 @@
(s/def ::frame-id uuid?)
(s/def ::id uuid?)
(s/def ::name string?)
(s/def ::path string?)
(s/def ::path (s/nilable string?))
(s/def ::page-id uuid?)
(s/def ::parent-id uuid?)
(s/def ::string string?)

2
frontend/src/app/main/data/workspace/common.cljs

@ -72,7 +72,7 @@
commit-local? false}
:as opts}]
(us/verify ::cp/changes changes)
;; (us/verify ::cp/changes undo-changes)
(us/verify ::cp/changes undo-changes)
(log/debug :msg "commit-changes"
:js/changes changes
:js/undo-changes undo-changes)

28
frontend/src/app/util/globals.js

@ -20,11 +20,23 @@ goog.provide("app.util.globals");
goog.scope(function() {
app.util.globals.global = goog.global;
function createGlobalEventEmiter(k) {
/* Allow mocked objects to be event emitters, so other modules
* may subscribe to them.
*/
return {
addListener(...args) {
},
removeListener(...args) {
}
}
}
app.util.globals.window = (function() {
if (typeof goog.global.window !== "undefined") {
return goog.global.window;
} else {
return {};
return createGlobalEventEmiter();
}
})();
@ -32,7 +44,7 @@ goog.scope(function() {
if (typeof goog.global.document !== "undefined") {
return goog.global.document;
} else {
return {};
return createGlobalEventEmiter();
}
})();
@ -40,7 +52,7 @@ goog.scope(function() {
if (typeof goog.global.location !== "undefined") {
return goog.global.location;
} else {
return {};
return createGlobalEventEmiter();
}
})();
@ -48,7 +60,15 @@ goog.scope(function() {
if (typeof goog.global.navigator !== "undefined") {
return goog.global.navigator;
} else {
return {};
return createGlobalEventEmiter();
}
})();
app.util.globals.FormData = (function() {
if (typeof goog.global.FormData !== "undefined") {
return goog.global.FormData;
} else {
return function() {};
}
})();
});

3
frontend/src/app/util/http.cljs

@ -9,6 +9,7 @@
(:require
[app.common.data :as d]
[app.config :as cfg]
[app.util.globals :as globals]
[app.util.object :as obj]
[app.util.transit :as t]
[beicon.core :as rx]
@ -22,7 +23,7 @@
(-get-body-data [_]))
(extend-protocol IBodyData
js/FormData
globals/FormData
(-get-body-data [it] it)
(-update-headers [it headers]
(dissoc headers "content-type" "Content-Type"))

5
frontend/src/app/util/i18n.cljs

@ -8,6 +8,7 @@
"A i18n foundation."
(:require
[app.config :as cfg]
[app.util.globals :as globals]
[app.util.storage :refer [storage]]
[app.util.transit :as t]
[beicon.core :as rx]
@ -28,7 +29,7 @@
(defn- parse-locale
[locale]
(let [locale (-> (.-language js/navigator)
(let [locale (-> (.-language globals/navigator)
(str/lower)
(str/replace "-" "_"))]
(cond-> [locale]
@ -37,7 +38,7 @@
(def ^:private browser-locales
(delay
(-> (.-language js/navigator)
(-> (.-language globals/navigator)
(parse-locale))))
(defn- autodetect

Loading…
Cancel
Save