Fork me on GitHub
#re-frame
<
2022-01-07
>
jherrlin09:01:24

Hey! re-frame-http-fx is using a lib called cljs-ajax. It got some updates and I would like try to update re-frame-http-fx to cljs-ajax version 0.8.4. I cant find instructions on how to run the tests. Anyone knows how to run the tests for re-frame-http-fx ?

p-himik10:01:59

According to profile.clj, If you're using karma then it should be as easy as lein ci. If you don't use it, you can run lein shadow compile browser-test. It will produce some files in run/resources/compiled_test and since the project doesn't use shadow-cljs' dev HTTP server, you will have to serve the contents of that directory yourself, e.g. by running python -m http.server in that directory. Then, if you open that served directory in your browser, you'll see the tests' results.

p-himik10:01:29

There might be an easier way to do this if you don't use karma, but I'm not that familiar with Lein to know them.

jherrlin15:01:42

@U2FRKM4TW thx! I got the tests to run. Installed a bunch of Karma stuff and then used lein ci. Now lets try to update cljs-ajax 🙂

👍 1
superstructor01:01:49

@UAEV0STAA Thanks for the PR. day8.re-frame/http-fx {:mvn/version "0.2.4"} is available with the update.

jherrlin07:01:19

@U0G75S29H my pleasure! Thank you for the awesome work you done! cljs-ajax supports qualified keywords. So now this is possible without the ns getting cut away.

(re-frame/dispatch
 [:http-get
  {:uri             ""
   :params          {:org.foo/id "bar"} ;; Qualified keywords are now supported!
   :on-success      [::console-log]
   :on-failure      [::console-log]}])

eval-on-point20:01:02

My team is running into an odd error which causes re-frame-10x to crash when we switch to the events panel. Does this ring a bell with anyone?

core.cljs:13 Uncaught TypeError: Cannot read properties of undefined (reading 'call')
    at cmp.re_highlight$core$did_mount (core.cljs:13:6)
    at cmp.reagent$impl$component$custom_wrapper_$_componentDidMount [as componentDidMount] (component.cljs:196:25)
    at commitLifeCycles (react-dom.development.js:22101:22)
    at commitLayoutEffects (react-dom.development.js:25344:7)
    at HTMLUnknownElement.callCallback (react-dom.development.js:336:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:385:16)
    at invokeGuardedCallback (react-dom.development.js:440:31)
    at commitRootImpl (react-dom.development.js:25082:9)
    at unstable_runWithPriority (scheduler.development.js:697:12)
    at runWithPriority$2 (react-dom.development.js:12149:10)
The offending code appears to be here:
(ns re-highlight.core
  (:require
    [goog.object  :as gobj]
    [reagent.core :as r]
    [reagent.dom  :as rdom]
    [highlight.js :as highlight-js]))

(def highlight-element (gobj/get highlight-js "highlightElement"))

(defn did-mount
  [this]
  (when-let [el (gobj/get (rdom/dom-node this) "firstChild")]
    (highlight-element el)))
Where highlight-element appears to end up as nil. It doesn't immediately appear to be an issue with transitive deps, but I am stumped as to what else could be going on.

p-himik20:01:14

Did you install the right version of highlight.js?

eval-on-point21:01:38

I believe so. re-frame-10x appears to bring in a minified copy of 10.3.1 through cljsjs/highlight

p-himik21:01:48

If you log the value of highlight-js and inspect it in your browser's JS console, it might give a clue as to what's going on. Maybe something else pulls in an older version of the library that doesn't have highlightElement. Maybe there's some issue with the cljsjs package (I haven't used those for years because shadow-cljs makes them obsolete, so can't really tell whether it's possible or not).

eval-on-point21:01:56

hmm just comes up as nil, but maybe I am doing something incorrectly. I might try running the equivalent project in a shadow build to see if the problem persists or not. Thanks for the second set of eyes

👍 1
eval-on-point01:01:38

Sure, I can do that tomorrow. First, I'll try to create a minimal example just to make absolutely sure it isn't user error. If it is, I can follow up w/ anything that might be useful to document

eval-on-point19:01:52

Created an issue to track this with a minimal example [here](https://github.com/day8/re-frame-10x/issues/346). I believe it has something to do with using :target :bundle in my figwheel configuration. Simply adding highlight.js to my npm deps doesn't get me there. I'm going to drill down on it some more when I have some free time after work.

eval-on-point20:01:06

Yup, let me know if you try your hand at it and need any additional info to reproduce.