Skip to content

Commit

Permalink
Added a feature where the user table only renders when a string is pr…
Browse files Browse the repository at this point in the history
…esent in the search box
  • Loading branch information
domducsutcliffe committed Jan 27, 2023
1 parent 3ba3478 commit 6226877
Show file tree
Hide file tree
Showing 28 changed files with 86 additions and 24 deletions.
65 changes: 44 additions & 21 deletions app/views/crown_marketplace/manage_users/_users_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="60%"><%= t('.email') %></th>
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="15%"><%= t('.status') %></th>
<td class="govuk-table__header" width="15%"></td>
</tr>
</thead>
<tbody class="govuk-table__body">
<% if users.empty? %>
<% if !(@search[:error] || params[:email].blank?) %>
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<td class="govuk-table__cell govuk-!-padding-right-2" colspan="3"><%= t('.no_users_found') %></td>
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="60%"><%= t('.email') %></th>
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="15%"><%= t('.status') %></th>
<td class="govuk-table__header" width="15%"></td>
</tr>
<% else %>
<% users.each do |user| %>
</thead>
<tbody class="govuk-table__body">
<% if users.empty? %>
<tr class="govuk-table__row">
<td class="govuk-table__cell govuk-!-padding-right-2" style="word-break: break-all;"><%= user[:email] %></td>
<td class="govuk-table__cell govuk-!-padding-right-2"><%= govuk_tag_with_text(*enabled_disabled_status_tag(user[:account_status])) %></td>
<td class="govuk-table__cell govuk-!-padding-right-2">
<%= link_to(t('.view_user'), crown_marketplace_manage_user_path(cognito_uuid: user[:cognito_uuid]), class: 'govuk-link govuk-link--no-visited-state', aria: { label: t('.view_user_email', email: user[:email]) }) %>
</td>
<td class="govuk-table__cell govuk-!-padding-right-2" colspan="3"><%= t('.no_users_found') %></td>
</tr>
<% else %>
<% users.each do |user| %>
<tr class="govuk-table__row">
<td class="govuk-table__cell govuk-!-padding-right-2" style="word-break: break-all;"><%= user[:email] %></td>
<td class="govuk-table__cell govuk-!-padding-right-2"><%= govuk_tag_with_text(*enabled_disabled_status_tag(user[:account_status])) %></td>
<td class="govuk-table__cell govuk-!-padding-right-2">
<%= link_to(t('.view_user'), crown_marketplace_manage_user_path(cognito_uuid: user[:cognito_uuid]), class: 'govuk-link govuk-link--no-visited-state', aria: { label: t('.view_user_email', email: user[:email]) }) %>
</td>
</tr>
<% end %>
<% end %>
<% end %>
</tbody>
</table>
</tbody>
</table>
<%else%>
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="60%"><%= t('.email') %></th>
<th class="govuk-table__header govuk-!-font-weight-bold" scope="col" width="15%"><%= t('.status') %></th>
<td class="govuk-table__header" width="15%"></td>
</tr>
</thead>
<tbody class="govuk-table__body">
<% users.each do %>
<tr class="govuk-table__row">
<td class="govuk-table__cell govuk-!-padding-right-2" style="word-break: break-all;"><%= user[:email] %></td>
<td class="govuk-table__cell govuk-!-padding-right-2"><%= govuk_tag_with_text(*enabled_disabled_status_tag(user[:account_status])) %></td>
<td class="govuk-table__cell govuk-!-padding-right-2">
<%= link_to(t('.view_user'), crown_marketplace_manage_user_path(cognito_uuid: user[:cognito_uuid]), class: 'govuk-link govuk-link--no-visited-state', aria: { label: t('.view_user_email', email: user[:email]) }) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%end%>

1 change: 1 addition & 0 deletions app/views/crown_marketplace/manage_users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</div>
</div>


