From 7130ea7e998763deb654275dffa84bcdc74bdd27 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 28 Feb 2023 10:49:50 +0100 Subject: [PATCH] fix specs --- app/javascript/new_design/instruction-button.js | 6 ++++-- .../instructeurs/dossiers/_instruction_button.html.haml | 2 +- .../dossiers/_instruction_button.html.haml_spec.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/javascript/new_design/instruction-button.js b/app/javascript/new_design/instruction-button.js index dc5645042..f2af6c57e 100644 --- a/app/javascript/new_design/instruction-button.js +++ b/app/javascript/new_design/instruction-button.js @@ -3,7 +3,7 @@ import { show, hide } from '@utils'; export function showMotivation(event, state) { event.preventDefault(); motivationCancel(); - const stateElement = document.querySelector(`.motivation.${state}`) + const stateElement = document.querySelector(`.motivation.${state}`); show(stateElement.parentElement); show(stateElement); @@ -12,7 +12,9 @@ export function showMotivation(event, state) { export function motivationCancel() { document.querySelectorAll('.motivation').forEach(hide); - document.querySelectorAll('.motivation').forEach(el => hide(el.parentElement)); + document + .querySelectorAll('.motivation') + .forEach((el) => hide(el.parentElement)); show(document.querySelector('.dropdown-items')); } diff --git a/app/views/instructeurs/dossiers/_instruction_button.html.haml b/app/views/instructeurs/dossiers/_instruction_button.html.haml index 6cf4de10e..ef5adbfb1 100644 --- a/app/views/instructeurs/dossiers/_instruction_button.html.haml +++ b/app/views/instructeurs/dossiers/_instruction_button.html.haml @@ -1,5 +1,5 @@ - if dossier.en_instruction? - = render Dropdown::MenuComponent.new(wrapper: :div, wrapper_options: { data: {'turbo-force': true} }, button_options: { class: [button_or_label_class(dossier)]}, role: @dossier.en_instruction? ? :region : :menu) do |menu| + = render Dropdown::MenuComponent.new(wrapper: :div, wrapper_options: { data: {'turbo-force': true} }, button_options: { class: [button_or_label_class(dossier)]}, role: dossier.en_instruction? ? :region : :menu) do |menu| - menu.with_button_inner_html do Instruire le dossier diff --git a/spec/views/instructeur/dossiers/_instruction_button.html.haml_spec.rb b/spec/views/instructeur/dossiers/_instruction_button.html.haml_spec.rb index 049640877..86e97981c 100644 --- a/spec/views/instructeur/dossiers/_instruction_button.html.haml_spec.rb +++ b/spec/views/instructeur/dossiers/_instruction_button.html.haml_spec.rb @@ -14,7 +14,7 @@ describe 'instructeurs/dossiers/instruction_button.html.haml', type: :view do matcher :have_dropdown_items do |options| match do |rendered| expected_count = options[:count] || 1 - expect(rendered).to have_selector('ul.dropdown-items li', count: expected_count) + expect(rendered).to have_selector('ul.dropdown-items li:not(.hidden)', count: expected_count) end end