From bef82a1a45f00c1047f635c8f0dba8e14fd7adf8 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Sun, 8 Nov 2026 17:00:24 +0100 Subject: [PATCH] :paperclip: Drop the typography file when a test text clears its typography A copy text that cleared a library typography in the generated histories kept the run's typography file reference with no typography, which the design panel never writes. The oracle then saw a reference the copy could not own. Restyling the typography of a test text now replaces the file reference too. Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/test_helpers/texts.cljc | 6 ++++-- .../test/common_tests/logic/composable_gen_test.cljc | 10 ++++++++++ common/test/common_tests/logic/text_notation_test.cljc | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/test_helpers/texts.cljc b/common/src/app/common/test_helpers/texts.cljc index 0522219daa..438c6eede4 100644 --- a/common/src/app/common/test_helpers/texts.cljc +++ b/common/src/app/common/test_helpers/texts.cljc @@ -332,8 +332,9 @@ (defn restyle "Set the run style `k` to `v` on every run of `text`. - Named colors and explicit fills replace each other. Font edits replace - stale raw identities while preserving the other font unit." + Named colors and explicit fills replace each other, a typography replaces + the file of the one before. Font edits replace stale raw identities while + preserving the other font unit." [text k v] (update-paragraphs text (fn [[style runs]] @@ -341,6 +342,7 @@ [letters (cond-> (assoc run-style k v) (= k :color) (dissoc :fills) (= k :fills) (dissoc :color) + (= k :typography) (dissoc :typography-ref-file) (= k :family) (dissoc :font-family :font-id) (= k :weight) (dissoc :font-weight :font-variant-id) (= k :italic) (dissoc :font-style :font-variant-id))]) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 1efe6d3322..9faa793e92 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1880,6 +1880,16 @@ (t/is (= 1 (get-in result [:executed :library-sync]))) (t/is (= 1 (count (tm/aux-files (:situation result))))))) +(t/deftest clearing-a-library-typography-in-a-copy-drops-its-reference + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :library-variants true + :stale-libraries true :layout nil :layout-item-margins false + :grid-square false :library-depth 1 :library true + :rich-variants true :layout-children false :library-text true + :grid-empty false :layout-copies true :text true}] + :ops [[:delete 0 0 0 0] [:delete 10 0 0 0] [:swap 3 0 0 0] + [:library-text-style 0 8 1] [:delete 0 0 0 0] [:library-edit 0 0 0] + [:edit 0 1 1 2] [:library-sync] [:text-style 14 8 0 0]]})))) + (t/deftest random-library-compositions (let [coverage (atom {}) failure (atom nil)] diff --git a/common/test/common_tests/logic/text_notation_test.cljc b/common/test/common_tests/logic/text_notation_test.cljc index c8ed56c220..ade0e94a62 100644 --- a/common/test/common_tests/logic/text_notation_test.cljc +++ b/common/test/common_tests/logic/text_notation_test.cljc @@ -135,7 +135,13 @@ (thtx/restyle-paragraphs typed :line-height 2)))) (t/testing "changing another style keeps it" (t/is (= [[{:line-height 1.6} ["Read" {:family "Roboto" :size 16 :typography :body :color :red}]]] - (thtx/restyle typed :color :red))))) + (thtx/restyle typed :color :red)))) + (t/testing "clearing the typography drops the file it comes from" + (let [cleared (-> typed + (thtx/restyle :typography-ref-file (thi/new-id! :library)) + (thtx/restyle :typography nil))] + (t/is (not-any? :typography-ref-file + (tree-seq map? :children (thtx/content cleared))))))) (t/is (= [[{:align "center"} ["Buy now" {:weight 700}]] [{:align "center"} ["Ends Sunday" {:weight 700}]]] (thtx/set-letters [[{:align "center"} ["Add " {:weight 700}] ["to cart"]]]