Skip to content

Commit

Permalink
Added functionality to not render table if there is a non-params empt…
Browse files Browse the repository at this point in the history
…y error
  • Loading branch information
domducsutcliffe committed Jan 26, 2023
1 parent 64fc88a commit eda4fde
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
7 changes: 2 additions & 5 deletions app/controllers/crown_marketplace/manage_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ class CrownMarketplace::ManageUsersController < CrownMarketplace::FrameworkContr
helper_method :section, :available_roles, :role_requires_service_access?, :can_edit_user?, :permitted_sections

def index
if @flag.nil? && (request.get? && params[:email].present?)
@form_submitted_once = true
@flag = true
end

@search = if find_user_params.empty?
{ users: [] }
else
Cognito::Admin::User.search(find_user_params[:email])
end

@form_submitted_success = !(@search[:error] || params[:email].blank?)

respond_to do |format|
format.js
format.html { render :index }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%if @form_submitted_once %>
<% if @form_submitted_success %>
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
Expand Down
9 changes: 2 additions & 7 deletions app/views/crown_marketplace/manage_users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@
</div>
</div>

<div id='form-submitted'></div>


<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters" id="users-table">
<%= render(partial: 'users_table', locals: { users: @search[:users], extra_data_1: @form_submitted_once, extra_data_2: @flag }) %>
<%= render(partial: 'users_table', locals: { users: @search[:users] }) %>
</div>
</div>


</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ 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

Scenario: I should not see the 'No found users' results
Then I should not see that there are no users with that email address

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:
Expand All @@ -19,4 +17,4 @@ Feature: Manage users - User admin - Find users - JavaScript enabled - Validatio
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 |
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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 that there are no users with that email address') do
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

Expand Down

0 comments on commit eda4fde

Please sign in to comment.