bullet-train-co / magic_test

MIT License
440 stars 23 forks source link

Register Capypara actions for alert and confirm methods #103

Open gazayas opened 1 year ago

gazayas commented 1 year ago

Closes #54.

This will add accept_alert to a test like this:

require "application_system_test_case"

class BasicsTest < ApplicationSystemTestCase
  test "getting started" do
    visit root_path

    click_on 'Link to Alert'
    accept_alert
  end
end

We could probably do this with a block if we wanted to, but it would definitely take more work and I at least wanted to just make sure we could register alerts that were accepted when flushing the input.

gazayas commented 1 year ago

I'm afraid this might get in the way of generating assertions with Ctrl + Shift + A.

gazayas commented 1 year ago

I'm afraid this might get in the way of generating assertions with Ctrl + Shift + A.

Alright, I was able to fix it.

gazayas commented 1 year ago

If we wanted to write blocks, I'm thinking with our current set up we'd have to write something like this, which I'm not a fan of:

testingOutput.push({action: "accept_alert do", target: "", options: ""});

// Register all of the actions for accept_alert...

// Then close off the block
testingOutput.push({action: "end", target: "", options: ""});

We could also write directly to the file above the magic_test invocation, but again I think I'll just leave this one be unless we really need it or its requested for.