mirror of
https://github.com/penpot/penpot.git
synced 2026-09-24 21:06:14 +00:00
The seven creation commands no longer accept an optional client id: create-file, create-project, create-team, create-team-with-invitations, upload-file-media-object, create-file-media-object-from-url and assemble-file-media-object. The server always generates the identifier; a sent id is ignored. Malli maps are open and the RPC layer never strips unknown params, so the handlers that would still honor an id (create-file, create-project) now drop it explicitly. Internal callers that pass remapped ids (project duplicate, binfile import) keep working. Closes #11783 AI-assisted-by: muse-spark-1.3-contributor
64 lines
2.3 KiB
Clojure
64 lines
2.3 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 frontend-tests.data.svg-upload-test
|
|
"Tests for the media upload triggered from an SVG import."
|
|
(:require
|
|
[app.common.transit :as tr]
|
|
[app.common.uuid :as uuid]
|
|
[app.main.data.workspace.svg-upload :as svg]
|
|
[beicon.v2.core :as rx]
|
|
[cljs.test :as t :include-macros true]
|
|
[frontend-tests.helpers.http :as http]))
|
|
|
|
(defn- image-node
|
|
[href]
|
|
{:tag :image
|
|
:attrs {:href href :width "10" :height "20"}
|
|
:content []})
|
|
|
|
(t/deftest upload-images-drops-svg-only-attrs
|
|
(t/testing "media upload params do not carry svg-only attrs"
|
|
(t/async done
|
|
(let [file-id (uuid/next)
|
|
bodies (atom [])
|
|
|
|
fetch-mock
|
|
(fn [url opts]
|
|
(swap! bodies conj {:cmd (http/url->cmd url)
|
|
:body (.-body opts)})
|
|
(js/Promise.resolve
|
|
(http/make-transit-response
|
|
{:id (uuid/next)
|
|
:file-id file-id
|
|
:name "pic"
|
|
:mtype "image/png"
|
|
:width 10
|
|
:height 20})))
|
|
|
|
orig (http/install-fetch-mock! fetch-mock)
|
|
svg-data {:tag :svg
|
|
:attrs {}
|
|
:content [(image-node "https://example.com/pic.png")]}]
|
|
|
|
(->> (svg/upload-images svg-data file-id)
|
|
(rx/subs!
|
|
(fn [_] nil)
|
|
(fn [err]
|
|
(http/restore-fetch! orig)
|
|
(t/is false (str "unexpected error: " (ex-message err)))
|
|
(done))
|
|
(fn []
|
|
(http/restore-fetch! orig)
|
|
(let [{:keys [cmd body]} (first @bodies)
|
|
params (tr/decode-str body)]
|
|
(t/is (= :create-file-media-object-from-url cmd))
|
|
(t/is (= "https://example.com/pic.png" (:url params)))
|
|
(t/is (not (contains? params :href)))
|
|
(t/is (not (contains? params :width)))
|
|
(t/is (not (contains? params :height))))
|
|
(done))))))))
|