2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
describe 'As an integrator:', js: true do
|
2023-09-07 10:10:07 +02:00
|
|
|
let(:procedure) { create(:procedure, :for_individual, :published, opendata: true) }
|
2022-12-19 12:32:09 +01:00
|
|
|
let!(:type_de_champ) { create(:type_de_champ_text, procedure: procedure) }
|
|
|
|
|
|
|
|
before { visit "/preremplir/#{procedure.path}" }
|
|
|
|
|
|
|
|
scenario 'I can read the procedure prefilling (aka public champs)' do
|
2023-09-07 10:10:07 +02:00
|
|
|
expect(page).to have_content(I18n.t("views.prefill_descriptions.edit.title.nom"))
|
2023-02-22 19:32:25 +01:00
|
|
|
expect(page).to have_content(type_de_champ.to_typed_id_for_query)
|
2022-12-19 12:32:09 +01:00
|
|
|
expect(page).to have_content(I18n.t("activerecord.attributes.type_de_champ.type_champs.#{type_de_champ.type_champ}"))
|
|
|
|
expect(page).to have_content(type_de_champ.libelle)
|
|
|
|
expect(page).to have_content(type_de_champ.description)
|
|
|
|
end
|
|
|
|
|
2023-01-04 08:31:31 +01:00
|
|
|
scenario 'I can select champs to prefill and get prefill link and prefill query' do
|
2023-09-07 10:10:07 +02:00
|
|
|
page.find_by_id("#{type_de_champ.id}_add_button", match: :first).click
|
2022-12-19 12:32:09 +01:00
|
|
|
prefill_description = PrefillDescription.new(procedure)
|
|
|
|
prefill_description.update(selected_type_de_champ_ids: [type_de_champ.id.to_s])
|
|
|
|
expect(page).to have_content(prefill_description.prefill_link)
|
2023-01-04 08:31:31 +01:00
|
|
|
expect(page).to have_content(prefill_description.prefill_query.gsub("\n ", "").delete("\n"))
|
2022-12-19 12:32:09 +01:00
|
|
|
end
|
|
|
|
end
|