|
4 | 4 | [clojars.errors :as errors] |
5 | 5 | [clojars.log :as log] |
6 | 6 | [clojars.test-helper :as help] |
| 7 | + [clojars.web.dashboard :as dashboard] |
7 | 8 | [clojure.test :refer [deftest is use-fixtures]] |
8 | 9 | [kerodon.core :refer [fill-in follow-redirect follow press |
9 | 10 | session visit within]] |
|
16 | 17 | help/run-test-app) |
17 | 18 |
|
18 | 19 | (deftest server-errors-display-error-page |
19 | | - (with-out-str (-> (session (help/app)) |
20 | | - (visit "/error") |
21 | | - (within [:div.small-section :> :h1] |
22 | | - (has (text? "Oops!")))))) |
23 | | - |
24 | | -(deftest error-page-includes-error-id |
25 | | - (with-redefs [log/trace-id (constantly #uuid "8f3788f5-9001-444d-8c57-049ba685cea8")] |
| 20 | + (with-redefs [dashboard/index-page (fn [& _] (throw (Exception. "BOOM!"))) |
| 21 | + log/trace-id (constantly #uuid "8f3788f5-9001-444d-8c57-049ba685cea8")] |
26 | 22 | (with-out-str (-> (session (help/app)) |
27 | | - (visit "/error") |
| 23 | + (visit "/") |
| 24 | + (within [:div.small-section :> :h1] |
| 25 | + (has (text? "Oops!"))) |
28 | 26 | (within [:div.small-section :> :pre.error-id] |
29 | 27 | (has (text? "error-id:\"8f3788f5-9001-444d-8c57-049ba685cea8\""))))))) |
30 | 28 |
|
31 | 29 | (deftest server-errors-log-caught-exceptions |
32 | 30 | (let [err (atom nil)] |
33 | | - (with-redefs [errors/report-error (fn [_r e & _] (reset! err e))] |
| 31 | + (with-redefs [dashboard/index-page (fn [& _] (throw (Exception. "BOOM!"))) |
| 32 | + errors/report-error (fn [_r e & _] (reset! err e))] |
34 | 33 | (-> (session (help/app)) |
35 | | - (visit "/error")) |
36 | | - (is (re-find #"You really want an error" (.getMessage @err)))))) |
| 34 | + (visit "/")) |
| 35 | + (is (re-find #"BOOM" (.getMessage @err)))))) |
37 | 36 |
|
38 | 37 | (deftest browse-page-renders-multiple-pages |
39 | 38 | (help/add-verified-group "test-user" "tester") |
|
0 commit comments