Skip to content

Commit 9736f13

Browse files
test: add test case for new notification
1 parent 80d2145 commit 9736f13

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

coderd/notifications/notifications_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,20 @@ func TestNotificationTemplates_Golden(t *testing.T) {
10341034
},
10351035
},
10361036
},
1037+
{
1038+
name: "TemplateWorkspaceCreated",
1039+
id: notifications.TemplateWorkspaceCreated,
1040+
payload: types.MessagePayload{
1041+
UserName: "Bobby",
1042+
UserEmail: "bobby@coder.com",
1043+
UserUsername: "bobby",
1044+
Labels: map[string]string{
1045+
"workspace": "bobby-workspace",
1046+
"template": "bobby-template",
1047+
"version": "alpha",
1048+
},
1049+
},
1050+
},
10371051
}
10381052

10391053
// We must have a test case for every notification_template. This is enforced below:
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
From: system@coder.com
2+
To: bobby@coder.com
3+
Subject: Workspace 'bobby-workspace' has been created
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 workspace bobby-workspace has been created from the template bobby-temp=
16+
late using version alpha.
17+
18+
19+
See workspace: http://test.com/@bobby/bobby-workspace
20+
21+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
22+
Content-Transfer-Encoding: quoted-printable
23+
Content-Type: text/html; charset=UTF-8
24+
25+
<!doctype html>
26+
<html lang=3D"en">
27+
<head>
28+
<meta charset=3D"UTF-8" />
29+
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=
30+
=3D1.0" />
31+
<title>Workspace 'bobby-workspace' has been created</title>
32+
</head>
33+
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-=
34+
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel=
35+
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617=
36+
; background: #f8fafc;">
37+
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde=
38+
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig=
39+
n: left; font-size: 14px; line-height: 1.5;">
40+
<div style=3D"text-align: center;">
41+
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod=
42+
er Logo" style=3D"height: 40px;" />
43+
</div>
44+
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m=
45+
argin: 8px 0 32px; line-height: 1.5;">
46+
Workspace 'bobby-workspace' has been created
47+
</h1>
48+
<div style=3D"line-height: 1.5;">
49+
<p>Hello Bobby,</p>
50+
51+
<p>The workspace <strong>bobby-workspace</strong> has been created from the=
52+
template <strong>bobby-template</strong> using version <strong>alpha</stro=
53+
ng>.</p>
54+
</div>
55+
<div style=3D"text-align: center; margin-top: 32px;">
56+
=20
57+
<a href=3D"http://test.com/@bobby/bobby-workspace" style=3D"display=
58+
: inline-block; padding: 13px 24px; background-color: #020617; color: #f8fa=
59+
fc; text-decoration: none; border-radius: 8px; margin: 0 4px;">
60+
See workspace
61+
</a>
62+
=20
63+
</div>
64+
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz=
65+
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;">
66+
<p>&copy;&nbsp;2024&nbsp;Coder. All rights reserved&nbsp;-&nbsp;<a =
67+
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h=
68+
ttp://test.com</a></p>
69+
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo=
70+
r: #2563eb; text-decoration: none;">Click here to manage your notification =
71+
settings</a></p>
72+
<p><a href=3D"http://test.com/settings/notifications?disabled=3D281=
73+
fdf73-c6d6-4cbb-8ff5-888baf8a2fff" style=3D"color: #2563eb; text-decoration=
74+
: none;">Stop receiving emails like this</a></p>
75+
</div>
76+
</div>
77+
</body>
78+
</html>
79+
80+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4--
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"_version": "1.1",
3+
"msg_id": "00000000-0000-0000-0000-000000000000",
4+
"payload": {
5+
"_version": "1.1",
6+
"notification_name": "Workspace Created",
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 workspace",
15+
"url": "http://test.com/@bobby/bobby-workspace"
16+
}
17+
],
18+
"labels": {
19+
"template": "bobby-template",
20+
"version": "alpha",
21+
"workspace": "bobby-workspace"
22+
},
23+
"data": null
24+
},
25+
"title": "Workspace 'bobby-workspace' has been created",
26+
"title_markdown": "Workspace 'bobby-workspace' has been created",
27+
"body": "Hello Bobby,\n\nThe workspace bobby-workspace has been created from the template bobby-template using version alpha.",
28+
"body_markdown": "Hello Bobby,\n\nThe workspace **bobby-workspace** has been created from the template **bobby-template** using version **alpha**."
29+
}

0 commit comments

Comments
 (0)