Skip to content

Commit 5732b26

Browse files
test: add rendered-template test
1 parent cd97285 commit 5732b26

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

coderd/notifications/notifications_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,20 @@ func TestNotificationTemplates_Golden(t *testing.T) {
10211021
appName: "Custom Application Name",
10221022
logoURL: "https://custom.application/logo.png",
10231023
},
1024+
{
1025+
name: "TemplateTemplateDeprecated",
1026+
id: notifications.TemplateTemplateDeprecated,
1027+
payload: types.MessagePayload{
1028+
UserName: "Bobby",
1029+
UserEmail: "bobby@coder.com",
1030+
UserUsername: "bobby",
1031+
Labels: map[string]string{
1032+
"template": "alpha",
1033+
"message": "This template has been replaced by beta",
1034+
"organization": "coder",
1035+
},
1036+
},
1037+
},
10241038
}
10251039

10261040
// We must have a test case for every notification_template. This is enforced below:
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From: system@coder.com
2+
To: bobby@coder.com
3+
Subject: Template 'alpha' has been deprecated
4+
Message-Id: 02ee4935-73be-4fa1-a290-ff9999026b13@blush-whale-48
5+
Date: Fri, 11 Oct 2024 09:03:06 +0000
6+
Content-Type: multipart/alternative; boundary=bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
7+
MIME-Version: 1.0
8+
9+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
10+
Content-Transfer-Encoding: quoted-printable
11+
Content-Type: text/plain; charset=UTF-8
12+
13+
Hello Bobby,
14+
15+
The template alpha has been deprecated with the following message:
16+
17+
This template has been replaced by beta
18+
19+
New workspaces may not be created from this template. Existing workspaces w=
20+
ill continue to function normally.
21+
22+
23+
See workspaces: http://test.com/workspaces?filter=3Downer%3Ame+template%3Aa=
24+
lpha
25+
26+
View template: http://test.com/templates/coder/alpha
27+
28+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
29+
Content-Transfer-Encoding: quoted-printable
30+
Content-Type: text/html; charset=UTF-8
31+
32+
<!doctype html>
33+
<html lang=3D"en">
34+
<head>
35+
<meta charset=3D"UTF-8" />
36+
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=
37+
=3D1.0" />
38+
<title>Template 'alpha' has been deprecated</title>
39+
</head>
40+
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-=
41+
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel=
42+
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617=
43+
; background: #f8fafc;">
44+
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde=
45+
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig=
46+
n: left; font-size: 14px; line-height: 1.5;">
47+
<div style=3D"text-align: center;">
48+
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod=
49+
er Logo" style=3D"height: 40px;" />
50+
</div>
51+
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m=
52+
argin: 8px 0 32px; line-height: 1.5;">
53+
Template 'alpha' has been deprecated
54+
</h1>
55+
<div style=3D"line-height: 1.5;">
56+
<p>Hello Bobby,</p>
57+
58+
<p>The template <strong>alpha</strong> has been deprecated with the followi=
59+
ng message:</p>
60+
61+
<p><strong>This template has been replaced by beta</strong></p>
62+
63+
<p>New workspaces may not be created from this template. Existing workspace=
64+
s will continue to function normally.</p>
65+
</div>
66+
<div style=3D"text-align: center; margin-top: 32px;">
67+
=20
68+
<a href=3D"http://test.com/workspaces?filter=3Downer%3Ame+template%=
69+
3Aalpha" style=3D"display: inline-block; padding: 13px 24px; background-col=
70+
or: #020617; color: #f8fafc; text-decoration: none; border-radius: 8px; mar=
71+
gin: 0 4px;">
72+
See workspaces
73+
</a>
74+
=20
75+
<a href=3D"http://test.com/templates/coder/alpha" style=3D"display:=
76+
inline-block; padding: 13px 24px; background-color: #020617; color: #f8faf=
77+
c; text-decoration: none; border-radius: 8px; margin: 0 4px;">
78+
View template
79+
</a>
80+
=20
81+
</div>
82+
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz=
83+
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;">
84+
<p>&copy;&nbsp;2024&nbsp;Coder. All rights reserved&nbsp;-&nbsp;<a =
85+
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h=
86+
ttp://test.com</a></p>
87+
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo=
88+
r: #2563eb; text-decoration: none;">Click here to manage your notification =
89+
settings</a></p>
90+
<p><a href=3D"http://test.com/settings/notifications?disabled=3Df40=
91+
fae84-55a2-42cd-99fa-b41c1ca64894" style=3D"color: #2563eb; text-decoration=
92+
: none;">Stop receiving emails like this</a></p>
93+
</div>
94+
</div>
95+
</body>
96+
</html>
97+
98+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4--
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"_version": "1.1",
3+
"msg_id": "00000000-0000-0000-0000-000000000000",
4+
"payload": {
5+
"_version": "1.1",
6+
"notification_name": "Template Deprecated",
7+
"notification_template_id": "00000000-0000-0000-0000-000000000000",
8+
"user_id": "00000000-0000-0000-0000-000000000000",
9+
"user_email": "bobby@coder.com",
10+
"user_name": "Bobby",
11+
"user_username": "bobby",
12+
"actions": [
13+
{
14+
"label": "See workspaces",
15+
"url": "http://test.com/workspaces?filter=owner%3Ame+template%3Aalpha"
16+
},
17+
{
18+
"label": "View template",
19+
"url": "http://test.com/templates/coder/alpha"
20+
}
21+
],
22+
"labels": {
23+
"message": "This template has been replaced by beta",
24+
"organization": "coder",
25+
"template": "alpha"
26+
},
27+
"data": null
28+
},
29+
"title": "Template 'alpha' has been deprecated",
30+
"title_markdown": "Template 'alpha' has been deprecated",
31+
"body": "Hello Bobby,\n\nThe template alpha has been deprecated with the following message:\n\nThis template has been replaced by beta\n\nNew workspaces may not be created from this template. Existing workspaces will continue to function normally.",
32+
"body_markdown": "Hello Bobby,\n\nThe template **alpha** has been deprecated with the following message:\n\n**This template has been replaced by beta**\n\nNew workspaces may not be created from this template. Existing workspaces will continue to function normally."
33+
}

0 commit comments

Comments
 (0)