2016-12-20 17:26:46 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-02-13 11:57:35 +01:00
|
|
|
feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers' do
|
2016-12-20 17:26:46 +01:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
2017-07-18 15:26:33 +02:00
|
|
|
let(:procedure_1) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 1') }
|
|
|
|
let(:procedure_2) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 2') }
|
2016-12-20 17:26:46 +01:00
|
|
|
|
|
|
|
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
|
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
|
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
2017-01-03 12:11:30 +01:00
|
|
|
30.times do
|
2017-12-14 15:51:45 +01:00
|
|
|
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'en_construction')
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
2017-01-03 12:11:30 +01:00
|
|
|
22.times do
|
2017-12-14 15:53:02 +01:00
|
|
|
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'en_instruction')
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
|
|
|
login_as gestionnaire, scope: :gestionnaire
|
|
|
|
visit backoffice_path
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'On index' do
|
|
|
|
scenario 'Switching between procedures' do
|
2017-04-12 11:12:05 +02:00
|
|
|
page.all('#procedure-list a').first.click
|
2016-12-20 17:26:46 +01:00
|
|
|
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_1.id.to_s), only_path: true)
|
2017-01-03 12:11:30 +01:00
|
|
|
expect(page.find('#all_dossiers .count').text).to eq('30 dossiers')
|
2017-04-12 11:12:05 +02:00
|
|
|
page.all('#procedure-list a').last.click
|
2016-12-20 17:26:46 +01:00
|
|
|
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_2.id.to_s), only_path: true)
|
2017-01-03 12:11:30 +01:00
|
|
|
expect(page.find('#all_dossiers .count').text).to eq('22 dossiers')
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
|
|
|
|
2017-02-13 11:57:35 +01:00
|
|
|
scenario 'Searching with search bar', js: true do
|
2017-04-12 11:12:05 +02:00
|
|
|
page.find_by_id('search-area').trigger('click')
|
2017-02-13 11:57:35 +01:00
|
|
|
fill_in 'q', with: (procedure_1.dossiers.first.id + 14)
|
2017-04-12 11:12:05 +02:00
|
|
|
page.find_by_id('search-button').click
|
2017-02-13 11:57:35 +01:00
|
|
|
page.find_by_id("tr_dossier_#{(procedure_1.dossiers.first.id + 14)}").click
|
|
|
|
expect(page).to have_current_path("/backoffice/dossiers/#{(procedure_1.dossiers.first.id + 14)}")
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Following dossier' do
|
2017-04-12 11:12:05 +02:00
|
|
|
page.all('#procedure-list a').first.click
|
2016-12-20 17:26:46 +01:00
|
|
|
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("0")
|
2017-02-13 11:57:35 +01:00
|
|
|
page.find_by_id('all_dossiers').click
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page.all('#dossiers-list a').first.text).to eq('Suivre')
|
|
|
|
page.all('#dossiers-list a').first.click
|
2016-12-20 17:26:46 +01:00
|
|
|
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("1")
|
|
|
|
end
|
|
|
|
|
2017-02-13 11:57:35 +01:00
|
|
|
scenario 'Using sort and pagination', js: true do
|
|
|
|
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
|
2016-12-23 14:46:50 +01:00
|
|
|
wait_for_ajax
|
2017-02-13 11:57:35 +01:00
|
|
|
expect(page.all("#all_state_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id}")
|
|
|
|
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=desc"
|
2016-12-23 14:46:50 +01:00
|
|
|
wait_for_ajax
|
2017-03-01 18:11:58 +01:00
|
|
|
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.last.id}")
|
2016-12-23 14:46:50 +01:00
|
|
|
page.find('#all_state_dossiers .next_page a').trigger('click')
|
|
|
|
wait_for_ajax
|
|
|
|
page.find('#all_state_dossiers .next_page a').trigger('click')
|
|
|
|
wait_for_ajax
|
2017-03-01 18:11:58 +01:00
|
|
|
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 9}")
|
2016-12-23 14:46:50 +01:00
|
|
|
page.find('#all_state_dossiers .prev a').trigger('click')
|
|
|
|
wait_for_ajax
|
2017-03-01 18:11:58 +01:00
|
|
|
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 19}")
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Using filter' do
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Have an export button' do
|
2016-12-23 14:46:50 +01:00
|
|
|
expect(page.all('.export-link')[0].text).to eq('Au format CSV')
|
|
|
|
expect(page.all('.export-link')[1].text).to eq('Au format XLSX')
|
|
|
|
expect(page.all('.export-link')[2].text).to eq('Au format ODS')
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
2016-12-23 14:46:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'On show' do
|
|
|
|
scenario 'Following dossier' do
|
|
|
|
expect(page.all('#follow_dossiers .count').first.text).to eq('0 dossiers')
|
2017-02-13 11:57:35 +01:00
|
|
|
|
|
|
|
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
|
2017-03-01 18:11:58 +01:00
|
|
|
page.find("#all_dossiers #suivre_dossier_#{procedure_1.dossiers.first.id}").click
|
2017-02-13 11:57:35 +01:00
|
|
|
|
|
|
|
visit "/backoffice/dossiers/#{procedure_1.dossiers.second.id}"
|
|
|
|
page.find_by_id("suivre_dossier_#{procedure_1.dossiers.second.id}").click
|
|
|
|
|
|
|
|
visit "/backoffice/dossiers/procedure/#{procedure_1.id}"
|
2016-12-23 14:46:50 +01:00
|
|
|
expect(page.all('#follow_dossiers .count').first.text).to eq('2 dossiers')
|
|
|
|
end
|
|
|
|
|
2017-02-21 22:05:22 +01:00
|
|
|
if ENV['CIRCLECI'].nil?
|
|
|
|
scenario 'Adding message', js: true do
|
2017-03-01 18:11:58 +01:00
|
|
|
page.find("#all_dossiers #tr_dossier_#{procedure_1.dossiers.first.id}").trigger('click')
|
2017-02-21 22:05:22 +01:00
|
|
|
expect(page).to have_current_path(backoffice_dossier_path(procedure_1.dossiers.first.id), only_path: true)
|
|
|
|
page.find_by_id('open-message').click
|
|
|
|
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
|
|
|
|
page.find_by_id('save-message').click
|
|
|
|
expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message')
|
|
|
|
end
|
2016-12-20 17:26:46 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|