Skip to content

Commit

Permalink
CV2-5621: add missing tests 2/2
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Nov 5, 2024
1 parent e04e1ca commit c2f3bad
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/models/bot/smooch_6_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit c2f3bad

Please sign in to comment.