Skip to content

feat(coderd): add inbox notifications endpoints #16889

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 18 commits into from
Mar 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make fmt and lint
  • Loading branch information
defelmnq committed Mar 14, 2025
commit 736a2d73c839ee412a7ed3705d1f3e05ee5ae4e9
44 changes: 22 additions & 22 deletions coderd/inboxnotifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ func TestInboxNotification_Watch(t *testing.T) {

dispatchFunc(ctx, uuid.New())

_, message, err := wsConn.Read(ctx)
require.NoError(t, err)

var notif codersdk.GetInboxNotificationResponse
err = json.Unmarshal(message, &notif)
require.NoError(t, err)

require.Equal(t, 1, notif.UnreadCount)
require.Equal(t, memberClient.ID, notif.Notification.UserID)
require.Equal(t, "memory related title", notif.Notification.Title)

dispatchFunc, err = inboxHandler.Dispatcher(types.MessagePayload{
UserID: memberClient.ID.String(),
NotificationTemplateID: notifications.TemplateWorkspaceOutOfDisk.String(),
Expand All @@ -183,17 +194,6 @@ func TestInboxNotification_Watch(t *testing.T) {

dispatchFunc(ctx, uuid.New())

_, message, err := wsConn.Read(ctx)
require.NoError(t, err)

var notif codersdk.GetInboxNotificationResponse
err = json.Unmarshal(message, &notif)
require.NoError(t, err)

require.Equal(t, 3, notif.UnreadCount)
require.Equal(t, memberClient.ID, notif.Notification.UserID)
require.Equal(t, "memory related title", notif.Notification.Title)

_, message, err = wsConn.Read(ctx)
require.NoError(t, err)

Expand Down Expand Up @@ -249,6 +249,17 @@ func TestInboxNotification_Watch(t *testing.T) {

dispatchFunc(ctx, uuid.New())

_, message, err := wsConn.Read(ctx)
require.NoError(t, err)

var notif codersdk.GetInboxNotificationResponse
err = json.Unmarshal(message, &notif)
require.NoError(t, err)

require.Equal(t, 1, notif.UnreadCount)
require.Equal(t, memberClient.ID, notif.Notification.UserID)
require.Equal(t, "memory related title", notif.Notification.Title)

dispatchFunc, err = inboxHandler.Dispatcher(types.MessagePayload{
UserID: memberClient.ID.String(),
NotificationTemplateID: notifications.TemplateWorkspaceOutOfMemory.String(),
Expand All @@ -267,17 +278,6 @@ func TestInboxNotification_Watch(t *testing.T) {

dispatchFunc(ctx, uuid.New())

_, message, err := wsConn.Read(ctx)
require.NoError(t, err)

var notif codersdk.GetInboxNotificationResponse
err = json.Unmarshal(message, &notif)
require.NoError(t, err)

require.Equal(t, 3, notif.UnreadCount)
require.Equal(t, memberClient.ID, notif.Notification.UserID)
require.Equal(t, "memory related title", notif.Notification.Title)

_, message, err = wsConn.Read(ctx)
require.NoError(t, err)

Expand Down
Loading