Merge branch 'main' of github.com:betagouv/demarches-simplifiees.fr into instructeur-invitation-include-typo-suggestion-ldu
This commit is contained in:
commit
42633c0012
138 changed files with 2056 additions and 3526 deletions
|
@ -75,8 +75,8 @@ RSpec.describe Attachment::MultipleComponent, type: :component do
|
|||
context 'max attachments' do
|
||||
let(:kwargs) { { max: 1 } }
|
||||
|
||||
it 'does not render visible input file where max attachments has been reached' do
|
||||
expect(subject).to have_selector('.hidden input[type=file]')
|
||||
it 'renders a disabled input file where max attachments has been reached' do
|
||||
expect(subject).to have_selector('input[type=file][disabled]')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
class Dsfr::ComboboxComponentPreview < ViewComponent::Preview
|
||||
OPTIONS = [
|
||||
'Cheddar',
|
||||
'Brie',
|
||||
'Mozzarella',
|
||||
'Gouda',
|
||||
'Swiss',
|
||||
'Parmesan',
|
||||
'Feta',
|
||||
'Blue cheese',
|
||||
'Camembert',
|
||||
'Monterey Jack',
|
||||
'Roquefort',
|
||||
'Provolone',
|
||||
'Colby',
|
||||
'Havarti',
|
||||
'Ricotta',
|
||||
'Pepper Jack',
|
||||
'Muenster',
|
||||
'Fontina',
|
||||
'Limburger',
|
||||
'Asiago',
|
||||
'Cottage cheese',
|
||||
'Emmental',
|
||||
'Mascarpone',
|
||||
'Taleggio',
|
||||
'Gruyere',
|
||||
'Edam',
|
||||
'Pecorino Romano',
|
||||
'Manchego',
|
||||
'Halloumi',
|
||||
'Jarlsberg',
|
||||
'Munster',
|
||||
'Stilton',
|
||||
'Gorgonzola',
|
||||
'Queso blanco',
|
||||
'Queso fresco',
|
||||
'Queso de bola',
|
||||
'Queso de cabra',
|
||||
'Queso panela',
|
||||
'Queso Oaxaca',
|
||||
'Queso Chihuahua',
|
||||
'Queso manchego',
|
||||
'Queso de bola',
|
||||
'Queso de bola de cabra',
|
||||
'Queso de bola de vaca',
|
||||
'Queso de bola de oveja',
|
||||
'Queso de bola de mezcla',
|
||||
'Queso de bola de leche cruda',
|
||||
'Queso de bola de leche pasteurizada',
|
||||
'Queso de bola de leche de cabra',
|
||||
'Queso de bola de leche de vaca',
|
||||
'Queso de bola de leche de oveja',
|
||||
'Queso de bola de leche de mezcla',
|
||||
'Burrata',
|
||||
'Scamorza',
|
||||
'Caciocavallo',
|
||||
'Provolone piccante',
|
||||
'Pecorino sardo',
|
||||
'Pecorino toscano',
|
||||
'Pecorino siciliano',
|
||||
'Pecorino calabrese',
|
||||
'Pecorino moliterno',
|
||||
'Pecorino di fossa',
|
||||
'Pecorino di filiano',
|
||||
'Pecorino di pienza',
|
||||
'Pecorino di grotta',
|
||||
'Pecorino di capra',
|
||||
'Pecorino di mucca',
|
||||
'Pecorino di pecora',
|
||||
'Pecorino di bufala',
|
||||
'Cacio di bosco',
|
||||
'Cacio di roma',
|
||||
'Cacio di fossa',
|
||||
'Cacio di tricarico',
|
||||
'Cacio di cavallo',
|
||||
'Cacio di capra',
|
||||
'Cacio di mucca',
|
||||
'Cacio di pecora',
|
||||
'Cacio di bufala',
|
||||
'Taleggio di capra',
|
||||
'Taleggio di mucca',
|
||||
'Taleggio di pecora',
|
||||
'Taleggio di bufala',
|
||||
'Bel Paese',
|
||||
'Crescenza',
|
||||
'Stracchino',
|
||||
'Robiola',
|
||||
'Toma',
|
||||
'Bra',
|
||||
'Castelmagno',
|
||||
'Raschera',
|
||||
'Montasio',
|
||||
'Piave',
|
||||
'Bitto',
|
||||
'Quartirolo Lombardo',
|
||||
'Formaggella del Luinese',
|
||||
'Formaggella della Val Vigezzo',
|
||||
'Formaggella della Valle Grana',
|
||||
'Formaggella della Val Bognanco',
|
||||
'Formaggella della Val d’Intelvi',
|
||||
'Formaggella della Val Gerola'
|
||||
]
|
||||
|
||||
def simple_select_with_options
|
||||
render Dsfr::ComboboxComponent.new(options: OPTIONS, selected: OPTIONS.sample, input_html_options: { name: :value, id: 'simple-select', class: 'width-33' })
|
||||
end
|
||||
|
||||
def simple_select_with_options_and_allows_custom_value
|
||||
render Dsfr::ComboboxComponent.new(options: OPTIONS, selected: OPTIONS.sample, allows_custom_value: true, input_html_options: { id: 'simple-select', class: 'width-33', name: :value })
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ describe Administrateurs::ExpertsProceduresController, type: :controller do
|
|||
subject { post :create, params: params }
|
||||
|
||||
context 'when inviting multiple valid experts' do
|
||||
let(:params) { { procedure_id: procedure.id, emails: [expert.email, "new@expert.fr"].to_json } }
|
||||
let(:params) { { procedure_id: procedure.id, emails: [expert.email, "new@expert.fr"] } }
|
||||
|
||||
it 'creates experts' do
|
||||
subject
|
||||
|
@ -38,7 +38,7 @@ describe Administrateurs::ExpertsProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when inviting expert using an email with typos' do
|
||||
let(:params) { { procedure_id: procedure.id, emails: ['martin@oraneg.fr'].to_json } }
|
||||
let(:params) { { procedure_id: procedure.id, emails: ['martin@oraneg.fr'] } }
|
||||
render_views
|
||||
it 'warns' do
|
||||
subject
|
||||
|
|
|
@ -332,14 +332,14 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
|||
describe '#add_instructeur_procedure_non_routee' do
|
||||
# faire la meme chose sur une procedure non routee
|
||||
let(:procedure_non_routee) { create(:procedure, administrateur: admin) }
|
||||
let(:emails) { ['instructeur_3@ministere_a.gouv.fr', 'instructeur_4@ministere_b.gouv.fr'].to_json }
|
||||
let(:emails) { ['instructeur_3@ministere_a.gouv.fr', 'instructeur_4@ministere_b.gouv.fr'] }
|
||||
let(:manager) { false }
|
||||
before {
|
||||
procedure_non_routee.administrateurs_procedures.where(administrateur: admin).update_all(manager:)
|
||||
}
|
||||
subject { post :add_instructeur, params: { emails: emails, procedure_id: procedure_non_routee.id, id: procedure_non_routee.defaut_groupe_instructeur.id } }
|
||||
context 'when all emails are valid' do
|
||||
let(:emails) { ['test@b.gouv.fr', 'test2@b.gouv.fr'].to_json }
|
||||
let(:emails) { ['test@b.gouv.fr', 'test2@b.gouv.fr'] }
|
||||
it do
|
||||
expect(subject).to render_template(:index)
|
||||
expect(subject.request.flash[:alert]).to be_nil
|
||||
|
@ -348,7 +348,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when there is at least one bad email' do
|
||||
let(:emails) { ['badmail', 'instructeur2@gmail.com'].to_json }
|
||||
let(:emails) { ['badmail', 'instructeur2@gmail.com'] }
|
||||
it do
|
||||
expect(subject).to render_template(:index)
|
||||
expect(subject.request.flash[:alert]).to be_present
|
||||
|
@ -376,7 +376,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
|||
params: {
|
||||
procedure_id: procedure.id,
|
||||
id: gi_1_2.id,
|
||||
emails: new_instructeur_emails.to_json
|
||||
emails: new_instructeur_emails
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
let(:zone) { create(:zone) }
|
||||
let(:zone_ids) { [zone.id] }
|
||||
let(:tags) { "[\"planete\",\"environnement\"]" }
|
||||
let(:tags) { ["planete", "environnement"] }
|
||||
|
||||
describe '#apercu' do
|
||||
subject { get :apercu, params: { id: procedure.id } }
|
||||
|
|
|
@ -367,7 +367,7 @@ describe Experts::AvisController, type: :controller do
|
|||
let(:previous_avis_confidentiel) { false }
|
||||
let(:previous_revoked_at) { nil }
|
||||
let!(:previous_avis) { create(:avis, dossier:, claimant:, experts_procedure:, confidentiel: previous_avis_confidentiel, revoked_at: previous_revoked_at) }
|
||||
let(:emails) { '["a@b.com"]' }
|
||||
let(:emails) { ["a@b.com"] }
|
||||
let(:introduction) { 'introduction' }
|
||||
let(:created_avis) { Avis.last }
|
||||
let!(:old_avis_count) { Avis.count }
|
||||
|
@ -394,7 +394,7 @@ describe Experts::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when an invalid email' do
|
||||
let(:emails) { "[\"toto.fr\"]" }
|
||||
let(:emails) { ["toto.fr"] }
|
||||
|
||||
it do
|
||||
expect(response).to render_template :instruction
|
||||
|
@ -414,7 +414,7 @@ describe Experts::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
context 'ask review with attachment' do
|
||||
let(:emails) { "[\"toto@totomail.com\"]" }
|
||||
let(:emails) { ["toto@totomail.com"] }
|
||||
|
||||
it do
|
||||
expect(created_avis.introduction_file).to be_attached
|
||||
|
@ -425,7 +425,7 @@ describe Experts::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with multiple emails' do
|
||||
let(:emails) { "[\"toto.fr\",\"titi@titimail.com\"]" }
|
||||
let(:emails) { ["toto.fr", "titi@titimail.com"] }
|
||||
|
||||
it do
|
||||
expect(response).to render_template :instruction
|
||||
|
|
|
@ -28,7 +28,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
post(
|
||||
:send_to_instructeurs,
|
||||
params: {
|
||||
recipients: [recipient.id].to_json,
|
||||
recipients: [recipient.id],
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
}
|
||||
end
|
||||
|
||||
let(:emails) { "[\"email@a.com\"]" }
|
||||
let(:emails) { ["email@a.com"] }
|
||||
|
||||
context "notifications updates" do
|
||||
context 'when an instructeur follows the dossier' do
|
||||
|
@ -811,7 +811,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
it { expect(response).to redirect_to(avis_instructeur_dossier_path(dossier.procedure, dossier)) }
|
||||
|
||||
context "with an invalid email" do
|
||||
let(:emails) { "[\"emaila.com\"]" }
|
||||
let(:emails) { ["emaila.com"] }
|
||||
|
||||
before { subject }
|
||||
|
||||
|
@ -822,7 +822,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
context "with no email" do
|
||||
let(:emails) { "" }
|
||||
let(:emails) { [] }
|
||||
|
||||
before { subject }
|
||||
|
||||
|
@ -833,7 +833,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with multiple emails' do
|
||||
let(:emails) { "[\"toto.fr\",\"titi@titimail.com\"]" }
|
||||
let(:emails) { ["toto.fr", "titi@titimail.com"] }
|
||||
|
||||
before { subject }
|
||||
|
||||
|
@ -845,7 +845,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when the expert do not want to receive notification' do
|
||||
let(:emails) { "[\"email@a.com\"]" }
|
||||
let(:emails) { ["email@a.com"] }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure, notify_on_new_avis: false) }
|
||||
|
||||
before { subject }
|
||||
|
|
639
spec/fixtures/cassettes/The_user/fill_a_dossier.yml
vendored
639
spec/fixtures/cassettes/The_user/fill_a_dossier.yml
vendored
File diff suppressed because one or more lines are too long
|
@ -22,21 +22,19 @@ RSpec.describe Champs::AnnuaireEducationChamp do
|
|||
it_behaves_like "a data updater (without updating the value)", ''
|
||||
end
|
||||
|
||||
context 'when data is inconsistent' do
|
||||
let(:data) { { 'yo' => 'lo' } }
|
||||
it_behaves_like "a data updater (without updating the value)", { 'yo' => 'lo' }
|
||||
end
|
||||
|
||||
context 'when data is consistent' do
|
||||
let(:data) {
|
||||
{
|
||||
'nom_etablissement': "karrigel an ankou",
|
||||
'nom_etablissement' => "karrigel an ankou",
|
||||
'nom_commune' => 'kumun',
|
||||
'identifiant_de_l_etablissement' => '666667'
|
||||
}.with_indifferent_access
|
||||
}
|
||||
}
|
||||
it_behaves_like "a data updater (without updating the value)", {
|
||||
'nom_etablissement' => "karrigel an ankou",
|
||||
'nom_commune' => 'kumun',
|
||||
'identifiant_de_l_etablissement' => '666667'
|
||||
}
|
||||
it { expect { subject }.to change { champ.reload.data }.to(data) }
|
||||
it { expect { subject }.to change { champ.reload.value }.to('karrigel an ankou, kumun (666667)') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ describe Champs::CommuneChamp do
|
|||
let(:champ) { create(:champ_communes, code_postal:, external_id: code_insee) }
|
||||
|
||||
describe 'value' do
|
||||
it 'with code_postal' do
|
||||
it 'find commune' do
|
||||
expect(champ.to_s).to eq('Châteldon (63290)')
|
||||
expect(champ.name).to eq('Châteldon')
|
||||
expect(champ.external_id).to eq(code_insee)
|
||||
|
@ -15,15 +15,22 @@ describe Champs::CommuneChamp do
|
|||
expect(champ.for_export(:value)).to eq 'Châteldon (63290)'
|
||||
expect(champ.for_export(:code)).to eq '63102'
|
||||
expect(champ.for_export(:departement)).to eq '63 – Puy-de-Dôme'
|
||||
expect(champ.communes.size).to eq(8)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'code_postal with spaces' do
|
||||
let(:code_postal) { ' 63 2 90 ' }
|
||||
context 'with code' do
|
||||
let(:champ) { create(:champ_communes, code: '63102-63290') }
|
||||
|
||||
it 'with code_postal' do
|
||||
expect(champ.communes.size).to eq(8)
|
||||
it 'find commune' do
|
||||
expect(champ.to_s).to eq('Châteldon (63290)')
|
||||
expect(champ.name).to eq('Châteldon')
|
||||
expect(champ.external_id).to eq(code_insee)
|
||||
expect(champ.code).to eq(code_insee)
|
||||
expect(champ.code_departement).to eq(code_departement)
|
||||
expect(champ.code_postal).to eq(code_postal)
|
||||
expect(champ.for_export(:value)).to eq 'Châteldon (63290)'
|
||||
expect(champ.for_export(:code)).to eq '63102'
|
||||
expect(champ.for_export(:departement)).to eq '63 – Puy-de-Dôme'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,12 @@ describe Champs::DecimalNumberChamp do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when value contain space' do
|
||||
let(:champ) { create(:champ_decimal_number, :private, value:) }
|
||||
let(:value) { ' 2.6666 ' }
|
||||
it { expect(champ.value).to eq('2.6666') }
|
||||
end
|
||||
|
||||
context 'when the value has too many decimal' do
|
||||
let(:value) { '2.6666' }
|
||||
|
||||
|
@ -65,7 +71,7 @@ describe Champs::DecimalNumberChamp do
|
|||
end
|
||||
context 'with number having spaces' do
|
||||
let(:value) { " 120 " }
|
||||
it { is_expected.to be_nil }
|
||||
it { is_expected.to eq(120) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,16 @@ describe Champs::IntegerNumberChamp do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the value is a number with sapces' do
|
||||
let(:value) { ' 120 ' }
|
||||
|
||||
it 'is valid and is formated' do
|
||||
is_expected.to be_truthy
|
||||
champ.save!
|
||||
expect(champ.value).to eq('120')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the value is blank' do
|
||||
let(:value) { '' }
|
||||
|
||||
|
|
|
@ -40,12 +40,6 @@ describe Logic::ChampValue do
|
|||
|
||||
it { is_expected.to be nil }
|
||||
end
|
||||
|
||||
context 'with invalid value' do
|
||||
before { champ.value = 'environ 300' }
|
||||
|
||||
it { is_expected.to be nil }
|
||||
end
|
||||
end
|
||||
|
||||
context 'decimal tdc' do
|
||||
|
@ -53,18 +47,6 @@ describe Logic::ChampValue do
|
|||
|
||||
it { expect(champ_value(champ.stable_id).type([champ.type_de_champ])).to eq(:number) }
|
||||
it { is_expected.to eq(42.01) }
|
||||
|
||||
context 'with invalid value with too many digits after the decimal point' do
|
||||
before { champ.value = '42.1234' }
|
||||
|
||||
it { is_expected.to be nil }
|
||||
end
|
||||
|
||||
context 'with invalid value' do
|
||||
before { champ.value = 'racine de 2' }
|
||||
|
||||
it { is_expected.to be nil }
|
||||
end
|
||||
end
|
||||
|
||||
context 'dropdown tdc' do
|
||||
|
|
|
@ -106,25 +106,10 @@ module SystemHelpers
|
|||
end
|
||||
end
|
||||
|
||||
def select_combobox(libelle, fill_with, value, check: true)
|
||||
fill_in libelle, with: fill_with
|
||||
find('li[role="option"][data-reach-combobox-option]', text: value, wait: 5).click
|
||||
if check
|
||||
check_selected_value(libelle, with: value)
|
||||
end
|
||||
end
|
||||
|
||||
def check_selected_value(libelle, with:)
|
||||
field = find_hidden_field_for(libelle)
|
||||
value = field.value.starts_with?('[') ? JSON.parse(field.value) : field.value
|
||||
if value.is_a?(Array)
|
||||
if with.is_a?(Array)
|
||||
expect(value.sort).to eq(with.sort)
|
||||
else
|
||||
expect(value).to include(with)
|
||||
end
|
||||
else
|
||||
expect(value).to eq(with)
|
||||
def select_combobox(libelle, value, custom_value: false)
|
||||
fill_in libelle, with: custom_value ? "#{value}," : value
|
||||
if !custom_value
|
||||
find_field(libelle).send_keys(:down, :enter)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ describe 'Administrateurs can edit procedures', js: true do
|
|||
procedure.update!(tags: ['social'])
|
||||
|
||||
visit edit_admin_procedure_path(procedure)
|
||||
select_combobox('procedure_tags_combo', 'planete', 'planete', check: false)
|
||||
select_combobox('procedure_tags_combo', 'planete', custom_value: true)
|
||||
click_on 'Enregistrer'
|
||||
|
||||
expect(procedure.reload.tags).to eq(['social', 'planete'])
|
||||
|
|
|
@ -29,7 +29,8 @@ describe 'Inviting an expert:', js: true do
|
|||
within('.fr-sidemenu') { click_on 'Demander un avis' }
|
||||
expect(page).to have_current_path(avis_new_instructeur_dossier_path(procedure, dossier))
|
||||
|
||||
page.execute_script("document.querySelector('#avis_emails').value = '[\"#{expert.email}\",\"#{expert2.email}\"]'")
|
||||
fill_in 'Emails', with: "#{expert.email},"
|
||||
fill_in 'Emails', with: expert2.email
|
||||
fill_in 'avis_introduction', with: 'Bonjour, merci de me donner votre avis sur ce dossier.'
|
||||
check 'avis_invite_linked_dossiers'
|
||||
page.select 'confidentiel', from: 'avis_confidentiel'
|
||||
|
@ -109,7 +110,7 @@ describe 'Inviting an expert:', js: true do
|
|||
within('.fr-sidemenu') { click_on 'Demander un avis' }
|
||||
expect(page).to have_current_path(avis_new_instructeur_dossier_path(procedure, dossier))
|
||||
|
||||
fill_in 'Emails', with: "#{expert.email}; #{expert2.email}"
|
||||
select_combobox 'Emails', expert.email
|
||||
fill_in 'avis_introduction', with: 'Bonjour, merci de me donner votre avis sur ce dossier.'
|
||||
check 'avis_invite_linked_dossiers'
|
||||
page.select 'confidentiel', from: 'avis_confidentiel'
|
||||
|
|
|
@ -160,13 +160,10 @@ describe 'Instructing a dossier:', js: true do
|
|||
within('.fr-sidemenu') { click_on 'Demander un avis' }
|
||||
expect(page).to have_current_path(avis_new_instructeur_dossier_path(procedure, dossier))
|
||||
|
||||
expert_email_formated = "[\"expert@tps.com\"]"
|
||||
expert_email = 'expert@tps.com'
|
||||
ask_confidential_avis(expert_email_formated, 'a good introduction')
|
||||
ask_confidential_avis(expert_email, 'a good introduction')
|
||||
|
||||
expert_email_formated = "[\"#{instructeur2.email}\"]"
|
||||
expert_email = instructeur2.email
|
||||
ask_confidential_avis(expert_email_formated, 'a good introduction')
|
||||
ask_confidential_avis(instructeur2.email, 'a good introduction')
|
||||
|
||||
click_on 'Personnes impliquées'
|
||||
expect(page).to have_text(expert_email)
|
||||
|
@ -189,8 +186,8 @@ describe 'Instructing a dossier:', js: true do
|
|||
|
||||
click_on 'Personnes impliquées'
|
||||
|
||||
select_combobox('Emails', instructeur_2.email, instructeur_2.email, check: false)
|
||||
select_combobox('Emails', instructeur_3.email, instructeur_3.email, check: false)
|
||||
select_combobox('Emails', instructeur_2.email)
|
||||
select_combobox('Emails', instructeur_3.email)
|
||||
|
||||
click_on 'Envoyer'
|
||||
|
||||
|
@ -287,7 +284,7 @@ describe 'Instructing a dossier:', js: true do
|
|||
end
|
||||
|
||||
def ask_confidential_avis(to, introduction)
|
||||
page.execute_script("document.querySelector('#avis_emails').value = '#{to}'")
|
||||
fill_in 'avis_emails', with: to
|
||||
fill_in 'avis_introduction', with: introduction
|
||||
select 'confidentiel', from: 'avis_confidentiel'
|
||||
within('form#new_avis') { click_on 'Demander un avis' }
|
||||
|
|
|
@ -88,33 +88,13 @@ describe "procedure filters" do
|
|||
|
||||
scenario "should be able to user custom fiters", js: true do
|
||||
# use date filter
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: "En construction le", wait: 5).click
|
||||
find("input#value[type=date]", visible: true)
|
||||
fill_in "Valeur", with: "10/10/2010"
|
||||
click_button "Ajouter le filtre"
|
||||
expect(page).to have_no_css("#search-filter", visible: true)
|
||||
add_filter("En construction le", "10/10/2010", type: :date)
|
||||
|
||||
# use statut dropdown filter
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: "Statut", wait: 5).click
|
||||
find("select#value", visible: false)
|
||||
select 'En construction', from: "Valeur"
|
||||
click_button "Ajouter le filtre"
|
||||
expect(page).to have_no_css("#search-filter", visible: true)
|
||||
add_filter('Statut', 'En construction', type: :enum)
|
||||
|
||||
# use choice dropdown filter
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: "Choix unique", wait: 5).click
|
||||
find("select#value", visible: false)
|
||||
select 'val1', from: "Valeur"
|
||||
click_button "Ajouter le filtre"
|
||||
add_filter('Choix unique', 'val1', type: :enum)
|
||||
end
|
||||
|
||||
describe 'with a vcr cached cassette' do
|
||||
|
@ -124,14 +104,7 @@ describe "procedure filters" do
|
|||
departement_champ.reload
|
||||
champ_select_value = "#{departement_champ.external_id} – #{departement_champ.value}"
|
||||
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: departement_champ.libelle, wait: 5).click
|
||||
find("select#value", visible: true)
|
||||
select champ_select_value, from: "Valeur"
|
||||
click_button "Ajouter le filtre"
|
||||
find("select#value", visible: false) # w8 for filter to be applied
|
||||
add_filter(departement_champ.libelle, champ_select_value, type: :enum)
|
||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||
end
|
||||
|
||||
|
@ -140,14 +113,7 @@ describe "procedure filters" do
|
|||
region_champ.update!(value: 'Bretagne', external_id: '53')
|
||||
region_champ.reload
|
||||
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: region_champ.libelle, wait: 5).click
|
||||
find("select#value", visible: true)
|
||||
select region_champ.value, from: "Valeur"
|
||||
click_button "Ajouter le filtre"
|
||||
find("select#value", visible: false) # w8 for filter to be applied
|
||||
add_filter(region_champ.libelle, region_champ.value, type: :enum)
|
||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||
end
|
||||
end
|
||||
|
@ -155,7 +121,7 @@ describe "procedure filters" do
|
|||
scenario "should be able to add and remove two filters for the same field", js: true do
|
||||
add_filter(type_de_champ.libelle, champ.value)
|
||||
add_filter(type_de_champ.libelle, champ_2.value)
|
||||
add_enum_filter('Groupe instructeur', procedure.groupe_instructeurs.first.label)
|
||||
add_filter('Groupe instructeur', procedure.groupe_instructeurs.first.label, type: :enum)
|
||||
|
||||
within ".dossiers-table" do
|
||||
expect(page).to have_link(new_unfollow_dossier.id.to_s, exact: true)
|
||||
|
@ -185,40 +151,40 @@ describe "procedure filters" do
|
|||
end
|
||||
end
|
||||
|
||||
def add_filter(column_name, filter_value, type: :text)
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter + button', wait: 5).click
|
||||
find('.fr-menu__item', text: column_name, wait: 5).click
|
||||
case type
|
||||
when :text
|
||||
fill_in "Valeur", with: filter_value
|
||||
when :date
|
||||
find("input#value[type=date]", visible: true)
|
||||
fill_in "Valeur", with: filter_value
|
||||
when :enum
|
||||
find("select#value", visible: false)
|
||||
select filter_value, from: "Valeur"
|
||||
end
|
||||
click_button "Ajouter le filtre"
|
||||
expect(page).to have_no_css("#search-filter", visible: true)
|
||||
end
|
||||
|
||||
def remove_filter(filter_value)
|
||||
click_link text: filter_value
|
||||
end
|
||||
|
||||
def add_filter(column_name, filter_value)
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: column_name, wait: 5).click
|
||||
fill_in "Valeur", with: filter_value
|
||||
click_button "Ajouter le filtre"
|
||||
expect(page).to have_no_css("#search-filter", visible: true)
|
||||
end
|
||||
|
||||
def add_enum_filter(column_name, filter_value)
|
||||
click_on 'Sélectionner un filtre'
|
||||
wait_until { all("#search-filter").size == 1 }
|
||||
find('#search-filter', wait: 5).click
|
||||
find('.fr-menu__item', text: column_name, wait: 5).click
|
||||
select filter_value, from: "Valeur"
|
||||
click_button "Ajouter le filtre"
|
||||
expect(page).to have_no_css("#search-filter", visible: true)
|
||||
end
|
||||
|
||||
def add_column(column_name)
|
||||
click_on 'Personnaliser'
|
||||
select_combobox('Colonne à afficher', column_name, column_name, check: false)
|
||||
select_combobox('Colonne à afficher', column_name)
|
||||
click_button "Enregistrer"
|
||||
end
|
||||
|
||||
def remove_column(column_name)
|
||||
click_on 'Personnaliser'
|
||||
click_button column_name
|
||||
find("body").native.send_key("Escape")
|
||||
within '.fr-tag-list' do
|
||||
find('.fr-tag', text: column_name).find('button').click
|
||||
end
|
||||
click_button "Enregistrer"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,10 @@ describe 'The user' do
|
|||
log_in(user, procedure)
|
||||
|
||||
fill_individual
|
||||
|
||||
# wait for react components to be initialized
|
||||
find('.dom-ready')
|
||||
|
||||
# fill data
|
||||
fill_in('text', with: 'super texte', match: :first)
|
||||
fill_in('textarea', with: 'super textarea')
|
||||
|
@ -37,16 +41,23 @@ describe 'The user' do
|
|||
select('Martinique', from: form_id_for('regions'))
|
||||
select('02 – Aisne', from: form_id_for('departements'))
|
||||
|
||||
scroll_to(find_field('communes'), align: :center)
|
||||
fill_in('communes', with: '60400')
|
||||
find('li', text: 'Brétigny (60400)').click
|
||||
find('.fr-menu__item', text: 'Brétigny (60400)').click
|
||||
wait_until { champ_value_for('communes') == "Brétigny" }
|
||||
|
||||
scroll_to(find_field('address'), align: :center)
|
||||
fill_in('address', with: '78 Rue du Grés 30310 Vergè')
|
||||
find('li', text: '78 Rue du Grés 30310 Vergèze').click
|
||||
find('.fr-menu__item', text: '78 Rue du Grés 30310 Vergèze').click
|
||||
wait_until { champ_value_for('address') == '78 Rue du Grés 30310 Vergèze' }
|
||||
wait_until { champ_for('address').full_address? }
|
||||
expect(champ_for('address').departement_code_and_name).to eq('30 – Gard')
|
||||
|
||||
scroll_to(find_field('annuaire_education'), align: :center)
|
||||
fill_in('annuaire_education', with: 'Moulin')
|
||||
find('.fr-menu__item', text: 'Ecole primaire Jean Moulin, Moulins (0030323K)').click
|
||||
wait_until { champ_for('annuaire_education').external_id == "0030323K" }
|
||||
|
||||
fill_in('dossier_link', with: '123')
|
||||
find('.editable-champ-piece_justificative input[type=file]').attach_file(Rails.root + 'spec/fixtures/files/file.pdf')
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
module Maintenance
|
||||
RSpec.describe FixDecimalNumberWithSpacesTask do
|
||||
describe "#process" do
|
||||
subject(:process) { described_class.process(element) }
|
||||
let(:champ) { create(:champ_decimal_number, value:) }
|
||||
let(:element) { champ }
|
||||
|
||||
context 'with nil' do
|
||||
let(:value) { 0 }
|
||||
it { expect { process }.not_to change { champ.reload.valid_value } }
|
||||
end
|
||||
context 'with simple number' do
|
||||
let(:value) { "120" }
|
||||
it { expect { process }.not_to change { champ.reload.valid_value } }
|
||||
end
|
||||
context 'with number having leading spaces' do
|
||||
let(:value) { " 120" }
|
||||
it { expect { process }.to change { champ.reload.valid_value }.from(nil).to("120") }
|
||||
end
|
||||
context 'with number having trailing spaces' do
|
||||
let(:value) { "120 " }
|
||||
it { expect { process }.to change { champ.reload.valid_value }.from(nil).to("120") }
|
||||
end
|
||||
context 'with number having leading and trailing spaces' do
|
||||
let(:value) { " 120 " }
|
||||
it { expect { process }.to change { champ.reload.valid_value }.from(nil).to("120") }
|
||||
end
|
||||
context 'with number having in between spaces' do
|
||||
let(:value) { "1 2 0" }
|
||||
it { expect { process }.to change { champ.reload.valid_value }.from(nil).to("120") }
|
||||
end
|
||||
context 'with number having in between tab' do
|
||||
let(:value) { "\t120\t" }
|
||||
it { expect { process }.to change { champ.reload.valid_value }.from(nil).to("120") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,17 +16,11 @@ describe 'administrateurs/procedures/show', type: :view do
|
|||
render
|
||||
end
|
||||
|
||||
describe 'publish button is visible' do
|
||||
it { expect(rendered).to have_css('#publish-procedure-link') }
|
||||
it { expect(rendered).not_to have_css('#close-procedure-link') }
|
||||
end
|
||||
|
||||
describe 'procedure path is not customized' do
|
||||
it { expect(rendered).to have_content('En test') }
|
||||
end
|
||||
|
||||
describe 'archive button' do
|
||||
it { expect(rendered).not_to have_css('#archive-procedure') }
|
||||
it "render content" do
|
||||
expect(rendered).to have_css('#publish-procedure-link')
|
||||
expect(rendered).not_to have_css('#close-procedure-link')
|
||||
expect(rendered).to have_content('En test')
|
||||
expect(rendered).not_to have_css('#archive-procedure')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,10 +7,15 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
let(:drafts) { [] }
|
||||
let(:not_drafts) { [] }
|
||||
let(:preview_dossiers) { dossiers.take(3) }
|
||||
let(:user) { nil }
|
||||
|
||||
before do
|
||||
allow(view).to receive(:current_administrateur).and_return(user&.administrateur)
|
||||
end
|
||||
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
assign(:revision, procedure.published_revision)
|
||||
assign(:revision, procedure.active_revision)
|
||||
assign(:dossiers, dossiers)
|
||||
assign(:drafts, drafts)
|
||||
assign(:not_drafts, not_drafts)
|
||||
|
@ -25,8 +30,6 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
subject { render }
|
||||
|
||||
context 'when no user is signed in' do
|
||||
let(:user) { nil }
|
||||
|
||||
it 'renders sign-in and sign-up links' do
|
||||
subject
|
||||
expect(rendered).to have_link('Créer un compte')
|
||||
|
@ -98,4 +101,35 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "procedure is draft" do
|
||||
let(:procedure) { create(:procedure, :draft) }
|
||||
let(:user) { create :user }
|
||||
|
||||
it 'renders a warning' do
|
||||
subject
|
||||
expect(rendered).to have_text("Cette démarche est actuellement en test")
|
||||
end
|
||||
|
||||
context "when user is admin" do
|
||||
let(:user) { procedure.administrateurs.first.user }
|
||||
|
||||
it "renders warning about draft" do
|
||||
subject
|
||||
expect(rendered).to have_text("Cette démarche est actuellement en test")
|
||||
expect(rendered).to have_text("Ne communiquez pas ce lien")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "revision is draft" do
|
||||
before {
|
||||
assign(:revision, procedure.draft_revision)
|
||||
}
|
||||
|
||||
it "renders warning about draft" do
|
||||
subject
|
||||
expect(rendered).to have_text("Démarche en test")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ describe 'instructeurs/dossiers/envoyer_dossier_block', type: :view do
|
|||
let(:instructeur) { create(:instructeur, email: 'yop@totomail.fr') }
|
||||
let(:potential_recipients) { [instructeur] }
|
||||
|
||||
it { is_expected.to match(/data-react-props.*#{instructeur.email}/) }
|
||||
it { is_expected.to match(/props.*#{instructeur.email}/) }
|
||||
it { is_expected.to have_css(".fr-btn") }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue