Skip to content

Commit

Permalink
Fix linting and test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron committed May 17, 2024
1 parent 773bd6e commit 105c86e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 0 additions & 2 deletions demo/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
config.autoload_paths << Rails.root.join("..", "test", "forms")
config.view_component.preview_paths << Rails.root.join("..", "test", "previews")

# rubocop:disable Style/IfUnlessModifier
if ENV.fetch("VC_COMPAT_PATCH_ENABLED", "false") == "true"
config.view_component.capture_compatibility_patch_enabled = true
end
# rubocop:enable Style/IfUnlessModifier
end
2 changes: 1 addition & 1 deletion test/components/alpha/toggle_switch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_small
def test_csrf_token
render_inline(Primer::Alpha::ToggleSwitch.new(src: "/foo", csrf_token: "abc123"))

assert_selector("[csrf]")
assert_selector("[data-csrf]")
end
end
end
Expand Down
13 changes: 3 additions & 10 deletions test/lib/primer/forms/integration_forms_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,12 @@ def test_toggle_switch_form_errors
wait_for_toggle_switch_spinner

assert_selector("#error-toggle [data-target='toggle-switch.errorIcon']")
assert_selector(".FormControl-inlineValidation", text: "Bad CSRF token")
assert_selector(".FormControl-inlineValidation", text: "Something went wrong.")

page.evaluate_script(<<~JAVASCRIPT)
document
.querySelector('toggle-switch#error-toggle')
.setAttribute('csrf', 'let_me_in');
JAVASCRIPT

find("#error-toggle").click
find("#success-toggle").click
wait_for_toggle_switch_spinner

refute_selector("#error-toggle [data-target='toggle-switch.errorIcon']")
refute_selector("#error-toggle", text: "Bad CSRF token")
refute_selector("#success-toggle [data-target='toggle-switch.errorIcon']")
end

def test_action_menu_form_input
Expand Down
13 changes: 9 additions & 4 deletions test/lib/primer/forms/toggle_switch_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
class Primer::Forms::ToggleSwitchFormTest < Minitest::Test
include Primer::ComponentTestHelpers

def test_it_renders_with_a_name
bogus_csrf = "let me in"
render_inline(ExampleToggleSwitchForm.new(csrf: bogus_csrf, src: "/toggle_switch"))
def test_it_renders
render_inline(ExampleToggleSwitchForm.new(src: "/toggle_switch"))

assert_selector "toggle-switch[src='/toggle_switch'][csrf='#{bogus_csrf}']"
assert_selector "toggle-switch[src='/toggle_switch']"
assert_selector "em", text: "favorite"
end

def test_accepts_custom_csrf_token
bogus_csrf = "let me in"
render_inline(ExampleToggleSwitchForm.new(csrf: bogus_csrf, src: "/toggle_switch"))
assert_selector "toggle-switch[data-csrf='#{bogus_csrf}']"
end

def test_can_render_without_subclass
render_inline(
Primer::Forms::ToggleSwitchForm.new(
Expand Down

0 comments on commit 105c86e

Please sign in to comment.