@@ -14,13 +14,17 @@ vi.mock('../../lib/api', () => ({
1414 deleteNotificationApiV1NotificationsNotificationIdDelete : ( ...args : unknown [ ] ) => mockDeleteNotification ( ...args ) ,
1515} ) ) ;
1616
17- const createMockNotification = ( overrides = { } ) => ( {
17+ const createMockNotification = ( overrides : Record < string , unknown > = { } ) => ( {
1818 notification_id : `notif-${ Math . random ( ) . toString ( 36 ) . slice ( 2 ) } ` ,
19- title : 'Test Notification' ,
20- message : 'Test message' ,
21- status : 'unread' as const ,
19+ channel : 'in_app' as const ,
20+ status : 'pending' as const ,
21+ subject : 'Test Notification' ,
22+ body : 'Test message body' ,
23+ action_url : null ,
2224 created_at : new Date ( ) . toISOString ( ) ,
23- tags : [ ] ,
25+ read_at : null ,
26+ severity : 'medium' as const ,
27+ tags : [ ] as string [ ] ,
2428 ...overrides ,
2529} ) ;
2630
@@ -74,8 +78,8 @@ describe('notificationStore', () => {
7478
7579 it ( 'populates notifications on success' , async ( ) => {
7680 const notifications = [
77- createMockNotification ( { notification_id : 'n1' , title : 'First' } ) ,
78- createMockNotification ( { notification_id : 'n2' , title : 'Second' } ) ,
81+ createMockNotification ( { notification_id : 'n1' , subject : 'First' } ) ,
82+ createMockNotification ( { notification_id : 'n2' , subject : 'Second' } ) ,
7983 ] ;
8084 mockGetNotifications . mockResolvedValue ( {
8185 data : { notifications } ,
@@ -86,7 +90,7 @@ describe('notificationStore', () => {
8690 await notificationStore . load ( ) ;
8791
8892 expect ( get ( notificationStore ) . notifications ) . toHaveLength ( 2 ) ;
89- expect ( get ( notificationStore ) . notifications [ 0 ] . title ) . toBe ( 'First' ) ;
93+ expect ( get ( notificationStore ) . notifications [ 0 ] . subject ) . toBe ( 'First' ) ;
9094 } ) ;
9195
9296 it ( 'sets loading false after success' , async ( ) => {
@@ -186,7 +190,7 @@ describe('notificationStore', () => {
186190 const { notificationStore } = await import ( '../notificationStore' ) ;
187191 await notificationStore . load ( ) ;
188192
189- const newNotification = createMockNotification ( { notification_id : 'new' , title : 'New' } ) ;
193+ const newNotification = createMockNotification ( { notification_id : 'new' , subject : 'New' } ) ;
190194 notificationStore . add ( newNotification ) ;
191195
192196 const notifications = get ( notificationStore ) . notifications ;
@@ -218,7 +222,7 @@ describe('notificationStore', () => {
218222 mockGetNotifications . mockResolvedValue ( {
219223 data : {
220224 notifications : [
221- createMockNotification ( { notification_id : 'n1' , status : 'unread ' } ) ,
225+ createMockNotification ( { notification_id : 'n1' , status : 'pending ' } ) ,
222226 ] ,
223227 } ,
224228 error : null ,
@@ -247,7 +251,7 @@ describe('notificationStore', () => {
247251 const result = await notificationStore . markAsRead ( 'n1' ) ;
248252
249253 expect ( result ) . toBe ( false ) ;
250- expect ( get ( notificationStore ) . notifications [ 0 ] . status ) . toBe ( 'unread ' ) ;
254+ expect ( get ( notificationStore ) . notifications [ 0 ] . status ) . toBe ( 'pending ' ) ;
251255 } ) ;
252256
253257 it ( 'calls API with correct notification ID' , async ( ) => {
@@ -267,8 +271,8 @@ describe('notificationStore', () => {
267271 mockGetNotifications . mockResolvedValue ( {
268272 data : {
269273 notifications : [
270- createMockNotification ( { notification_id : 'n1' , status : 'unread ' } ) ,
271- createMockNotification ( { notification_id : 'n2' , status : 'unread ' } ) ,
274+ createMockNotification ( { notification_id : 'n1' , status : 'pending ' } ) ,
275+ createMockNotification ( { notification_id : 'n2' , status : 'pending ' } ) ,
272276 ] ,
273277 } ,
274278 error : null ,
@@ -390,9 +394,9 @@ describe('notificationStore', () => {
390394 mockGetNotifications . mockResolvedValue ( {
391395 data : {
392396 notifications : [
393- createMockNotification ( { notification_id : 'n1' , status : 'unread ' } ) ,
397+ createMockNotification ( { notification_id : 'n1' , status : 'pending ' } ) ,
394398 createMockNotification ( { notification_id : 'n2' , status : 'read' } ) ,
395- createMockNotification ( { notification_id : 'n3' , status : 'unread ' } ) ,
399+ createMockNotification ( { notification_id : 'n3' , status : 'pending ' } ) ,
396400 ] ,
397401 } ,
398402 error : null ,
@@ -424,7 +428,7 @@ describe('notificationStore', () => {
424428 mockGetNotifications . mockResolvedValue ( {
425429 data : {
426430 notifications : [
427- createMockNotification ( { notification_id : 'n1' , status : 'unread ' } ) ,
431+ createMockNotification ( { notification_id : 'n1' , status : 'pending ' } ) ,
428432 ] ,
429433 } ,
430434 error : null ,
@@ -443,8 +447,8 @@ describe('notificationStore', () => {
443447 describe ( 'notifications derived store' , ( ) => {
444448 it ( 'exposes notifications array' , async ( ) => {
445449 const notifs = [
446- createMockNotification ( { notification_id : 'n1' , title : 'First' } ) ,
447- createMockNotification ( { notification_id : 'n2' , title : 'Second' } ) ,
450+ createMockNotification ( { notification_id : 'n1' , subject : 'First' } ) ,
451+ createMockNotification ( { notification_id : 'n2' , subject : 'Second' } ) ,
448452 ] ;
449453 mockGetNotifications . mockResolvedValue ( {
450454 data : { notifications : notifs } ,
@@ -455,7 +459,7 @@ describe('notificationStore', () => {
455459 await notificationStore . load ( ) ;
456460
457461 expect ( get ( notifications ) ) . toHaveLength ( 2 ) ;
458- expect ( get ( notifications ) [ 0 ] . title ) . toBe ( 'First' ) ;
462+ expect ( get ( notifications ) [ 0 ] . subject ) . toBe ( 'First' ) ;
459463 } ) ;
460464 } ) ;
461465} ) ;
0 commit comments