Skip to content

feat: add notification for suspended/activated account #14367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 22, 2024
Prev Previous commit
Next Next commit
tests
  • Loading branch information
mtojek committed Aug 22, 2024
commit 80b227a356ef64eaed615d4ddc757a18613810da
20 changes: 20 additions & 0 deletions coderd/notifications/notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,26 @@ func TestNotificationTemplatesCanRender(t *testing.T) {
},
},
},
{
name: "TemplateYourAccountSuspended",
id: notifications.TemplateYourAccountSuspended,
payload: types.MessagePayload{
UserName: "bobby",
Labels: map[string]string{
"suspended_account_name": "bobby",
},
},
},
{
name: "TemplateYourAccountActivated",
id: notifications.TemplateYourAccountActivated,
payload: types.MessagePayload{
UserName: "bobby",
Labels: map[string]string{
"activated_account_name": "bobby",
},
},
},
{
name: "TemplateTemplateDeleted",
id: notifications.TemplateTemplateDeleted,
Expand Down
4 changes: 2 additions & 2 deletions coderd/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestNotifyUserSuspended(t *testing.T) {
require.Equal(t, member.Username, notifyEnq.Sent[1].Labels["suspended_account_name"])

// "Member" account suspended, "member" notified
require.Equal(t, notifications.TemplateUserAccountSuspended, notifyEnq.Sent[2].TemplateID)
require.Equal(t, notifications.TemplateYourAccountSuspended, notifyEnq.Sent[2].TemplateID)
require.Equal(t, member.ID, notifyEnq.Sent[2].UserID)
require.Contains(t, notifyEnq.Sent[2].Targets, member.ID)
require.Equal(t, member.Username, notifyEnq.Sent[2].Labels["suspended_account_name"])
Expand Down Expand Up @@ -473,7 +473,7 @@ func TestNotifyUserReactivate(t *testing.T) {
require.Equal(t, member.Username, notifyEnq.Sent[1].Labels["activated_account_name"])

// "Member" account suspended, "member" notified
require.Equal(t, notifications.TemplateUserAccountActivated, notifyEnq.Sent[2].TemplateID)
require.Equal(t, notifications.TemplateYourAccountActivated, notifyEnq.Sent[2].TemplateID)
require.Equal(t, member.ID, notifyEnq.Sent[2].UserID)
require.Contains(t, notifyEnq.Sent[2].Targets, member.ID)
require.Equal(t, member.Username, notifyEnq.Sent[2].Labels["activated_account_name"])
Expand Down
Loading