-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix escape characters of events when dry running
JSONEditor double escapes escape characters to properly display them in the UI, however when dry running Agents we actually need to send the Event's characters as they were. Before an event containing new lines like this `Line A\nLineB` would be send as `Line A\\nLineB` to the backend. By replacing the double escaped slashes we ensure the event is handled as it would be when not dry running. #1677
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rails_helper' | ||
|
||
describe "Dry running an Agent", js: true do | ||
let(:formatting_agent) { agents(:bob_formatting_agent) } | ||
let(:user) { users(:bob) } | ||
let(:emitter) { agents(:bob_weather_agent) } | ||
|
||
before(:each) do | ||
login_as(user) | ||
end | ||
|
||
def open_dry_run_modal(agent) | ||
visit edit_agent_path(agent) | ||
click_on("Dry Run") | ||
expect(page).to have_text('Event to send') | ||
end | ||
|
||
context 'successful dry runs' do | ||
it 'sends escape characters correctly to the backend' do | ||
emitter.events << Event.new(payload: {data: "Line 1\nLine 2\nLine 3"}) | ||
formatting_agent.sources << emitter | ||
formatting_agent.options.merge!('instructions' => {'data' => "{{data | newline_to_br | strip_newlines | split: '<br />' | join: ','}}"}) | ||
formatting_agent.save! | ||
|
||
open_dry_run_modal(formatting_agent) | ||
find('.dry-run-event-sample').click | ||
within(:css, '.modal .builder') do | ||
expect(page).to have_text('Line 1\nLine 2\nLine 3') | ||
end | ||
click_on("Dry Run") | ||
expect(page).to have_text('Line 1,Line 2,Line 3') | ||
expect(page).to have_selector(:css, 'li[role="presentation"].active a[href="#tabEvents"]') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters