From 687617cb084ae8eca3706e55fb04fe86f94b3d3f Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 26 Sep 2024 17:36:12 +0200 Subject: [PATCH] [#10799] Add test --- .../_api_entreprise_token_expiration_alert.html.haml | 2 +- app/views/administrateurs/procedures/jeton.html.haml | 2 +- spec/components/procedures/errors_summary_spec.rb | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/administrateurs/procedures/_api_entreprise_token_expiration_alert.html.haml b/app/views/administrateurs/procedures/_api_entreprise_token_expiration_alert.html.haml index 877fb464b..d37e14142 100644 --- a/app/views/administrateurs/procedures/_api_entreprise_token_expiration_alert.html.haml +++ b/app/views/administrateurs/procedures/_api_entreprise_token_expiration_alert.html.haml @@ -11,4 +11,4 @@ %p Votre jeton API Entreprise expirera le = procedure.api_entreprise_token_expires_at.strftime('%d/%m/%Y à %H:%M.') - Merci de le renouveler avant cette date. \ No newline at end of file + Merci de le renouveler avant cette date. diff --git a/app/views/administrateurs/procedures/jeton.html.haml b/app/views/administrateurs/procedures/jeton.html.haml index 57dfa4534..862a989a0 100644 --- a/app/views/administrateurs/procedures/jeton.html.haml +++ b/app/views/administrateurs/procedures/jeton.html.haml @@ -19,7 +19,7 @@ propre à votre démarche. = render partial: 'administrateurs/procedures/api_entreprise_token_expiration_alert', locals: { procedure: @procedure } - + .fr-input-group = f.label :api_entreprise_token, "Jeton", class: 'fr-label' = f.password_field :api_entreprise_token, value: @procedure.read_attribute(:api_entreprise_token), class: 'fr-input' diff --git a/spec/components/procedures/errors_summary_spec.rb b/spec/components/procedures/errors_summary_spec.rb index 9ff3edadb..e673244f9 100644 --- a/spec/components/procedures/errors_summary_spec.rb +++ b/spec/components/procedures/errors_summary_spec.rb @@ -83,7 +83,8 @@ describe Procedure::ErrorsSummary, type: :component do include Logic let(:validation_context) { :publication } - let(:procedure) { create(:procedure, attestation_template:, initiated_mail:) } + let(:expired_token) { JWT.encode({ exp: 2.days.ago.to_i }, nil, 'none') } + let(:procedure) { create(:procedure, attestation_template:, initiated_mail:, api_entreprise_token: expired_token) } let(:attestation_template) { build(:attestation_template) } let(:initiated_mail) { build(:initiated_mail) } @@ -97,6 +98,7 @@ describe Procedure::ErrorsSummary, type: :component do expect(page).to have_selector("a", text: "Les règles d’inéligibilité") expect(page).to have_selector("a", text: "Le modèle d’attestation") expect(page).to have_selector("a", text: "L’email de notification de passage de dossier en instruction") + expect(page).to have_selector("a", text: "Jeton API Entreprise") expect(page).to have_text("n'est pas valide", count: 2) end end