Skip to content

Commit

Permalink
Merge pull request #9963 from DFE-Digital/344-add-the-last-login-date…
Browse files Browse the repository at this point in the history
…-for-each-person-in-support-users-page-on-support-console

[344] Surface last login date for support users
  • Loading branch information
avinhurry authored Oct 23, 2024
2 parents c1b4d6e + aff0cfd commit 2aa563d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module SupportInterface
class SupportUsersController < SupportInterfaceController
def index
@support_users = params[:removed] == 'true' ? SupportUser.discarded : SupportUser.kept
unsorted_support_users = params[:removed] == 'true' ? SupportUser.discarded : SupportUser.kept
@support_users = unsorted_support_users.order!(last_signed_in_at: :asc)
end

def show
Expand Down
4 changes: 4 additions & 0 deletions app/views/support_interface/support_users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Email</th>
<th scope="col" class="govuk-table__header">Last Login Date</th>
<th scope="col" class="govuk-table__header">DfE Sign-in UID</th>
<th scope="col" class="govuk-table__header">Actions</th>
</tr>
Expand All @@ -16,6 +17,9 @@
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<%= govuk_link_to support_user.display_name, support_interface_support_user_path(support_user) %>
</td>
<td class="govuk-table__cell">
<%= support_user.last_signed_in_at&.to_fs(:govuk_date_and_time) || 'Not signed in yet' %>
</td>
<td class="govuk-table__cell">
<%= support_user.dfe_sign_in_uid %>
Expand Down
35 changes: 33 additions & 2 deletions spec/system/support_interface/managing_support_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
given_i_am_a_support_user

when_i_visit_the_support_console
and_i_click_the_manange_support_users_link
and_i_click_the_manage_support_users_link
and_i_click_the_add_user_link
and_i_enter_the_users_email_and_dsi_uid
and_i_click_add_user
Expand All @@ -23,6 +23,37 @@
then_i_see_an_error
end

scenario 'orders users by last login date', :with_audited do
given_i_am_a_support_user

when_i_visit_the_support_console
and_there_are_other_support_users_in_the_db
and_i_click_the_manage_support_users_link
and_i_see_the_last_login_date_column
then_i_see_users_ordered_by_oldest_login
end

def then_i_see_users_ordered_by_oldest_login
emails = page.all('tbody .govuk-table__row td:first-child a.govuk-link').map(&:text)

expect(emails).to eq([
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
])
end

def and_i_see_the_last_login_date_column
expect(page).to have_css('th.govuk-table__header', text: 'Last Login Date')
end

def and_there_are_other_support_users_in_the_db
SupportUser.create(email_address: '[email protected]', last_signed_in_at: Time.zone.yesterday, dfe_sign_in_uid: 'Y')
SupportUser.create(email_address: '[email protected]', last_signed_in_at: Time.zone.now, dfe_sign_in_uid: 'TD')
SupportUser.create(email_address: '[email protected]', last_signed_in_at: Time.zone.tomorrow, dfe_sign_in_uid: 'TM')
end

def given_i_am_a_support_user
sign_in_as_support_user
end
Expand All @@ -31,7 +62,7 @@ def when_i_visit_the_support_console
visit support_interface_path
end

def and_i_click_the_manange_support_users_link
def and_i_click_the_manage_support_users_link
click_link_or_button 'Settings'
click_link_or_button 'Support users'
end
Expand Down

0 comments on commit 2aa563d

Please sign in to comment.