amelioration(types_de_champ/editor): en mode edition d'un champ de type explication, permet de choisir d'afficher ou pas cette explication derriere un collapse

This commit is contained in:
Martin 2022-11-04 16:26:28 +01:00 committed by mfo
parent 4a0955832d
commit fe0411203f
5 changed files with 71 additions and 1 deletions

View file

@ -0,0 +1,35 @@
describe TypesDeChampEditor::ChampComponent, type: :component do
describe 'render by type' do
context 'explication' do
let(:procedure) { create(:procedure, :with_explication) }
let(:tdc) { procedure.types_de_champ.first }
let(:coordinate) { procedure.draft_revision.coordinate_for(tdc) }
let(:component) { described_class.new(coordinate: coordinate, upper_coordinates: []) }
context 'not enabled' do
before do
allow(component).to receive(:current_user).and_return(procedure.administrateurs.first)
render_inline(component)
end
it 'renders only collapsible_explanation_enabled checkbox' do
expect(page).to have_selector('input[name="type_de_champ[collapsible_explanation_enabled]"]')
expect(page).not_to have_selector('textarea[name="type_de_champ[collapsible_explanation_text]"]')
end
end
context 'enabled' do
before do
tdc.update!(collapsible_explanation_enabled: "1")
allow(component).to receive(:current_user).and_return(procedure.administrateurs.first)
render_inline(component)
end
it 'renders both fields' do
expect(page).to have_selector('input[name="type_de_champ[collapsible_explanation_enabled]"]')
expect(page).to have_selector('textarea[name="type_de_champ[collapsible_explanation_text]"]')
end
end
end
end
end