Last active
February 8, 2021 18:37
-
-
Save tmoerman/9429cea43504c9bcd0e8251908c8d548 to your computer and use it in GitHub Desktop.
Fulcro bug or edge case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-case-ident | |
[props] | |
(let [case-id? string?] | |
(cond | |
(-> props :nexus.case.image-annotation/id merge/nilify-not-found case-id?) [:nexus.case.image-annotation/id (:nexus.case.image-annotation/id props)] | |
(-> props :nexus.case.test-case/id merge/nilify-not-found case-id?) [:nexus.case.test-case/id (:nexus.case.test-case/id props)] | |
:else (log/error "Cannot derive a valid ident. Invalid props." props)))) | |
(defsc AddState [_ _] | |
{:query [:nexus.case.image-annotation/id | |
:cmmn.case/state] | |
:ident :nexus.case.image-annotation/id}) | |
(defsc ImageAnnotationCase [this props] | |
{:query [:nexus.case.image-annotation/id | |
:cmmn.case/name | |
;; cmmn.case/state -> not queried here but under :>/bla placeholder! | |
{:>/bla (comp/get-query AddState)}] | |
:ident :nexus.case.image-annotation/id}) | |
(defsc TestCase [this props] | |
{:query [:nexus.case.test-case/id | |
:cmmn.case/name | |
:cmmn.case/state] | |
:ident :nexus.case.test-case/id}) | |
(defsc CaseUnion | |
"Union query component for different Case types." | |
[this props computed] | |
{:query (fn [] {:nexus.case.test-case/id (comp/get-query TestCase) | |
:nexus.case.image-annotation/id (comp/get-query ImageAnnotationCase)}) | |
:ident (fn [] (get-case-ident props))}) | |
(deftest reproducing-the-problem | |
(behavior "Reproduce situation where the :cmmn.case/state of the first case doesn't show up in merged props" | |
(let [response [{:nexus.case.image-annotation/id "case-id-00000001" | |
:cmmn.case/name "Annotate Image 1" | |
:cmmn.case/state ::merge/not-found ;; Note: I captured this by logging data-tree in pre-merge | |
:>/bla {:nexus.case.image-annotation/id "case-id-00000001" | |
:cmmn.case/state "completed"}} | |
{:nexus.case.test-case/id "case-id-00000004" | |
:cmmn.case/name "Test Case 1", | |
:cmmn.case/state "active"}]] | |
(assertions | |
"Show that :cmmn.case/state isn't merged" | |
(merge/merge-component {} CaseUnion response) => | |
{:nexus.case.image-annotation/id {"case-id-00000001" {:nexus.case.image-annotation/id "case-id-00000001" | |
:cmmn.case/name "Annotate Image 1" | |
;; :cmmn.case/state "completed" <== EXPECTED!! | |
:>/bla [:nexus.case.image-annotation/id "case-id-00000001"]}} | |
:nexus.case.test-case/id {"case-id-00000004" {:nexus.case.test-case/id "case-id-00000004" | |
:cmmn.case/name "Test Case 1" | |
:cmmn.case/state "active"}}} )))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment