From a861257f738e2c8fcda31c2c52d3a5f6685d8f72 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Wed, 24 Jan 2024 13:58:27 +0400 Subject: [PATCH] chore: Fix flaky contacts spec (#8773) - The ordering was not guaranteed; hence, the specs were failing randomly. Made changes to the expectations accordingly --- .../api/v1/accounts/contacts_controller_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/controllers/api/v1/accounts/contacts_controller_spec.rb b/spec/controllers/api/v1/accounts/contacts_controller_spec.rb index 7352b842f..ace9e8e03 100644 --- a/spec/controllers/api/v1/accounts/contacts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/contacts_controller_spec.rb @@ -36,9 +36,11 @@ RSpec.describe 'Contacts API', type: :request do expect(response).to have_http_status(:success) response_body = response.parsed_body - expect(response_body['payload'].first['email']).to eq(contact.email) - expect(response_body['payload'].first['contact_inboxes'].first['source_id']).to eq(contact_inbox.source_id) - expect(response_body['payload'].first['contact_inboxes'].first['inbox']['name']).to eq(contact_inbox.inbox.name) + contact_emails = response_body['payload'].pluck('email') + contact_inboxes_source_ids = response_body['payload'].flat_map { |c| c['contact_inboxes'].pluck('source_id') } + + expect(contact_emails).to include(contact.email) + expect(contact_inboxes_source_ids).to include(contact_inbox.source_id) end it 'returns all contacts without contact inboxes' do