🐛 Explain in the import dialog why a components v1 file is rejected

Importing a file in the old components v1 format failed with "Something
went wrong while processing this file". The job's entry carried the
specific message (`dashboard.import.components-v1-error`), but the error
list of the dialog only knew the check error and corrupt file texts and
showed the unknown error text for everything else.

The error list now shows the components v1 message as it is
(`import-error-detail`).

Found by the components Qase run (Migration suite).

Test: `dashboard-import-errors-test`.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-19 09:55:58 +01:00
parent 81ff4c0c90
commit 61d3313fbb
3 changed files with 49 additions and 11 deletions

View File

@ -669,6 +669,24 @@
:style (when (some? pct)
#js {:width (str pct "%")})}]])])))
(defn import-error-detail
"The text that explains why an entry could not be imported."
[err]
(cond
(= err (tr "dashboard.import.components-v1-error"))
err
(and (string? err)
(str/includes? (str/lower err) "check error"))
(tr "dashboard.import.import-error.check-error")
(and (string? err)
(str/includes? (str/lower err) "corrupt"))
(tr "dashboard.import.import-error.corrupt-file")
:else
(tr "dashboard.import.import-error.unknown-error")))
(mf/defc import-files-stage*
{::mf/private true}
[{:keys [entries template status step errors? import-success-total auto-linked-count
@ -715,17 +733,7 @@
[:div (:name entry)]
(when-let [err (:error entry)]
[:div {:class (stl/css :import-error-detail)}
(cond
(and (string? err)
(str/includes? (str/lower err) "check error"))
(tr "dashboard.import.import-error.check-error")
(and (string? err)
(str/includes? (str/lower err) "corrupt"))
(tr "dashboard.import.import-error.corrupt-file")
:else
(tr "dashboard.import.import-error.unknown-error"))])]))]
(import-error-detail err)])]))]
[:div (tr "dashboard.import.import-error.message2")]]
(imp/awaiting-analysis? status errors?)

View File

@ -188,6 +188,7 @@
[frontend-tests.ui.comments-clustering-test]
[frontend-tests.ui.comments-position-modifier-test]
[frontend-tests.ui.context-menu-prototype-test]
[frontend-tests.ui.dashboard-import-errors-test]
[frontend-tests.ui.dashboard-import-linking-test]
[frontend-tests.ui.drawarea-test]
[frontend-tests.ui.ds-controls-numeric-input-test]
@ -445,6 +446,7 @@
'frontend-tests.ui.comments-clustering-test
'frontend-tests.ui.comments-position-modifier-test
'frontend-tests.ui.context-menu-prototype-test
'frontend-tests.ui.dashboard-import-errors-test
'frontend-tests.ui.dashboard-import-linking-test
'frontend-tests.ui.drawarea-test
'frontend-tests.ui.ds-controls-numeric-input-test

View File

@ -0,0 +1,28 @@
;; 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.ui.dashboard-import-errors-test
"The text the import wizard shows under an entry that failed."
(:require
[app.main.ui.dashboard.import :as import]
[app.util.i18n :refer [tr]]
[cljs.test :as t :include-macros true]))
(t/deftest a-components-v1-file-shows-why-it-cannot-be-imported
(let [err (tr "dashboard.import.components-v1-error")]
(t/is (= err (import/import-error-detail err)))))
(t/deftest known-failures-show-their-own-explanation
(t/is (= (tr "dashboard.import.import-error.check-error")
(import/import-error-detail "Check error: invalid shape")))
(t/is (= (tr "dashboard.import.import-error.corrupt-file")
(import/import-error-detail "The file is corrupt"))))
(t/deftest other-failures-show-the-generic-explanation
(t/is (= (tr "dashboard.import.import-error.unknown-error")
(import/import-error-detail "some server hint")))
(t/is (= (tr "dashboard.import.import-error.unknown-error")
(import/import-error-detail nil))))