Skip to content

Commit bd884f6

Browse files
committed
Use source location viewer in test report viewer
1 parent c9c174f commit bd884f6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/portal/ui/viewer/source_location.cljs

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
(defn- source-location? [value]
2121
(s/valid? ::source-location value))
2222

23+
(defn ->source-location [value]
24+
(when (source-location? value)
25+
(with-meta
26+
(select-keys value [:ns :column :line :file :label])
27+
(assoc (meta value)
28+
:portal.viewer/default :portal.viewer/source-location))))
29+
2330
(defn inspect-source [value]
2431
(let [theme (theme/use-theme)]
2532
[d/div

src/portal/ui/viewer/test_report.cljs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
[portal.ui.inspector :as ins]
77
[portal.ui.select :as select]
88
[portal.ui.styled :as d]
9-
[portal.ui.theme :as theme]))
9+
[portal.ui.theme :as theme]
10+
[portal.ui.viewer.source-location :as src]))
1011

1112
;;; :spec
1213
(s/def :test-run/type #{:end-run-tests})
@@ -147,12 +148,11 @@
147148
:border-bottom-right-radius (when-not expanded? (:border-radius theme))}}
148149
[ins/toggle-expand {:padding-left (:padding theme)}]
149150
[label value]
150-
(when-let [file (:file value)]
151+
(when-let [location (src/->source-location value)]
151152
[d/div
152-
{:style {:color (::c/uri theme)}}
153-
file
154-
(when-let [line (:line value)]
155-
[:<> ":" line])])]]
153+
[select/with-position
154+
{:row -1 :column 1}
155+
[ins/with-key :loc [ins/inspector location]]]])]]
156156

157157
(when (:expanded? options)
158158
[ins/inspect-map-k-v (dissoc value :type :message :file :line :ns :var)])]))

0 commit comments

Comments
 (0)