mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Add integration tests for Scenario imports
This commit is contained in:
parent
aceace7950
commit
5b5da87c3a
1 changed files with 46 additions and 0 deletions
46
spec/features/scenario_import_spec.rb
Normal file
46
spec/features/scenario_import_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe ScenarioImportsController do
|
||||
let(:user) { users(:bob) }
|
||||
|
||||
before do
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
it 'renders the import form' do
|
||||
visit new_scenario_imports_path
|
||||
expect(page).to have_text('Import a Public Scenario')
|
||||
end
|
||||
|
||||
it 'requires a URL or file uplaod' do
|
||||
visit new_scenario_imports_path
|
||||
click_on 'Start Import'
|
||||
expect(page).to have_text('Please provide either a Scenario JSON File or a Public Scenario URL.')
|
||||
end
|
||||
|
||||
it 'imports a scenario that does not exist yet' do
|
||||
visit new_scenario_imports_path
|
||||
attach_file('Option 2: Upload a Scenario JSON File', File.join(Rails.root, 'data/default_scenario.json'))
|
||||
click_on 'Start Import'
|
||||
expect(page).to have_text('This scenario has a few agents to get you started. Feel free to change them or delete them as you see fit!')
|
||||
expect(page).not_to have_text('This Scenario already exists in your system.')
|
||||
check('I confirm that I want to import these Agents.')
|
||||
click_on 'Finish Import'
|
||||
expect(page).to have_text('Import successful!')
|
||||
end
|
||||
|
||||
it 'asks to accept conflicts when the scenario was modified' do
|
||||
DefaultScenarioImporter.seed(user)
|
||||
agent = user.agents.where(name: 'Rain Notifier').first
|
||||
agent.options['expected_receive_period_in_days'] = 9001
|
||||
agent.save!
|
||||
visit new_scenario_imports_path
|
||||
attach_file('Option 2: Upload a Scenario JSON File', File.join(Rails.root, 'data/default_scenario.json'))
|
||||
click_on 'Start Import'
|
||||
expect(page).to have_text('This Scenario already exists in your system.')
|
||||
expect(page).to have_text('9001')
|
||||
check('I confirm that I want to import these Agents.')
|
||||
click_on 'Finish Import'
|
||||
expect(page).to have_text('Import successful!')
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue