Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to handle browser JSON responses more robustly #3305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions test/system/alpha/action_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ def test_single_select_form_submission

find("input[type=submit]").click

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "fast_forward", response["value"]
end

Expand All @@ -417,8 +416,7 @@ def test_single_select_form_uses_label_if_no_value_provided

find("input[type=submit]").click

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "Resolve", response["value"]
end

Expand All @@ -434,8 +432,7 @@ def test_multiple_select_form_submission

find("input[type=submit]").click

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)

# "ours" is pre-selected
assert_equal %w[fast_forward recursive ours], response["value"]
Expand All @@ -453,8 +450,7 @@ def test_multiple_select_form_uses_label_if_no_value_provided

find("input[type=submit]").click

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)

# "ours" is pre-selected
assert_equal %w[fast_forward ours Resolve], response["value"]
Expand All @@ -471,7 +467,7 @@ def test_individual_items_can_submit_post_requests_via_forms
click_on_invoker_button
click_on_fourth_item

response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "bar", response["value"]
end

Expand All @@ -481,8 +477,7 @@ def test_single_select_items_can_submit_forms
click_on_invoker_button
click_on_first_item

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "group-by-repository", response["value"]
end

Expand All @@ -494,8 +489,7 @@ def test_single_select_items_can_submit_forms_on_enter
# "click" first item
keyboard.type(:enter)

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "group-by-repository", response["value"]
end

Expand All @@ -507,8 +501,7 @@ def test_single_select_items_can_submit_forms_on_keydown_space
# "click" first item
keyboard.type(:space)

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "group-by-repository", response["value"]
end

Expand All @@ -518,8 +511,7 @@ def test_single_select_items_can_submit_forms_with_multiple_fields
click_on_invoker_button
click_on_first_item

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "query", response.dig("other_params", "query")
end

Expand Down
9 changes: 3 additions & 6 deletions test/system/alpha/select_panel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,7 @@ def test_single_select_form

click_on "Submit"

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "item2", response.dig(*%w(form_params item))
end

Expand All @@ -1232,8 +1231,7 @@ def test_single_select_form_submits_pre_selected_item
# the first item has been pre-selected, so there's no need to select any items
click_on "Submit"

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)
assert_equal "item1", response.dig(*%w(form_params item))
end

Expand All @@ -1246,8 +1244,7 @@ def test_multi_select_form

click_on "Submit"

# for some reason the JSON response is wrapped in HTML, I have no idea why
response = JSON.parse(find("pre").text)
response = JSON.parse(page.document.text)

# first item is pre-selected
assert_equal ["item1", "item2"], response.dig(*%w(form_params item))
Expand Down
Loading