@@ -5,18 +5,6 @@ class EmailErrorReporter::ErrorMailerTest < ActionMailer::TestCase
5
5
@exception = Exception . new ( "some message" )
6
6
end
7
7
8
- test "renders the template correctly" do
9
- assert_equal [ ] , error_mail . to
10
- assert_equal read_fixture ( "error" ) . join , error_mail . body . to_s
11
- end
12
-
13
- test "renders a backtrace" do
14
- @exception . set_backtrace ( [ "foo" , "bar" ] )
15
-
16
- assert_equal [ ] , error_mail . to
17
- assert_equal read_fixture ( "error_with_backtrace" ) . join , error_mail . body . to_s
18
- end
19
-
20
8
test "severity: error" do
21
9
email = error_mail ( severity : :error )
22
10
assert_equal "🔥" + " Exception" , email . subject
@@ -32,6 +20,21 @@ class EmailErrorReporter::ErrorMailerTest < ActionMailer::TestCase
32
20
assert_equal "ℹ️" + " Exception" , email . subject
33
21
end
34
22
23
+ test "email content" do
24
+ @exception . set_backtrace ( [ "foo" , "bar" ] )
25
+ email = error_mail ( handled : true , severity : :info ) . deliver_now
26
+ assert_dom_email do
27
+ assert_dom "h1" , "Exception"
28
+ assert_dom "h2" , "some message"
29
+ assert_dom test_id ( "source" ) , "Source: No source present"
30
+ assert_dom test_id ( "handled" ) , "Handled: ✅"
31
+ assert_dom test_id ( "context" ) , "{}"
32
+ assert_dom "table" do
33
+ assert_dom "tr" , 2
34
+ end
35
+ end
36
+ end
37
+
35
38
private
36
39
37
40
def error_mail ( **kwargs )
@@ -43,4 +46,8 @@ def error_mail(**kwargs)
43
46
**kwargs
44
47
)
45
48
end
49
+
50
+ def test_id ( value )
51
+ "[data-test-id='#{ value } ']"
52
+ end
46
53
end
0 commit comments