feat(sms): CLI list --type/--phones + notification sms group + channel-aware recipients (S6)

This commit is contained in:
Joseph Doherty
2026-06-19 10:40:09 -04:00
parent cdfd0ffbd2
commit 73df322a66
7 changed files with 638 additions and 37 deletions
@@ -1365,6 +1365,43 @@ public class ManagementActorTests : TestKit, IDisposable
Assert.Equal(Commons.Types.Enums.NotificationType.Sms, added!.Type);
}
[Fact]
public void CreateNotificationList_WithSmsTypeAndPhones_PersistsForSmsRecipients()
{
// S6: an SMS list builds recipients from RecipientPhones via NotificationRecipient.ForSms
// — PhoneNumber set, EmailAddress null (the off-channel RecipientEmails list is ignored).
var notifRepo = Substitute.For<INotificationRepository>();
Commons.Entities.Notifications.NotificationList? added = null;
notifRepo.When(r => r.AddNotificationListAsync(
Arg.Any<Commons.Entities.Notifications.NotificationList>(), Arg.Any<CancellationToken>()))
.Do(ci => added = ci.Arg<Commons.Entities.Notifications.NotificationList>());
_services.AddScoped(_ => notifRepo);
var actor = CreateActor();
var envelope = Envelope(
new CreateNotificationListCommand(
"Ops SMS",
Array.Empty<string>(),
Commons.Types.Enums.NotificationType.Sms,
new[] { "+15551230000", "+15551230001" }),
"Designer");
actor.Tell(envelope);
var response = ExpectMsg<ManagementSuccess>(TimeSpan.FromSeconds(5));
Assert.Equal(envelope.CorrelationId, response.CorrelationId);
Assert.NotNull(added);
Assert.Equal(Commons.Types.Enums.NotificationType.Sms, added!.Type);
Assert.Equal(2, added.Recipients.Count);
Assert.All(added.Recipients, r =>
{
Assert.Null(r.EmailAddress);
Assert.NotNull(r.PhoneNumber);
});
Assert.Equal(new[] { "+15551230000", "+15551230001" },
added.Recipients.Select(r => r.PhoneNumber).ToArray());
}
[Fact]
public void CreateNotificationList_DefaultType_IsEmail()
{