@@ -101,6 +101,91 @@ describe('NotificationService Unit Tests', () => {
101101 } ) ;
102102 } ) ;
103103
104+ describe ( 'markAsRead' , ( ) => {
105+ it ( 'should POST per-id read=true entries with tenant header' , async ( ) => {
106+ mockApiClient . post . mockResolvedValue ( undefined ) ;
107+ const ids = [
108+ NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID ,
109+ NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID_2 ,
110+ ] ;
111+
112+ const result = await notificationService . markAsRead ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID , ids ) ;
113+
114+ expect ( mockApiClient . post ) . toHaveBeenCalledWith (
115+ NOTIFICATION_ENDPOINTS . UPDATE_READ ,
116+ {
117+ notifications : [
118+ { notificationId : NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID , read : true } ,
119+ { notificationId : NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID_2 , read : true } ,
120+ ] ,
121+ forceAllRead : false ,
122+ } ,
123+ { headers : TENANT_HEADER }
124+ ) ;
125+ expect ( result ) . toEqual ( { success : true , data : { notificationIds : ids , read : true } } ) ;
126+ } ) ;
127+
128+ it ( 'should propagate errors' , async ( ) => {
129+ mockApiClient . post . mockRejectedValue ( createMockError ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ) ;
130+
131+ await expect (
132+ notificationService . markAsRead ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID , [ NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID ] )
133+ ) . rejects . toThrow ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ;
134+ } ) ;
135+ } ) ;
136+
137+ describe ( 'markAsUnread' , ( ) => {
138+ it ( 'should POST per-id read=false entries with tenant header' , async ( ) => {
139+ mockApiClient . post . mockResolvedValue ( undefined ) ;
140+ const ids = [ NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID ] ;
141+
142+ const result = await notificationService . markAsUnread ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID , ids ) ;
143+
144+ expect ( mockApiClient . post ) . toHaveBeenCalledWith (
145+ NOTIFICATION_ENDPOINTS . UPDATE_READ ,
146+ {
147+ notifications : [
148+ { notificationId : NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID , read : false } ,
149+ ] ,
150+ forceAllRead : false ,
151+ } ,
152+ { headers : TENANT_HEADER }
153+ ) ;
154+ expect ( result ) . toEqual ( { success : true , data : { notificationIds : ids , read : false } } ) ;
155+ } ) ;
156+
157+ it ( 'should propagate errors' , async ( ) => {
158+ mockApiClient . post . mockRejectedValue ( createMockError ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ) ;
159+
160+ await expect (
161+ notificationService . markAsUnread ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID , [ NOTIFICATION_TEST_CONSTANTS . NOTIFICATION_ID ] )
162+ ) . rejects . toThrow ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ;
163+ } ) ;
164+ } ) ;
165+
166+ describe ( 'markAllAsRead' , ( ) => {
167+ it ( 'should POST forceAllRead=true with empty notifications array and tenant header' , async ( ) => {
168+ mockApiClient . post . mockResolvedValue ( undefined ) ;
169+
170+ const result = await notificationService . markAllAsRead ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID ) ;
171+
172+ expect ( mockApiClient . post ) . toHaveBeenCalledWith (
173+ NOTIFICATION_ENDPOINTS . UPDATE_READ ,
174+ { notifications : [ ] , forceAllRead : true } ,
175+ { headers : TENANT_HEADER }
176+ ) ;
177+ expect ( result ) . toEqual ( { success : true , data : { all : true , read : true } } ) ;
178+ } ) ;
179+
180+ it ( 'should propagate errors' , async ( ) => {
181+ mockApiClient . post . mockRejectedValue ( createMockError ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ) ;
182+
183+ await expect (
184+ notificationService . markAllAsRead ( NOTIFICATION_TEST_CONSTANTS . TENANT_ID )
185+ ) . rejects . toThrow ( NOTIFICATION_TEST_CONSTANTS . ERROR_NOTIFICATION_NOT_FOUND ) ;
186+ } ) ;
187+ } ) ;
188+
104189 describe ( 'response transformation' , ( ) => {
105190 it ( 'strips internal fields and renames isRead → hasRead in the returned notifications' , async ( ) => {
106191 const raw : RawNotificationEntry = createBasicNotificationEntry ( ) ;
0 commit comments