mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 06:20:32 +00:00
🚧 WIP Step 12.3, Test cleanup + missing coverage
AI-assisted-by: muse-spark, deepseek-flash
This commit is contained in:
parent
9f945de1a6
commit
5224a54cb7
@ -6,7 +6,10 @@
|
||||
|
||||
(ns frontend-tests.benches.boolean-test
|
||||
(:require
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes.intersect :as gint]
|
||||
[app.common.types.path :as path]
|
||||
[app.common.types.path.segment :as segm]
|
||||
[app.common.uuid :as uuid]
|
||||
[benches.render-wasm.scenes.builder :as b :include-macros true]
|
||||
[benches.render-wasm.scenes.common :as common]
|
||||
@ -33,6 +36,18 @@
|
||||
[(:frame-id (first children)) (:frame-id (second children))]))
|
||||
(t/is (= [0 0 100 100] (helpers/selrect bool)))))
|
||||
|
||||
(t/deftest difference-excludes-points-in-removed-overlap
|
||||
(let [instance (b/scene {:seed 1}
|
||||
(b/bool {:bool-type :difference}
|
||||
(b/rect {:x 0 :y 0 :width 100 :height 100})
|
||||
(b/rect {:x 50 :y 50 :width 100 :height 100})))
|
||||
bool (first (helpers/children-of instance uuid/zero))
|
||||
lines (segm/path->lines bool)]
|
||||
(t/is (true? (gint/is-point-inside-nonzero? (gpt/point 25 25) lines))
|
||||
"a point in the kept region stays inside the content")
|
||||
(t/is (false? (gint/is-point-inside-nonzero? (gpt/point 75 75) lines))
|
||||
"a point in the subtracted overlap is excluded from the content")))
|
||||
|
||||
(t/deftest union-derives-canonical-bounds
|
||||
(let [instance (b/scene {:seed 1}
|
||||
(b/bool {:bool-type :union}
|
||||
|
||||
@ -147,6 +147,43 @@
|
||||
(t/is (= ::cases/invalid-case (:type data)))
|
||||
(t/is (some? (::sm/explain data)))))))
|
||||
|
||||
(t/deftest rects-workload-ranges-are-rejected
|
||||
(let [schema (:params-schema (core/registered-scene :rects))
|
||||
good {:count 1000 :width 1920 :height 1080 :min-size 20 :max-size 100}]
|
||||
(t/is (true? (sm/validate schema good)))
|
||||
(t/testing "reversed size range"
|
||||
(t/is (false? (sm/validate schema (assoc good :min-size 100 :max-size 20)))))
|
||||
(t/testing "non-finite sizes"
|
||||
(doseq [bad [(assoc good :width js/Infinity)
|
||||
(assoc good :height js/NaN)
|
||||
(assoc good :min-size js/Infinity)
|
||||
(assoc good :max-size js/NaN)]]
|
||||
(t/is (false? (sm/validate schema bad)) (pr-str bad))))))
|
||||
|
||||
(t/deftest view-coordinates-are-finite
|
||||
(let [good {:scale 1 :x 0 :y 0}]
|
||||
(t/is (true? (sm/validate core/schema:view good)))
|
||||
(doseq [bad [(assoc good :scale js/Infinity)
|
||||
(assoc good :x js/NaN)
|
||||
(assoc good :y js/Infinity)
|
||||
(assoc good :viewport {:width js/NaN})]]
|
||||
(t/is (false? (sm/validate core/schema:view bad)) (pr-str bad)))))
|
||||
|
||||
(t/deftest serializable-rejects-json-lossy-values
|
||||
(t/is (true? (core/serializable? {:id :rects/load :seed 42 :tags ["a" 1]})))
|
||||
(t/is (false? (core/serializable? {:v js/NaN})))
|
||||
(t/is (false? (core/serializable? {:v js/Infinity})))
|
||||
(t/is (false? (core/serializable? {:v js/-Infinity})))
|
||||
(t/is (false? (core/serializable? {[1 2] "k"})))
|
||||
(t/is (false? (core/serializable? {{:a 1} "k"}))))
|
||||
|
||||
(t/deftest wire-ids-round-trip-through-json
|
||||
(doseq [id [:rects/load :rects :fresh :render-full]]
|
||||
(let [encoded (core/encode-id id)
|
||||
wire (.stringify js/JSON #js {:id encoded})
|
||||
through (unchecked-get (.parse js/JSON wire) "id")]
|
||||
(t/is (= id (core/decode-id through)) (str id)))))
|
||||
|
||||
(t/deftest duplicate-scene-id-from-another-namespace-is-rejected
|
||||
(t/is (= ::core/duplicate-scene
|
||||
(:type (failure-data
|
||||
|
||||
@ -92,15 +92,6 @@
|
||||
path? (conj [:path id (:content shape)])))))
|
||||
cases))
|
||||
|
||||
(t/deftest tail-cases-flags-are-consistent
|
||||
(doseq [{:keys [shape tail? svg? path?]} tail-cases]
|
||||
(t/is (boolean? tail?) "tail? is a boolean")
|
||||
(t/is (= tail? (boolean (or svg? path?))) "tail? matches the write flags")
|
||||
(t/is (= svg? (some? (:svg-attrs shape))) "svg? matches the shape")
|
||||
(t/is (= path? (boolean (and (contains? #{:path :bool} (:type shape))
|
||||
(some? (:content shape)))))
|
||||
"path? matches the shape")))
|
||||
|
||||
(t/deftest needs-shape-tail-matches-spec-table
|
||||
(doseq [{:keys [shape tail?]} tail-cases]
|
||||
(t/is (= tail? (serialize-shape/needs-shape-tail? shape))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user