Integrate objects-map and introduce file feature flags

This commit is contained in:
Andrey Antukh
2022-10-06 18:47:16 +02:00
committed by Andrés Moya
parent 69f084e1df
commit 951b3eb4fe
21 changed files with 406 additions and 264 deletions

View File

@@ -6,16 +6,22 @@
(ns app.common.pages-test
(:require
[clojure.test :as t]
[clojure.pprint :refer [pprint]]
[app.common.files.features :as ffeat]
[app.common.pages :as cp]
[app.common.types.file :as ctf]
[app.common.uuid :as uuid]))
[app.common.uuid :as uuid]
[clojure.pprint :refer [pprint]]
[clojure.test :as t]))
(defn- make-file-data
[file-id page-id]
(binding [ffeat/*current* #{"components/v2"}]
(ctf/make-file-data file-id page-id)))
(t/deftest process-change-set-option
(let [file-id (uuid/custom 2 2)
page-id (uuid/custom 1 1)
data (ctf/make-file-data file-id page-id true)]
data (make-file-data file-id page-id)]
(t/testing "Sets option single"
(let [chg {:type :set-option
:page-id page-id
@@ -81,7 +87,7 @@
(t/deftest process-change-add-obj
(let [file-id (uuid/custom 2 2)
page-id (uuid/custom 1 1)
data (ctf/make-file-data file-id page-id true)
data (make-file-data file-id page-id)
id-a (uuid/custom 2 1)
id-b (uuid/custom 2 2)
id-c (uuid/custom 2 3)]
@@ -135,7 +141,7 @@
(t/deftest process-change-mod-obj
(let [file-id (uuid/custom 2 2)
page-id (uuid/custom 1 1)
data (ctf/make-file-data file-id page-id true)]
data (make-file-data file-id page-id)]
(t/testing "simple mod-obj"
(let [chg {:type :mod-obj
:page-id page-id
@@ -162,7 +168,7 @@
(let [file-id (uuid/custom 2 2)
page-id (uuid/custom 1 1)
id (uuid/custom 2 1)
data (ctf/make-file-data file-id page-id true)
data (make-file-data file-id page-id)
data (-> data
(assoc-in [:pages-index page-id :objects uuid/zero :shapes] [id])
(assoc-in [:pages-index page-id :objects id]
@@ -206,7 +212,7 @@
file-id (uuid/custom 2 2)
page-id (uuid/custom 1 1)
data (ctf/make-file-data file-id page-id true)
data (make-file-data file-id page-id)
data (update-in data [:pages-index page-id :objects]
#(-> %
@@ -450,7 +456,7 @@
:obj {:type :rect
:name "Shape 3"}}
]
data (ctf/make-file-data file-id page-id true)
data (make-file-data file-id page-id)
data (cp/process-changes data changes)]
(t/testing "preserve order on multiple shape mov 1"
@@ -557,7 +563,7 @@
:parent-id group-1-id
:shapes [shape-1-id shape-2-id]}]
data (ctf/make-file-data file-id page-id true)
data (make-file-data file-id page-id)
data (cp/process-changes data changes)]
(t/testing "case 1"

View File

@@ -6,16 +6,22 @@
(ns app.common.test-helpers.files
(:require
[app.common.geom.point :as gpt]
[app.common.types.components-list :as ctkl]
[app.common.types.colors-list :as ctcl]
[app.common.types.container :as ctn]
[app.common.types.file :as ctf]
[app.common.types.pages-list :as ctpl]
[app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst]
[app.common.types.typographies-list :as ctyl]
[app.common.uuid :as uuid]))
[app.common.files.features :as ffeat]
[app.common.geom.point :as gpt]
[app.common.types.colors-list :as ctcl]
[app.common.types.components-list :as ctkl]
[app.common.types.container :as ctn]
[app.common.types.file :as ctf]
[app.common.types.pages-list :as ctpl]
[app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst]
[app.common.types.typographies-list :as ctyl]
[app.common.uuid :as uuid]))
(defn- make-file-data
[file-id page-id]
(binding [ffeat/*current* #{"components/v2"}]
(ctf/make-file-data file-id page-id)))
(def ^:private idmap (atom {}))
@@ -33,7 +39,7 @@
([file-id page-id props]
(merge {:id file-id
:name (get props :name "File1")
:data (ctf/make-file-data file-id page-id true)}
:data (make-file-data file-id page-id)}
props)))
(defn sample-shape
@@ -81,12 +87,12 @@
#(reduce (fn [page shape] (ctst/set-shape page shape))
%
updated-shapes))
(ctkl/add-component (:id component-shape)
(:name component-shape)
""
shape-id
page-id
component-shapes))))))
(ctkl/add-component {:id (:id component-shape)
:name (:name component-shape)
:path ""
:main-instance-id shape-id
:main-instance-page page-id
:shapes component-shapes}))))))
(defn sample-instance
[file label page-id library component-id]