From e1dbbf6c9db6dbf3f356dae4c59fa05299372370 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 25 Mar 2025 12:22:41 -0400 Subject: [PATCH] Isolate assertions in v2/notifications intermittent failure cases (#34271) --- spec/requests/api/v2/notifications_spec.rb | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/spec/requests/api/v2/notifications_spec.rb b/spec/requests/api/v2/notifications_spec.rb index a7608e1419..a434deaed9 100644 --- a/spec/requests/api/v2/notifications_spec.rb +++ b/spec/requests/api/v2/notifications_spec.rb @@ -158,14 +158,13 @@ RSpec.describe 'Notifications' do expect(response).to have_http_status(200) expect(response.content_type) .to start_with('application/json') - expect(response.parsed_body[:notification_groups]).to contain_exactly( - a_hash_including( - type: 'favourite', - sample_account_ids: have_attributes(size: 5), - page_min_id: notification_ids.first.to_s, - page_max_id: notification_ids.last.to_s - ) - ) + expect(response.parsed_body[:notification_groups].size) + .to eq(1) + expect(response.parsed_body.dig(:notification_groups, 0)) + .to include(type: 'favourite') + .and(include(sample_account_ids: have_attributes(size: 5))) + .and(include(page_max_id: notification_ids.last.to_s)) + .and(include(page_min_id: notification_ids.first.to_s)) end end @@ -180,14 +179,13 @@ RSpec.describe 'Notifications' do expect(response).to have_http_status(200) expect(response.content_type) .to start_with('application/json') - expect(response.parsed_body[:notification_groups]).to contain_exactly( - a_hash_including( - type: 'favourite', - sample_account_ids: have_attributes(size: 5), - page_min_id: notification_ids.first.to_s, - page_max_id: notification_ids.last.to_s - ) - ) + expect(response.parsed_body[:notification_groups].size) + .to eq(1) + expect(response.parsed_body.dig(:notification_groups, 0)) + .to include(type: 'favourite') + .and(include(sample_account_ids: have_attributes(size: 5))) + .and(include(page_max_id: notification_ids.last.to_s)) + .and(include(page_min_id: notification_ids.first.to_s)) end end end