Jesper

Joined

650 Experience
6 Lessons Completed
0 Questions Solved

Activity

I'm seeking assistance on testing JavaScript that executes on the response page after a POST request.

So I have something like this

class YourControllerTest < ActionDispatch::IntegrationTest
  test 'submitting a POST request' do
    post '/your_controller/your_action', params: { your_param: 'some_value' }

    # Check if the response was a redirect (status code 202)
    assert_response :success

    # Now you can assert against the content of the redirected page
    assert_select 'h1', text: 'Expected Header'
  end
end

Which works, but the page object only contains an empty HTML page (<html><head></head><body></body></html>).

And I should be able to interact with the `page?, according to this https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends

I've experimented with both Selenium and the JavaScript driver for Capybara. In my test, there's plain JavaScript that alters the context of an HTML block, and I want to verify its functionality with a Minitest.

Can someone guide me on how to approach this effectively?