clean(spec): rubocopify / fix specs

This commit is contained in:
Martin 2022-12-02 17:16:29 +01:00 committed by mfo
parent 0563ac391b
commit 6556fda218
8 changed files with 29 additions and 17 deletions

View file

@ -1,19 +1,19 @@
.fr-mb-5v
- if @batch.finished_and_success? && @batch.seen_at.nil?
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :success) do |c|
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :success, heading_level: 'h2') do |c|
- c.body do
%p
= t('.finish.text_success', count: @batch.success_dossier_ids.count)
- set_seen_at!
- if @batch.finished_and_fails? && @batch.seen_at.nil?
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :warning) do |c|
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :warning, heading_level: 'h2') do |c|
- c.body do
%p
= t('.finish.text_fail', count: @batch.failed_dossier_ids.count)
- set_seen_at!
- if @batch.beginning?
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info) do |c|
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info, heading_level: 'h2') do |c|
- c.body do
%p
= t('.in_progress.text_beginning', count: @batch.dossiers.count)
@ -23,7 +23,7 @@
= t('.after_link_text')
- if @batch.in_progress?
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info) do |c|
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info, heading_level: 'h2') do |c|
- c.body do
- if @batch.failed_dossier_ids.present?

View file

@ -14,11 +14,12 @@ class Dsfr::AlertComponent < ApplicationComponent
private
def initialize(state:, title:)
def initialize(state:, title:, heading_level: 'h3')
@state = state
@title = title
@block = block
@heading_level = heading_level
end
attr_reader :state, :title, :block
attr_reader :state, :title, :block, :heading_level
end

View file

@ -2,7 +2,7 @@
= link_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-btn--secondary" do
= t('views.instructeurs.dossiers.restore')
- elsif close_to_expiration || Dossier::TERMINE.include?(state)
.dropdown.user-dossier-actions{ data: { controller: 'menu-button' } }
%li.dropdown.user-dossier-actions{ data: { controller: 'menu-button' } }
%button.fr-btn.fr-mb-0.dropdown-button{ data: { menu_button_target: 'button' } }
Actions
.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' }, id: "dossier_#{dossier_id}_actions_menu" }
@ -11,23 +11,23 @@
%li
= link_to repousser_expiration_instructeur_dossier_path(procedure_id, dossier_id), method: :post do
%span.icon.standby
.dropdown-description= t('instructeurs.dossiers.header.banner.button_delay_expiration')
%span.dropdown-description= t('instructeurs.dossiers.header.banner.button_delay_expiration')
- if archived
%li
= link_to unarchive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch do
%span.icon.unarchive
.dropdown-description
%span.dropdown-description
Désarchiver le dossier
- else
%li
= link_to archive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch do
%span.icon.archive
.dropdown-description
%span.dropdown-description
Archiver le dossier
%li.danger
= link_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete do
%span.icon.delete
.dropdown-description
%span.dropdown-description
= t('views.instructeurs.dossiers.delete_dossier')
- elsif Dossier::EN_CONSTRUCTION_OU_INSTRUCTION.include?(state)

View file

@ -83,7 +83,7 @@
%tr
- if batch_operation_component.render?
%th.text-center
%input{ type: "checkbox", data: { "batch-operation-target" => "all","action" => "batch-operation#onCheckAll"}, id: dom_id(BatchOperation.new, :checkbox_all), aria: { title: t('views.instructeurs.dossiers.select_all') } }
%input{ type: "checkbox", data: { "batch-operation-target" => "all","action" => "batch-operation#onCheckAll"}, id: dom_id(BatchOperation.new, :checkbox_all), aria: { label: t('views.instructeurs.dossiers.select_all') } }
- else
- if @statut.in? %w(suivis traites tous)
= render partial: "header_field", locals: { field: { "label" => "●", "table" => "notifications", "column" => "notifications" }, classname: "notification-col text-center" }
@ -120,9 +120,9 @@
%td.text-center
- if batch_operation_component.render?
- if p.batch_operation_id.present?
= check_box_tag :"batch_operation[dossier_ids][]", p.dossier_id, true, disabled: true, id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}")
= check_box_tag :"batch_operation[dossier_ids][]", p.dossier_id, true, disabled: true, id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"), aria: {label: t('views.instructeurs.dossiers.batch_operation.disabled')}
- else
= check_box_tag :"batch_operation[dossier_ids][]", p.dossier_id, false, data: { "batch-operation-target" => "input", "action" => "batch-operation#onCheckOne"}, form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}")
= check_box_tag :"batch_operation[dossier_ids][]", p.dossier_id, false, data: { "batch-operation-target" => "input", "action" => "batch-operation#onCheckOne"}, form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"), aria: {label: t('views.instructeurs.dossiers.batch_operation.enabled')}
- else
- if p.hidden_by_administration_at.present?
%span.cell-link

View file

@ -177,6 +177,9 @@ en:
filters:
title: Filter
select_all: Select all
batch_operation:
enabled: "Add this file to the selection for the bulk operation"
disabled: "Impossible to add this file to the selection because it is already in a bulk operation"
personalize: Personalize
follow_file: Follow-up the file
save: Save

View file

@ -172,6 +172,9 @@ fr:
filters:
title: Filtrer
select_all: Tout selectionner
batch_operation:
enabled: "Ajouter ce dossier à la selection pour un traitement de masse"
disabled: "Impossible d'ajouter ce dossier à la selection car il est déjà dans un traitement de masse"
personalize: Personnaliser
download: Télécharger un dossier
follow_file: Suivre le dossier

View file

@ -343,9 +343,9 @@ describe Instructeurs::ProceduresController, type: :controller do
end
context 'with batch operations' do
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur) }
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur, groupe_instructeurs: instructeur.groupe_instructeurs) }
let!(:termine_dossier_2) { create(:dossier, :accepte, procedure: procedure) }
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur) }
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur, groupe_instructeurs: instructeur.groupe_instructeurs) }
before { subject }
@ -357,7 +357,7 @@ describe Instructeurs::ProceduresController, type: :controller do
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur_2) }
before { subject }
it { expect(assigns(:batch_operations)).to eq(nil) }
it { expect(assigns(:batch_operations)).to eq([]) }
end
end

View file

@ -13,6 +13,9 @@ describe 'BatchOperation a dossier:', js: true do
dossier_3 = create(:dossier, :accepte, procedure: procedure)
log_in(instructeur.email, password)
visit instructeur_procedure_path(procedure, statut: 'traites')
# check a11y with enabled checkbox
expect(page).to be_axe_clean
# ensure button is disabled by default
expect(page).to have_selector('input[disabled][value="Archiver la sélection"]')
@ -28,6 +31,8 @@ describe 'BatchOperation a dossier:', js: true do
# ensure batched dossier is disabled
expect(page).to have_selector("##{checkbox_id}[disabled]")
# check a11y with disabled checkbox
expect(page).to be_axe_clean
# ensure alert is present
expect(page).to have_content("Information : Une action de masse est en cours")