@@ -1224,9 +1224,14 @@ def test_mark_all_read_only_affects_own_notifications(
12241224 })
12251225 assert b_create .status_code == 201
12261226
1227+ b_before = second_user_session .get (f'{ api_client } /api/notifications' )
1228+ b_unread_count = sum (1 for n in b_before .json ()['notifications' ] if n ['unread' ])
1229+
12271230 mark_resp = second_user_session .put (f'{ api_client } /api/notifications/mark-all-read' )
12281231 assert mark_resp .status_code == 200
1229- assert mark_resp .json ()['count' ] == 1 , "Expected exactly User B's 1 notification to be updated"
1232+ assert mark_resp .json ()['count' ] == b_unread_count , (
1233+ "Expected exactly User B's own unread notifications to be updated"
1234+ )
12301235
12311236 check = authenticated_session .get (f'{ api_client } /api/notifications' )
12321237 notifs = check .json ()['notifications' ]
@@ -1255,9 +1260,15 @@ def test_delete_all_only_affects_own_notifications(
12551260 'subject' : 'User B to delete' ,
12561261 'message' : 'User B notification' ,
12571262 })
1263+
1264+ b_before = second_user_session .get (f'{ api_client } /api/notifications' )
1265+ b_notif_count = len (b_before .json ()['notifications' ])
1266+
12581267 delete_resp = second_user_session .delete (f'{ api_client } /api/notifications/delete-all' )
12591268 assert delete_resp .status_code == 200
1260- assert delete_resp .json ()['count' ] == 1 , "Expected exactly User B's 1 notification to be deleted"
1269+ assert delete_resp .json ()['count' ] == b_notif_count , (
1270+ "Expected exactly User B's own notifications to be deleted"
1271+ )
12611272
12621273 check = authenticated_session .get (f'{ api_client } /api/notifications' )
12631274 notifs = check .json ()['notifications' ]
@@ -1266,6 +1277,29 @@ def test_delete_all_only_affects_own_notifications(
12661277 )
12671278
12681279
1280+ @pytest .mark .api
1281+ class TestMobileAppInstallNotification :
1282+ """Regression test for Issue 514: new users get a mobile app install notification."""
1283+
1284+ def test_new_user_receives_mobile_app_install_notification (
1285+ self , api_client , second_user_session
1286+ ):
1287+ """A freshly registered user should have the 'Install AFT as an app' notification."""
1288+ response = second_user_session .get (f'{ api_client } /api/notifications' )
1289+ assert response .status_code == 200
1290+
1291+ notifications = response .json ()['notifications' ]
1292+ install_notif = next (
1293+ (n for n in notifications if n ['subject' ] == 'Install AFT as an app' ), None
1294+ )
1295+ assert install_notif is not None , (
1296+ f"Expected an 'Install AFT as an app' notification for a new user, "
1297+ f"but found subjects: { [n .get ('subject' ) for n in notifications ]} "
1298+ )
1299+ assert install_notif ['unread' ] is True
1300+ assert install_notif ['action_url' ] == '/settings.html'
1301+
1302+
12691303@pytest .mark .api
12701304class TestNotificationMultiUserCreation :
12711305 """Test cases for admin creating notifications for all users."""
0 commit comments