cover the use case with feature specs
This commit is contained in:
parent
d5ffd61ab6
commit
a3ca79076e
3 changed files with 31 additions and 16 deletions
|
@ -19,6 +19,9 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do
|
|||
expect(page).to have_field(type_de_champ_phone.libelle, with: phone_value)
|
||||
expect(page).to have_css('label', text: type_de_champ_phone.libelle)
|
||||
expect(page).to have_field(type_de_champ_datetime.libelle, with: datetime_value)
|
||||
expect(page).to have_css('label', text: type_de_champ_multiple_drop_down_list.libelle)
|
||||
expect(page).to have_content(multiple_drop_down_list_values.first)
|
||||
expect(page).to have_content(multiple_drop_down_list_values.last)
|
||||
expect(page).to have_field(type_de_champ_epci.libelle, with: epci_value.last)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,12 +9,30 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
||||
let(:type_de_champ_phone) { create(:type_de_champ_phone, procedure: procedure) }
|
||||
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
|
||||
let(:type_de_champ_multiple_drop_down_list) { create(:type_de_champ_multiple_drop_down_list, procedure: procedure) }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:text_value) { "My Neighbor Totoro is the best movie ever" }
|
||||
let(:phone_value) { "invalid phone value" }
|
||||
let(:datetime_value) { "2023-02-01T10:32" }
|
||||
let(:multiple_drop_down_list_values) {
|
||||
[
|
||||
type_de_champ_multiple_drop_down_list.drop_down_list_enabled_non_empty_options.first,
|
||||
type_de_champ_multiple_drop_down_list.drop_down_list_enabled_non_empty_options.last
|
||||
]
|
||||
}
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
let(:entry_path) {
|
||||
commencer_path(
|
||||
path: procedure.path,
|
||||
"champ_#{type_de_champ_text.to_typed_id}" => text_value,
|
||||
"champ_#{type_de_champ_phone.to_typed_id}" => phone_value,
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_multiple_drop_down_list.to_typed_id}" => multiple_drop_down_list_values,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
)
|
||||
}
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
Rails.cache.clear
|
||||
|
@ -36,13 +54,7 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
visit "/users/sign_in"
|
||||
sign_in_with user.email, password
|
||||
|
||||
visit commencer_path(
|
||||
path: procedure.path,
|
||||
"champ_#{type_de_champ_text.to_typed_id}" => text_value,
|
||||
"champ_#{type_de_champ_phone.to_typed_id}" => phone_value,
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
)
|
||||
visit entry_path
|
||||
|
||||
click_on "Poursuivre mon dossier prérempli"
|
||||
end
|
||||
|
@ -50,15 +62,7 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
end
|
||||
|
||||
context 'when unauthenticated' do
|
||||
before do
|
||||
visit commencer_path(
|
||||
path: procedure.path,
|
||||
"champ_#{type_de_champ_text.to_typed_id}" => text_value,
|
||||
"champ_#{type_de_champ_phone.to_typed_id}" => phone_value,
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
)
|
||||
end
|
||||
before { visit entry_path }
|
||||
|
||||
context 'when the user signs in with email and password' do
|
||||
it_behaves_like "the user has got a prefilled dossier, owned by themselves" do
|
||||
|
|
|
@ -9,10 +9,17 @@ describe 'Prefilling a dossier (with a POST request):' do
|
|||
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
||||
let(:type_de_champ_phone) { create(:type_de_champ_phone, procedure: procedure) }
|
||||
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
|
||||
let(:type_de_champ_multiple_drop_down_list) { create(:type_de_champ_multiple_drop_down_list, procedure: procedure) }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:text_value) { "My Neighbor Totoro is the best movie ever" }
|
||||
let(:phone_value) { "invalid phone value" }
|
||||
let(:datetime_value) { "2023-02-01T10:32" }
|
||||
let(:multiple_drop_down_list_values) {
|
||||
[
|
||||
type_de_champ_multiple_drop_down_list.drop_down_list_enabled_non_empty_options.first,
|
||||
type_de_champ_multiple_drop_down_list.drop_down_list_enabled_non_empty_options.last
|
||||
]
|
||||
}
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
before do
|
||||
|
@ -116,6 +123,7 @@ describe 'Prefilling a dossier (with a POST request):' do
|
|||
"champ_#{type_de_champ_text.to_typed_id}" => text_value,
|
||||
"champ_#{type_de_champ_phone.to_typed_id}" => phone_value,
|
||||
"champ_#{type_de_champ_datetime.to_typed_id}" => datetime_value,
|
||||
"champ_#{type_de_champ_multiple_drop_down_list.to_typed_id}" => multiple_drop_down_list_values,
|
||||
"champ_#{type_de_champ_epci.to_typed_id}" => epci_value
|
||||
}.to_json
|
||||
JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "")
|
||||
|
|
Loading…
Reference in a new issue