From 288df3a3996e09b402508cb7473645890329a6bf Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 12 Jun 2025 02:05:34 -0400 Subject: [PATCH] fix: Flaky Instagram unsend message test (#11712) - Use direct message object reference instead of re-querying through inbox - Add message.reload after unsend operation to get updated state - Remove unnecessary inbox reload that could cause timing issues - Remove redundant assertions for better test atomicity Co-authored-by: Muhsin Keloth --- spec/jobs/webhooks/instagram_events_job_spec.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/jobs/webhooks/instagram_events_job_spec.rb b/spec/jobs/webhooks/instagram_events_job_spec.rb index 23e7f9e5a..dfd9f1aed 100644 --- a/spec/jobs/webhooks/instagram_events_job_spec.rb +++ b/spec/jobs/webhooks/instagram_events_job_spec.rb @@ -234,16 +234,15 @@ describe Webhooks::InstagramEventsJob do account_id: instagram_inbox.account_id ) - instagram_inbox.reload - expect(instagram_inbox.messages.count).to be 1 instagram_webhook.perform_now(message_events[:unsend][:entry]) - expect(instagram_inbox.messages.last.content).to eq 'This message was deleted' - expect(instagram_inbox.messages.last.deleted).to be true - expect(instagram_inbox.messages.last.attachments.count).to be 0 - expect(instagram_inbox.messages.last.reload.deleted).to be true + message.reload + + expect(message.content).to eq 'This message was deleted' + expect(message.deleted).to be true + expect(message.attachments.count).to be 0 end it 'creates incoming message with attachments in the instagram direct inbox' do