fix(dossier/footer): don't say user can submit dossier when he can't

This commit is contained in:
Colin Darie 2024-12-10 15:50:08 +01:00
parent 0a406376cb
commit a54f022353
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 50 additions and 2 deletions

View file

@ -5,7 +5,8 @@ en:
confirmation: Draft saved
error: Impossible to save the draft
en_construction:
explanation: Your modifications are automatically saved. Submit them when youre done.
explanation: Your modifications are automatically saved.
submit_them: Submit them when youre done.
confirmation: Modifications saved
error: Impossible to save the modifications.
annotations:

View file

@ -5,7 +5,8 @@ fr:
confirmation: Brouillon enregistré
error: Impossible denregistrer le brouillon
en_construction:
explanation: Vos modifications sont automatiquement enregistrées. Déposez-les quand vous aurez terminé.
explanation: Vos modifications sont automatiquement enregistrées.
submit_them: Déposez-les quand vous aurez terminé.
confirmation: Modifications enregistrées.
error: Impossible denregistrer les modifications
annotations:

View file

@ -5,6 +5,8 @@
= t('.annotations.explanation')
- elsif dossier.editing_fork?
= t('.en_construction.explanation')
- if dossier.can_passer_en_construction?
= t('.en_construction.submit_them')
- else
= t('.brouillon.explanation')
- if !annotation?

View file

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Dossiers::AutosaveFooterComponent, type: :component do
subject(:component) { render_inline(described_class.new(dossier:, annotation:)) }
let(:dossier) { create(:dossier) }
let(:annotation) { false }
context 'when showing brouillon state (default state)' do
it 'displays brouillon explanation' do
expect(component).to have_text("Votre brouillon")
end
end
context 'when editing fork and can pass en construction' do
let(:dossier) { create(:dossier, :en_construction).find_or_create_editing_fork(create(:user)) }
it 'displays en construction explanation' do
expect(component).to have_text("Vos modifications")
expect(component).to have_text("Déposez-les")
end
context 'when dossier is not eligible' do
before do
allow(dossier).to receive(:can_passer_en_construction?).and_return(false)
end
it 'displays en construction explanation' do
expect(component).to have_text("Vos modifications")
expect(component).not_to have_text("Déposez-les")
end
end
end
context 'when showing annotations' do
let(:annotation) { true }
it 'displays annotations explanation' do
expect(component).to have_text("Vos annotations")
end
end
end