mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Add specs for creating agents with a source/receiver/control target
This commit is contained in:
parent
e7ab172b30
commit
0abc42fb40
1 changed files with 65 additions and 0 deletions
|
@ -17,6 +17,71 @@ describe "Creating a new agent", js: true do
|
|||
expect(page).to have_text("Test Trigger Agent")
|
||||
end
|
||||
|
||||
context "with associated agents" do
|
||||
let!(:bob_scheduler_agent) {
|
||||
Agents::SchedulerAgent.create!(
|
||||
user: users(:bob),
|
||||
name: 'Example Scheduler',
|
||||
options: {
|
||||
'action' => 'run',
|
||||
'schedule' => '0 * * * *'
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
let!(:bob_weather_agent) {
|
||||
agents(:bob_weather_agent)
|
||||
}
|
||||
|
||||
let!(:bob_formatting_agent) {
|
||||
agents(:bob_formatting_agent).tap { |agent|
|
||||
# Make this valid
|
||||
agent.options['instructions']['foo'] = 'bar'
|
||||
agent.save!
|
||||
}
|
||||
}
|
||||
|
||||
it "creates an agent with a source and a receiver" do
|
||||
visit "/"
|
||||
page.find("a", text: "Agents").trigger(:mouseover)
|
||||
click_on("New Agent")
|
||||
|
||||
select_agent_type("Trigger Agent")
|
||||
fill_in(:agent_name, with: "Test Trigger Agent")
|
||||
|
||||
select2("SF Weather", from: 'Sources')
|
||||
select2("Formatting Agent", from: 'Receivers')
|
||||
|
||||
click_on "Save"
|
||||
|
||||
expect(page).to have_text("Test Trigger Agent")
|
||||
|
||||
agent = Agent.find_by(name: "Test Trigger Agent")
|
||||
|
||||
expect(agent.sources).to eq([bob_weather_agent])
|
||||
expect(agent.receivers).to eq([bob_formatting_agent])
|
||||
end
|
||||
|
||||
it "creates an agent with a control target" do
|
||||
visit "/"
|
||||
page.find("a", text: "Agents").trigger(:mouseover)
|
||||
click_on("New Agent")
|
||||
|
||||
select_agent_type("Scheduler Agent")
|
||||
fill_in(:agent_name, with: "Test Scheduler Agent")
|
||||
|
||||
select2("SF Weather", from: 'Control targets')
|
||||
|
||||
click_on "Save"
|
||||
|
||||
expect(page).to have_text("Test Scheduler Agent")
|
||||
|
||||
agent = Agent.find_by(name: "Test Scheduler Agent")
|
||||
|
||||
expect(agent.control_targets).to eq([bob_weather_agent])
|
||||
end
|
||||
end
|
||||
|
||||
it "creates an alert if a new agent with invalid json is submitted" do
|
||||
visit "/"
|
||||
page.find("a", text: "Agents").trigger(:mouseover)
|
||||
|
|
Loading…
Add table
Reference in a new issue