Skip to content

feat: add Notification module tests and scaffolding (framework#1524) - #141

Merged
hwbrzzl merged 3 commits into
masterfrom
bowen/notification-tests
Aug 16, 2026
Merged

feat: add Notification module tests and scaffolding (framework#1524)#141
hwbrzzl merged 3 commits into
masterfrom
bowen/notification-tests

Conversation

@goravel-coder

@goravel-coder goravel-coder commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wire the Notification module into the example app: facades.Notification() facade, notification.ServiceProvider, example mail/database/queued notifications, and a notifiable User via RouteNotificationFor
  • Add a notifications table migration so database-channel notifications persist alongside the example's other tables
  • Add a 16-test feature suite covering send flows, custom channels, should-send/after-sending hooks, mail delivery, and artisan commands — mail sends are distinguishable because the OrderShipped subject embeds the order ID and mail tests share a mailRecipient() helper

Why

Adds full user-facing test coverage for the Notification module shipped with the pinned framework (goravel/framework#1524). The example app now wires facades.Notification() and notification.ServiceProvider, ships three ready-to-use example notifications (mail, database, and queued), makes User notifiable via RouteNotificationFor, and persists database-channel notifications in a new notifications migration.

The 16-test feature suite asserts user-visible outcomes — persisted rows in the notifications table, successful sends, channel skipping, and command-generated files. The mail tests were refined so each send is identifiable: OrderShipped.ToMail now embeds the order ID in the subject (matching the HTML body), and both mail tests resolve their recipient through a shared mailRecipient() helper that skips when MAIL_HOST is unset.

// app/notifications/order_shipped.go
func (r *OrderShipped) ToMail(notifiable notification.Notifiable) notification.MailMessage {
	return mail.NewMessage().
		Subject("Order " + r.OrderID + " has shipped").
		Html("<p>Order " + r.OrderID + " has shipped.</p>").
		Build()
}

// Send from a controller
if err := facades.Notification().Send(user, notifications.NewOrderShipped(orderID)); err != nil {
	return ctx.Response().Json(http.StatusInternalServerError, http.Json{"error": err.Error()})
}

@goravel-coder
goravel-coder requested a review from a team as a code owner August 15, 2026 04:50
Comment thread app/models/user.go Outdated
Comment thread tests/feature/notification_test.go
Comment thread tests/feature/notification_test.go
Comment thread tests/feature/notification_test.go
Comment thread tests/feature/notification_test.go
Comment thread tests/feature/notification_test.go
Comment thread tests/feature/notification_test.go
@hwbrzzl
hwbrzzl merged commit b85b300 into master Aug 16, 2026
9 checks passed
@hwbrzzl
hwbrzzl deleted the bowen/notification-tests branch August 16, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants