diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs index 459e4e70b9..480c8c9d55 100644 --- a/frontend/src/app/main/data/workspace/notifications.cljs +++ b/frontend/src/app/main/data/workspace/notifications.cljs @@ -359,7 +359,7 @@ (modal/show :file-restored {:fullname (restorer-fullname state profile-id session-id) :label label - :created-at created-at + :date created-at ;; Made on the replaced version, so the reload drops them :unsaved (boolean (seq (dps/pending-file-changes state file)))})) (rx/empty)))))) diff --git a/frontend/src/app/main/ui/workspace/file_restored_modal.cljs b/frontend/src/app/main/ui/workspace/file_restored_modal.cljs index badadb4957..c4aee1305f 100644 --- a/frontend/src/app/main/ui/workspace/file_restored_modal.cljs +++ b/frontend/src/app/main/ui/workspace/file_restored_modal.cljs @@ -36,7 +36,9 @@ which was reloaded, and whether their edits not saved yet were lost." {::mf/register modal/components ::mf/register-as :file-restored} - [{:keys [fullname label created-at unsaved]}] + ;; The modal wrapper passes the props map without camelCasing its keys, + ;; so every prop of this component must be a one-word name. + [{:keys [fullname label date unsaved]}] (let [on-close (mf/use-fn #(st/emit! (modal/hide)))] [:div {:class (stl/css :modal-overlay)} [:div {:class (stl/css :modal-dialog) @@ -49,7 +51,7 @@ :class (stl/css :modal-title)} (tr "workspace.file-restored.title")] [:> text* {:as "p" :typography t/body-large} - (restored-message fullname label created-at)] + (restored-message fullname label date)] (when unsaved [:> text* {:as "p" :typography t/body-large} (tr "workspace.file-restored.unsaved-changes")]) diff --git a/frontend/test/frontend_tests/data/workspace_notifications_test.cljs b/frontend/test/frontend_tests/data/workspace_notifications_test.cljs index 0ad8a12697..c6b4d721b4 100644 --- a/frontend/test/frontend_tests/data/workspace_notifications_test.cljs +++ b/frontend/test/frontend_tests/data/workspace_notifications_test.cljs @@ -140,7 +140,7 @@ props (:props (shown-modal events))] (t/is (= "Ada" (:fullname props))) (t/is (= "Hand-off v2" (:label props))) - (t/is (= created-at (:created-at props))) + (t/is (= created-at (:date props))) (t/is (true? (:unsaved props))))) ;; Scenario: the restoring session left before its message arrived, so it diff --git a/frontend/test/frontend_tests/ui/file_restored_modal_test.cljs b/frontend/test/frontend_tests/ui/file_restored_modal_test.cljs index 169baa4573..983f88ab39 100644 --- a/frontend/test/frontend_tests/ui/file_restored_modal_test.cljs +++ b/frontend/test/frontend_tests/ui/file_restored_modal_test.cljs @@ -6,10 +6,14 @@ (ns frontend-tests.ui.file-restored-modal-test (:require + ["react-dom/server" :as rds] [app.common.time :as ct] + [app.main.data.modal :as modal] [app.main.ui.workspace.file-restored-modal :as frm] [app.util.i18n :as i18n] - [cljs.test :as t :include-macros true])) + [cljs.test :as t :include-macros true] + [cuerdas.core :as str] + [rumext.v2 :as mf])) (defn- message "The translation key and arguments of the restore message." @@ -32,3 +36,17 @@ (message "Ada" nil nil))) (t/is (= ["workspace.file-restored.message-anonymous"] (message nil nil nil))))) + +(defn- render-modal + "Markup of the registered `:file-restored` modal for the `props` map, + rendered the way the modal wrapper does it (`mf/element` with the map)." + [props] + (with-redefs [i18n/tr (fn ([key] key) ([key & args] (str/join "|" (into [key] args))))] + (rds/renderToStaticMarkup + (mf/element (get @modal/components :file-restored) props)))) + +(t/deftest the-modal-shows-the-date-of-an-unnamed-version + (let [created-at (ct/now) + markup (render-modal {:fullname "Ada" :date created-at :unsaved false})] + (t/is (str/includes? markup (str "workspace.file-restored.message-date|Ada|" + (ct/format-inst created-at "PPp"))))))