fix: use dedicated Twilio fields and add service switch case tests

- Added `accountSid` and `twilioPhoneNumber` fields to Notification
  type, MongoDB model, and frontend type instead of reusing
  `address` and `homeserverUrl`
- Updated provider, validation, form hook, and form UI to use new fields
- Added Pushover and Twilio to notificationsService routing tests
  (both handleNotifications and sendTestNotification)
- All 59 tests passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
egeoztassandClaude Opus 4.6 committed 2026-04-17 23:11:11 +03:00
1 parent 9210259511
commit d5d6797f91
10 files changed
+40 -27

No files matched your search

+2 -2
View File
@@ -64,10 +64,10 @@ function buildDefaults(data: Notification | null): NotificationFormData {
return {
type: "twilio",
notificationName: data.notificationName || "",
address: data.address || "",
accountSid: data.accountSid || "",
accessToken: data.accessToken || "",
phone: data.phone || "",
homeserverUrl: data.homeserverUrl || "",
twilioPhoneNumber: data.twilioPhoneNumber || "",
};
}
if (data?.type === "pushover") {
@@ -270,9 +270,9 @@ const NotificationsCreatePage = () => {
rightContent={
<Stack spacing={theme.spacing(8)}>
<Controller
name="address"
name="accountSid"
control={control}
defaultValue={"address" in defaults ? defaults.address : ""}
defaultValue={"accountSid" in defaults ? defaults.accountSid : ""}
render={({ field, fieldState }) => (
<TextField
{...field}
@@ -306,9 +306,11 @@ const NotificationsCreatePage = () => {
)}
/>
<Controller
name="homeserverUrl"
name="twilioPhoneNumber"
control={control}
defaultValue={"homeserverUrl" in defaults ? defaults.homeserverUrl : ""}
defaultValue={
"twilioPhoneNumber" in defaults ? defaults.twilioPhoneNumber : ""
}
render={({ field, fieldState }) => (
<TextField
{...field}
+2
View File
@@ -23,6 +23,8 @@ export interface Notification {
homeserverUrl?: string;
roomId?: string;
accessToken?: string;
accountSid?: string;
twilioPhoneNumber?: string;
createdAt: string;
updatedAt: string;
}
+2 -2
View File
@@ -64,10 +64,10 @@ const pushoverSchema = baseSchema.extend({
const twilioSchema = baseSchema.extend({
type: z.literal("twilio"),
address: z.string().min(1, "Account SID is required"),
accountSid: z.string().min(1, "Account SID is required"),
accessToken: z.string().min(1, "Auth token is required"),
phone: z.string().min(1, "Recipient phone number is required"),
homeserverUrl: z.string().min(1, "Twilio phone number is required"),
twilioPhoneNumber: z.string().min(1, "Twilio phone number is required"),
});
export const notificationSchema = z.discriminatedUnion("type", [