diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 6995464290..145737280a 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -784,8 +784,12 @@ (db/tx-run! (assoc cfg ::db/rollback true) (fn [cfg] - (let [file (bfc/get-file cfg file-id) - libs (bfc/get-resolved-file-libraries cfg file-id)] + ;; Validation walks every page and component, so the + ;; file is read realized; the library map is built + ;; from the file (not its id) and its own loader + ;; resolves each library's pointers. + (let [file (bfc/get-file cfg file-id :realize? true) + libs (bfc/get-resolved-file-libraries cfg file)] (if file (let [errors (cfv/validate-file file libs)] {::yres/status 200 diff --git a/backend/test/backend_tests/http_debug_test.clj b/backend/test/backend_tests/http_debug_test.clj new file mode 100644 index 0000000000..9c874601f4 --- /dev/null +++ b/backend/test/backend_tests/http_debug_test.clj @@ -0,0 +1,29 @@ +;; 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 backend-tests.http-debug-test + "The /dbg validate action walks the whole file and its libraries: it + must hand `get-resolved-file-libraries` the file (not its id) and + resolve the pointer-mapped pages with the file's own loader." + (:require + [app.http.debug :as debug] + [backend-tests.helpers :as th] + [clojure.test :as t] + [yetti.response :as-alias yres])) + +(t/use-fixtures :once th/state-init) +(t/use-fixtures :each th/database-reset) + +(t/deftest validate-file-action-resolves-pointer-mapped-data + (let [profile (th/create-profile* 1) + file (th/create-file* 1 {:profile-id (:id profile) + :project-id (:default-project-id profile) + :is-shared false}) + handler (deref #'debug/validate-file) + result (handler th/*system* {:params {:file-id (str (:id file))}})] + + (t/is (= 200 (::yres/status result))) + (t/is (= "NO VALIDATION ERRORS FOUND" (::yres/body result)))))