"Empty State" for Result-less Search and Filter (#17777)
* Adds an empty state when user search & filter returns nothing * Addresses e2e failures for small screens
This commit is contained in:
parent
b155749db0
commit
b155398f17
2 changed files with 67 additions and 0 deletions
|
|
@ -100,6 +100,13 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @users.empty? %>
|
||||
<div class="align-center flex flex-col my-auto py-7" id="empty-state-message-id">
|
||||
<p class="fs-xl fw-normal mb-2">No members found under these filters.</p>
|
||||
<p class="color-secondary">Try broadening or removing the filters.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- XL screen data view end -->
|
||||
|
||||
<div class="flex justify-end xl:p-7">
|
||||
|
|
|
|||
|
|
@ -170,6 +170,43 @@ describe('User index view', () => {
|
|||
.should('equal', 'admin@forem.local');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Empty state', () => {
|
||||
// Search and filter controls are initialized async.
|
||||
// This helper function allows us to use `pipe` to retry commands in case the test runner clicks before the JS has run
|
||||
const click = (el) => el.click();
|
||||
|
||||
it('Displays an empty state when no results are returned when searching for a user', () => {
|
||||
cy.findByRole('button', { name: 'Expand search' })
|
||||
.should('have.attr', 'aria-expanded', 'false')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('textbox', {
|
||||
name: 'Search member by name, username or email',
|
||||
}).type('Not a member');
|
||||
|
||||
cy.findByRole('button', { name: 'Search' }).click();
|
||||
|
||||
// Since there aren't any results, the following message should be displayed
|
||||
cy.findByText('No members found under these filters.').should('exist');
|
||||
});
|
||||
|
||||
it('Displays an empty state when no results are returned when filtering for a user', () => {
|
||||
cy.findByRole('button', { name: 'Expand filter' })
|
||||
.should('have.attr', 'aria-expanded', 'false')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('combobox', { name: 'User role' }).select(
|
||||
'codeland_admin',
|
||||
);
|
||||
cy.findByRole('button', { name: 'Filter' }).click();
|
||||
|
||||
// Since there aren't any results, the following message should be displayed
|
||||
cy.findByText('No members found under these filters.').should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('large screens', () => {
|
||||
|
|
@ -233,6 +270,29 @@ describe('User index view', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Empty state', () => {
|
||||
it('Displays an empty state when no results are returned when searching for a user', () => {
|
||||
cy.findByRole('textbox', {
|
||||
name: 'Search member by name, username or email',
|
||||
}).type('Not a member');
|
||||
|
||||
cy.findByRole('button', { name: 'Search' }).click();
|
||||
|
||||
// Since there aren't any results, the following message should be displayed
|
||||
cy.findByText('No members found under these filters.').should('exist');
|
||||
});
|
||||
|
||||
it('Displays an empty state when no results are returned when filtering for a user', () => {
|
||||
cy.findByRole('combobox', { name: 'User role' }).select(
|
||||
'codeland_admin',
|
||||
);
|
||||
cy.findByRole('button', { name: 'Filter' }).click();
|
||||
|
||||
// Since there aren't any results, the following message should be displayed
|
||||
cy.findByText('No members found under these filters.').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
it('Copies user email to clipboard', () => {
|
||||
// Helper function for cypress-pipe
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue