mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 17:50:38 +00:00
The frontend's component swap, which a variant switch uses too, sends a layout update for the parents the swap returns and for the new subtree. The harness swap and switch nodes reflowed nothing, so a switch in a page copy of a flex main left a sibling of the switched head in its old place, and the next move of that sibling took the layout's correction as its own geometry override. The swap and switch nodes now reflow the layouts among those parents and the new subtree. They do not mark the changes for the runner's pass over every layout after sync, which the frontend does not do for a swap. Generated regression: a four-step nest, switch, duplicate and move program that failed I2 (seed 159775967, round 9) now passes. Golden masters af and ak recorded again on purpose: they start with a swap in a grid copy, whose two children now take their cells instead of the stale place they had; the main a later update-main pushes them into follows. Only geometry changes. Harness only; the benchmark is not run. Also in this commit: - Draw 50 programs in each random composition coverage test. The seven random composition tests check that every operation kind supplies its share of meaningful changes. With 20 programs some seeds draw too few steps whose precondition holds (a redo with an undone library change, a grid direction on a grid, a resize that changes anything), so the suite failed now and then although every program passed. The four seeds that failed pass with 50 programs. AI-assisted-by: claude-opus-5-5
51 lines
1.9 KiB
Clojure
51 lines
1.9 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
|
|
|
(ns common-tests.schema-check-test
|
|
(:require
|
|
[app.common.schema.test :as smt]
|
|
[clojure.string :as str]
|
|
[clojure.test :as t]
|
|
[clojure.test.check.generators :as gen]))
|
|
|
|
(t/deftest check-preserves-size-and-seed
|
|
(let [seen (atom [])
|
|
property (smt/for [size (gen/sized gen/return)]
|
|
(swap! seen conj size)
|
|
true)
|
|
run (fn []
|
|
(reset! seen [])
|
|
(smt/check! property :num 4 :max-size 1 :seed 712)
|
|
@seen)]
|
|
(t/is (= (run) (run)))
|
|
(t/is (every? zero? @seen))))
|
|
|
|
(t/deftest failure-reports-the-shrunk-case
|
|
(let [output (with-out-str
|
|
(smt/default-reporter-fn
|
|
{:type :shrunk :seed 712 :shrunk {:smallest [10]}}))]
|
|
(t/is (str/includes? output "712"))
|
|
(t/is (str/includes? output ":smallest [10]"))))
|
|
|
|
(t/deftest check-uses-the-environment-seed
|
|
(let [seed (atom nil)
|
|
expected #?(:clj (some-> (System/getenv "PENPOT_GEN_SEED") parse-long)
|
|
:cljs (some-> js/globalThis .-process .-env .-PENPOT_GEN_SEED js/Number))]
|
|
(smt/check! (smt/for [value gen/nat] (<= 0 value))
|
|
:num 1
|
|
:reporter-fn #(when (= :complete (:type %)) (reset! seed (:seed %))))
|
|
(when (some? expected)
|
|
(t/is (= expected @seed)))))
|
|
|
|
(t/deftest check-runs-the-default-num-unless-the-environment-sets-one
|
|
(let [runs (atom 0)
|
|
environment-num #?(:clj (System/getenv "PENPOT_GEN_NUM")
|
|
:cljs (some-> js/globalThis .-process .-env .-PENPOT_GEN_NUM))]
|
|
(when-not environment-num
|
|
(smt/check! (smt/for [_ gen/nat] (swap! runs inc) true)
|
|
:default-num 3)
|
|
(t/is (= 3 @runs)))))
|