From a3a2204010f0e5a86aba235c52d068121fb51707 Mon Sep 17 00:00:00 2001
From: Daniel Tian <dtian@gitlab.com>
Date: Wed, 1 May 2024 00:18:58 +0000
Subject: [PATCH] Apply 1 suggestion(s) to 1 file(s)

Co-authored-by: Mohamed Hamda <mhamda@gitlab.com>
---
 app/views/admin/users/show.html.haml          |  6 +++-
 .../views/admin/users/show.html.haml_spec.rb  | 28 +++++++++++++++++--
 locale/gitlab.pot                             |  3 ++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml
index 682ae4403bed6..6da9288872477 100644
--- a/app/views/admin/users/show.html.haml
+++ b/app/views/admin/users/show.html.haml
@@ -37,6 +37,10 @@
             %span.light= _('Email:')
             %strong
               = render partial: 'shared/email_with_badge', locals: { email: mail_to(@user.email), verified: @user.confirmed? }
+          %li{ data: { testid: 'email-verification-last-sent-at' } }
+            %span.light= s_('UserProfile|Email verification last sent at:')
+            %strong
+              = @user.confirmation_sent_at&.to_fs(:medium) || _('never')
           - @user.emails.reject(&:user_primary_email?).each do |email|
             %li
               %span.light= _('Secondary email:')
@@ -94,7 +98,7 @@
                 = @user.confirmed_at.to_fs(:medium)
           - else
             %li
-              %span.ligh= _('Confirmed:')
+              %span.light= _('Confirmed:')
               %strong.cred
                 = _('No')
 
diff --git a/ee/spec/views/admin/users/show.html.haml_spec.rb b/ee/spec/views/admin/users/show.html.haml_spec.rb
index 9cbc37901d59e..b822a2c51f012 100644
--- a/ee/spec/views/admin/users/show.html.haml_spec.rb
+++ b/ee/spec/views/admin/users/show.html.haml_spec.rb
@@ -2,8 +2,8 @@
 
 require 'spec_helper'
 
-RSpec.describe 'admin/users/show.html.haml' do
-  let_it_be(:user) { create(:user, email: 'user@example.com') }
+RSpec.describe 'admin/users/show.html.haml', feature_category: :system_access do
+  let_it_be_with_reload(:user) { create(:user, email: 'user@example.com') }
 
   let(:page) { Nokogiri::HTML.parse(rendered) }
   let(:credit_card_status) { page.at('#credit-card-status')&.text }
@@ -87,4 +87,28 @@
       end
     end
   end
+
+  describe 'email verification last sent at' do
+    let(:verification_last_sent_at) { page.at('[data-testid="email-verification-last-sent-at"]') }
+
+    context 'when confirmation sent at is set' do
+      before do
+        user.update!(confirmation_sent_at: Time.zone.parse('2024-04-16 20:15:32 UTC'))
+      end
+
+      it 'shows the correct date and time' do
+        render
+
+        expect(verification_last_sent_at).to have_content('Email verification last sent at: Apr 16, 2024 8:15pm')
+      end
+    end
+
+    context 'when confirmation sent at is not set' do
+      it 'shows "never"' do
+        render
+
+        expect(verification_last_sent_at).to have_content('Email verification last sent at: never')
+      end
+    end
+  end
 end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index e664f755c265c..c8e7cdff65006 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -56108,6 +56108,9 @@ msgstr ""
 msgid "UserProfile|Edit profile"
 msgstr ""
 
+msgid "UserProfile|Email verification last sent at:"
+msgstr ""
+
 msgid "UserProfile|Explore public groups to find projects to contribute to"
 msgstr ""
 
-- 
GitLab