<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters" id="users-table">
<%= render(partial: 'users_table', locals: { users: @search[:users] }) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Manage users - Super admin - Edit user
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - Super admin - Resend temporary password
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario Outline: There is only a button for FORCE_CHANGE_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Feature: Manage users - Super admin - Edit user - Validations
When I click on 'Manage users'
Then I am on the 'Manage users' page
Given I am going to do a search to find users
Then I should not see users table
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
| Account enabled | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Feature: Manage users - Super admin - View user - Assorted Details
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users


Scenario Outline: View Buyer - Different confirmation status
And I search for '[email protected]' and there is a user with the following details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Feature: Manage users - Super admin - View user - Full Details
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users


Scenario: View Buyer - Full details
And I search for '[email protected]' and there is a user with the following details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Feature: Manage users - Super admin - View user - Mixed Roles
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users



Scenario: View Buyer and service admin
And I search for '[email protected]' and there is a user with the following details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - Super admin - View user - Something went wron
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' there are the following users:
| buyer@test.com | enabled |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - Edit user
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Manage users - User admin - Find users - JavaScript disabled
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table

Scenario: Try and find a user
Given I am going to do a search to find users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Manage users - User admin - Find users - JavaScript enabled
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for 'test@' and there are no users
And I enter 'test@' into the search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Manage users - User admin - Resend temporary password
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario Outline: There is only a button for FORCE_CHANGE_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - Edit user - Validations
Given I sign in as an 'super admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ Feature: Manage users - User admin - Find users - JavaScript enabled - Validatio
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page

Then I should not see users table

Scenario: I enter no email - JavaScript disabled
And I click on 'Search'
Then I should see the following error for finding a user:
| You must enter an email address |
Then I should not see users table

Scenario: There is a service error
And I cannot find any user accounts because of the 'service' error
And I enter 'test' into the search
And I click on 'Search'
Then I should see the following error for finding a user:
| An error occured: service |
| An error occured: service |
Then I should not see users table

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ Feature: Manage users - User admin - Find a users - JavaScript disabled - Valida
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table

Scenario: I enter no email - JavaScript disabled
And I click on 'Search'
Then I should see the following error for finding a user:
| You must enter an email address |
Then I should not see users table

Scenario: There is a service error
And I cannot find any user accounts because of the 'service' error
And I enter 'test' into the search
And I click on 'Search'
Then I should see the following error for finding a user:
| An error occured: service |
| An error occured: service |
Then I should not see users table
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - View user - Assorted Details
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario Outline: View Buyer - Different confirmation status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - View user - Full Details
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario: View Buyer - Full details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - View user - Mixed Roles
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario: View Buyer and service admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User admin - View user - Something went wron
Given I sign in as an 'user admin' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' there are the following users:
| buyer@test.com | enabled |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Manage users - User support - Edit user
When I click on 'Manage users'
Then I am on the 'Manage users' page
Given I am going to do a search to find users
Then I should not see users table
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
| Account enabled | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - Resend temporary password
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario Outline: There is only a button for FORCE_CHANGE_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - Edit user - Validations
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' and there is a user with the following details:
| Email verified | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - View user - Assorted Details
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario Outline: View Buyer - Different confirmation status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - View user - Full Details
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario: View Buyer - Full details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - View user - Mixed Roles
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users

Scenario: View Buyer and service admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Manage users - User support - View user - Something went wron
Given I sign in as an 'user support' user go to the crown marketplace dashboard
When I click on 'Manage users'
Then I am on the 'Manage users' page
Then I should not see users table
Given I am going to do a search to find users
And I search for '[email protected]' there are the following users:
| buyer@test.com | enabled |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
expect(manage_users_page.find_a_user_table.no_users).to have_content('No users were found with that email address')
end

Given('I should not see users table') do
expect(manage_users_page).not_to have_content('No users were found with that email address')
end

Then('I should see the following users in the results:') do |found_users_table|
found_users = found_users_table.raw
found_users_rows = manage_users_page.find_a_user_table.rows
Expand Down

0 comments on commit 6226877

Please sign in to comment.