@@ -93,10 +93,12 @@ tests s =
93
93
test s " Fetch all notifications" testFetchAllNotifs,
94
94
test s " Fetch new notifications" testFetchNewNotifs,
95
95
test s " No new notifications" testNoNewNotifs,
96
- test s " Missing notifications" testMissingNotifs,
96
+ test s " Missing notifications (until API Version 3)" testMissingNotifsV2,
97
+ test s " Missing notifications (from API Version 3)" testMissingNotifsV3,
97
98
test s " Fetch last notification" testFetchLastNotif,
98
99
test s " No last notification" testNoLastNotif,
99
- test s " Bad 'since' parameter" testFetchNotifBadSince,
100
+ test s " Bad 'since' parameter (until API Version 3)" testFetchNotifBadSinceV2,
101
+ test s " Bad 'since' parameter (from API Version 3)" testFetchNotifBadSinceV3,
100
102
test s " Fetch notification by ID" testFetchNotifById,
101
103
test s " Filter notifications by client" testFilterNotifByClient,
102
104
test s " Paging" testNotificationPaging
@@ -482,7 +484,7 @@ testFetchNewNotifs = do
482
484
get
483
485
( runGundeckR gu
484
486
. zUser ally
485
- . path " notifications"
487
+ . paths [ " v3 " , " notifications" ]
486
488
. query [(" since" , Just (toByteString' (ns !! 1 )))]
487
489
)
488
490
!!! do
@@ -498,31 +500,40 @@ testNoNewNotifs = do
498
500
get
499
501
( runGundeckR gu
500
502
. zUser ally
501
- . path " notifications"
503
+ . paths [ " v3 " , " notifications" ]
502
504
. query [(" since" , Just (toByteString' n))]
503
505
)
504
506
!!! do
505
507
const 200 === statusCode
506
508
const (Just [] ) === parseNotificationIds
507
509
508
- testMissingNotifs :: TestM ()
509
- testMissingNotifs = do
510
- gu <- view tsGundeck
511
- other <- randomId
512
- sendPush (buildPush other [(other, RecipientClientsAll )] (textPayload " hello" ))
513
- (old : _) <- map (view queuedNotificationId) <$> listNotifications other Nothing
514
- ally <- randomId
515
- sendPush (buildPush ally [(ally, RecipientClientsAll )] (textPayload " hello" ))
516
- ns <- listNotifications ally Nothing
517
- get
518
- ( runGundeckR gu
519
- . zUser ally
520
- . path " notifications"
521
- . query [(" since" , Just (toByteString' old))]
522
- )
523
- !!! do
524
- const 404 === statusCode
525
- const (Just ns) === parseNotifications
510
+ testMissingNotifsV2 :: TestM ()
511
+ testMissingNotifsV2 = do
512
+ testMissingNotifs " v2" $ \ ns -> do
513
+ const 404 === statusCode
514
+ const (Just ns) === parseNotifications
515
+
516
+ testMissingNotifsV3 :: TestM ()
517
+ testMissingNotifsV3 =
518
+ testMissingNotifs " v2" $ const $ const 404 === statusCode
519
+
520
+ testMissingNotifs :: ByteString -> ([QueuedNotification ] -> Assertions () ) -> TestM ()
521
+ testMissingNotifs version checks =
522
+ do
523
+ gu <- view tsGundeck
524
+ other <- randomId
525
+ sendPush (buildPush other [(other, RecipientClientsAll )] (textPayload " hello" ))
526
+ (old : _) <- map (view queuedNotificationId) <$> listNotifications other Nothing
527
+ ally <- randomId
528
+ sendPush (buildPush ally [(ally, RecipientClientsAll )] (textPayload " hello" ))
529
+ ns <- listNotifications ally Nothing
530
+ get
531
+ ( runGundeckR gu
532
+ . zUser ally
533
+ . paths [version, " notifications" ]
534
+ . query [(" since" , Just (toByteString' old))]
535
+ )
536
+ !!! checks ns
526
537
527
538
testFetchLastNotif :: TestM ()
528
539
testFetchLastNotif = do
@@ -543,8 +554,22 @@ testNoLastNotif = do
543
554
const 404 === statusCode
544
555
const (Just " not-found" ) =~= responseBody
545
556
546
- testFetchNotifBadSince :: TestM ()
547
- testFetchNotifBadSince = do
557
+ testFetchNotifBadSinceV3 :: TestM ()
558
+ testFetchNotifBadSinceV3 = do
559
+ gu <- view tsGundeck
560
+ ally <- randomId
561
+ sendPush (buildPush ally [(ally, RecipientClientsAll )] (textPayload " first" ))
562
+ get
563
+ ( runGundeckR gu
564
+ . zUser ally
565
+ . paths [" v3" , " notifications" ]
566
+ . query [(" since" , Just " jumberjack" )]
567
+ )
568
+ !!! do
569
+ const 400 === statusCode
570
+
571
+ testFetchNotifBadSinceV2 :: TestM ()
572
+ testFetchNotifBadSinceV2 = do
548
573
gu <- view tsGundeck
549
574
ally <- randomId
550
575
sendPush (buildPush ally [(ally, RecipientClientsAll )] (textPayload " first" ))
@@ -712,7 +737,7 @@ testNotificationPaging = do
712
737
maybe id (queryItem " client" . toByteString') c
713
738
. maybe id (queryItem " since" . toByteString') start
714
739
. queryItem " size" (toByteString' step)
715
- r <- get (runGundeckR gu . path " / notifications" . zUser u . range) <!! const 200 === statusCode
740
+ r <- get (runGundeckR gu . paths [ " v3 " , " notifications" ] . zUser u . range) <!! const 200 === statusCode
716
741
let rs = decode =<< responseBody r
717
742
let (ns, more) = (fmap (view queuedNotifications) &&& fmap (view queuedHasMore)) rs
718
743
let count' = count + step
@@ -1093,7 +1118,7 @@ getNotifications u c =
1093
1118
get $
1094
1119
runGundeckR gu
1095
1120
. zUser u
1096
- . path " notifications"
1121
+ . paths [ " v3 " , " notifications" ]
1097
1122
. maybe id (queryItem " client" . toByteString') c
1098
1123
1099
1124
getLastNotification :: UserId -> Maybe ClientId -> TestM (Response (Maybe BL. ByteString ))
0 commit comments