demarches-normaliennes/spec/system/administrateurs/annotations_spec.rb

43 lines
1.7 KiB
Ruby
Raw Normal View History

describe 'As an administrateur I can edit annotation', js: true do
include ActionView::RecordIdentifier
2022-07-12 14:02:51 +02:00
let(:administrateur) { procedure.administrateurs.first }
let(:procedure) { create(:procedure) }
before do
login_as administrateur.user, scope: :user
visit annotations_admin_procedure_path(procedure)
end
scenario 'with private tdc, having invalid order, it pops up errors summary' do
click_on 'Ajouter une annotation'
2022-07-12 14:02:51 +02:00
select('Titre de section', from: 'Type de champ')
wait_until { procedure.reload.active_revision.types_de_champ_private.first&.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
first_header = procedure.active_revision.types_de_champ_private.first
select('Titre de niveau 1', from: dom_id(first_header, :header_section_level))
within(find('.type-de-champ-add-button', match: :first)) {
click_on 'Ajouter une annotation'
}
wait_until { procedure.reload.active_revision.types_de_champ_private.count == 2 }
second_header = procedure.active_revision.types_de_champ_private.last
select('Titre de section', from: dom_id(second_header, :type_champ))
wait_until { procedure.reload.active_revision.types_de_champ_private.last&.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
select('Titre de niveau 2', from: dom_id(second_header, :header_section_level))
within(".types-de-champ-block li:first-child") do
page.accept_alert do
click_on 'Supprimer'
end
end
expect(page).to have_content("devrait être précédé d'un titre de niveau 1")
# check summary
procedure.reload.active_revision.types_de_champ_private.each do |header_section|
expect(page).to have_link(header_section.libelle)
end
2022-07-12 14:02:51 +02:00
end
end