2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
describe 'As an administrateur I can edit annotation', js: true do
|
2024-06-19 18:19:52 +02:00
|
|
|
|
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
|
|
|
|
|
|
2024-06-19 18:19:52 +02:00
|
|
|
|
scenario 'with private tdc, having invalid order, it pops up errors summary' do
|
2024-01-12 10:03:54 +01:00
|
|
|
|
click_on 'Ajouter une annotation'
|
2022-07-12 14:02:51 +02:00
|
|
|
|
|
2024-06-19 18:19:52 +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
|