demarches-normaliennes/spec/system/administrateurs/annotations_spec.rb
2024-09-10 21:31:30 +02:00

44 lines
1.8 KiB
Ruby
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
describe 'As an administrateur I can edit annotation', js: true do
include ActionView::RecordIdentifier
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'
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
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
end
end