From c2f3bad6ae6ea25605e2f995c5777debb97bb53f Mon Sep 17 00:00:00 2001 From: Sawy Date: Tue, 5 Nov 2024 18:00:12 +0200 Subject: [PATCH] CV2-5621: add missing tests 2/2 --- test/models/bot/smooch_6_test.rb | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/models/bot/smooch_6_test.rb b/test/models/bot/smooch_6_test.rb index 08df08150..f46cc3f7d 100644 --- a/test/models/bot/smooch_6_test.rb +++ b/test/models/bot/smooch_6_test.rb @@ -970,12 +970,14 @@ def send_message_outside_24_hours_window(template, pm = nil) test "should get dynamic resource on tipline bot v2" do WebMock.stub_request(:get, /googleapis\.com\/civicinfo/).to_return(body: { pollingLocations: [{ address: {} }], earlyVoteSites: [{ address: {} }] }.to_json) - @resource.content_type = 'dynamic' - @resource.save! - send_message 'hello', '1', '4' - assert_state 'resource_waiting_for_user_input' - send_message '972 Mission St San Francisco CA' - assert_state 'waiting_for_message' + stub_configs({ 'google_api_key' => random_string }) do + @resource.content_type = 'dynamic' + @resource.save! + send_message 'hello', '1', '4' + assert_state 'resource_waiting_for_user_input' + send_message '972 Mission St San Francisco CA' + assert_state 'waiting_for_message' + end end test "should not get dynamic resource on tipline bot v2 if resource is not available anymore" do @@ -990,11 +992,13 @@ def send_message_outside_24_hours_window(template, pm = nil) test "should not get dynamic resource on tipline bot v2 if external API returns an error" do WebMock.stub_request(:get, /googleapis\.com\/civicinfo/).to_return(body: { pollingLocations: 'Some error' }.to_json) - @resource.content_type = 'dynamic' - @resource.save! - send_message 'hello', '1', '4' - assert_state 'resource_waiting_for_user_input' - send_message '972 Mission St San Francisco CA' - assert_state 'waiting_for_message' + stub_configs({ 'google_api_key' => random_string }) do + @resource.content_type = 'dynamic' + @resource.save! + send_message 'hello', '1', '4' + assert_state 'resource_waiting_for_user_input' + send_message '972 Mission St San Francisco CA' + assert_state 'waiting_for_message' + end end end