12345678910111213141516171819202122232425262728293031323334 |
- require 'capybara_helper'
- describe "Creating a new agent", js: true do
- it "creates an agent" do
- login_as(users(:bob))
- visit "/"
- page.find("a", text: "Agents").trigger(:mouseover)
- click_on("New Agent")
- select2("Trigger Agent", from: "Type")
- fill_in(:agent_name, with: "Test Trigger Agent")
- click_on "Save"
- expect(page).to have_text("Test Trigger Agent")
- end
- it "creates an alert if a new agent with invalid json is submitted" do
- login_as(users(:bob))
- visit "/"
- page.find("a", text: "Agents").trigger(:mouseover)
- click_on("New Agent")
- select2("Trigger Agent", from: "Type")
- fill_in(:agent_name, with: "Test Trigger Agent")
- click_on("Toggle View")
- fill_in(:agent_options, with: '{
- "expected_receive_period_in_days": "2"
- "keep_event": "false"
- }')
- expect(get_alert_text_from { click_on "Save" }).to have_text("Sorry, there appears to be an error in your JSON input. Please fix it before continuing.")
- end
- end
|