Skip to content

Commit

Permalink
Merge pull request #137 from adhocteam/274-allow-case-insensitive-search
Browse files Browse the repository at this point in the history
Allow search to be case-insensitive
  • Loading branch information
gopar authored Feb 3, 2021
2 parents db9cb58 + 2956987 commit eb867ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions frontend/src/pages/Admin/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe('Admin Page', () => {
const users = [
{
id: 2,
email: 'email',
email: '[email protected]',
name: undefined,
homeRegionId: 1,
role: 'Grantee Specialist',
permissions: [],
},
{
id: 3,
email: 'email',
email: '[email protected]',
name: 'Harry Potter',
homeRegionId: 1,
role: 'Grantee Specialist',
Expand All @@ -63,6 +63,23 @@ describe('Admin Page', () => {
expect(links[0]).toHaveTextContent('Harry Potter');
});

it('User list is filterable by email', async () => {
const filter = await screen.findByLabelText('Filter Users');
userEvent.type(filter, '@hogwarts.com');
const sideNav = screen.getByTestId('sidenav');
const links = within(sideNav).getAllByRole('link');
expect(links.length).toBe(2);
});

it('user filtering is case-insentive', async () => {
const filter = await screen.findByLabelText('Filter Users');
userEvent.type(filter, 'harry');
const sideNav = screen.getByTestId('sidenav');
const links = within(sideNav).getAllByRole('link');
expect(links.length).toBe(1);
expect(links[0]).toHaveTextContent('Harry Potter');
});

it('allows a user to be selected', async () => {
const button = await screen.findByText('Harry Potter');
userEvent.click(button);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Admin(props) {

const filteredUsers = _.filter(users, (u) => {
const { email, name } = u;
return `${email}${name}`.includes(userSearch);
return `${email}${name}`.toLowerCase().includes(userSearch.toLowerCase());
});

const onSave = async (newUser) => {
Expand Down

0 comments on commit eb867ac

Please sign in to comment.