Skip to content

Commit

Permalink
UIU-2987 - add unit tests and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Nov 21, 2023
1 parent 354531c commit 0fad4fc
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Also support `feesfines` interface version `19.0`. Refs UIU-2960.
* Disable validation for shadow user. Refs UIU-3000.
* Disable open loan actions for virtual patron. Refs UIU-2964.
* Hide all actionalble buttons on user details pane for DCB Virtual user. Refs UIU-2987.

## [10.0.4](https://github.com/folio-org/ui-users/tree/v10.0.4) (2023-11-10)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.3...v10.0.4)
Expand Down
39 changes: 28 additions & 11 deletions src/components/UserDetailSections/PatronBlock/PatronBlock.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen } from '@folio/jest-config-stripes/testing-library/react';
import { act, screen } from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';

import renderWithRouter from 'helpers/renderWithRouter';
Expand Down Expand Up @@ -52,20 +52,37 @@ const props = {
};

describe('render ProxyPermissions component', () => {
beforeEach(() => {
renderPatronBlock(props);
});
it('Component must be rendered', () => {
renderPatronBlock(props);
expect(screen.getByText('ui-users.settings.patronBlocks')).toBeInTheDocument();
});
it('Clicking the patron row should redirect via history.push', async () => {
await userEvent.click(document.querySelector('[data-row-inner="0"]'));
renderPatronBlock(props);
await act(async () => userEvent.click(document.querySelector('[data-row-inner="0"]')));
expect(mockRedirect).toHaveBeenCalled();
});
/* Need to fix the bug UIU-2538 for the sorting to work so that this test case can be uncommented */

// it('checking for sort order', () => {
// userEvent.click(document.querySelector('[id="clickable-list-column-blockedactions"]'));
// expect(screen.getByText('Sample')).toBeInTheDocument();
// });
it('checking for sort order', () => {
renderPatronBlock(props);
userEvent.click(document.querySelector('[id="clickable-list-column-blockedactions"]'));
expect(screen.getByText('Sample')).toBeInTheDocument();
});
describe('when user is of type "dcb"', () => {
it('should not display "Create block" button', () => {
const alteredProps = {
...props,
resources: {
selUser: {
records: [
{
personal: { lastName: 'DcbSystem' },
type: 'dcb'
}
]
}
}
};
renderPatronBlock(alteredProps);
expect(screen.queryByText('Create block')).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,39 @@ describe('Render UserAccounts component', () => {
renderUserAccounts(props(false));
expect(document.querySelector('[id="numOpenAccounts"]')).toBeNull();
});
describe('when user is of type dcb', () => {
it('should not display "Create fee/fine" button', () => {
const alteredProps = {
accounts : {
records: [accounts],
isPending: false,
},
accordionId: 'UserAccounts',
expanded: true,
onToggle: onToggleMock,
location: {
search: '',
path: '/userAccounts'
},
match: {
params: {
id: ''
}
},
resources: {
...resources,
selUser: {
records: [
{
personal: { lastName: 'DcbSystem' },
type: 'dcb'
}
]
},
},
};
renderUserAccounts(alteredProps);
expect(screen.queryByText('Create fee/fine')).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,20 @@ describe('Render User Requests component', () => {
renderUserRequests(props(false));
expect(screen.getByText('List Component')).toBeInTheDocument();
});

describe('when user is of type dcb', () => {
it('should not display "Create Request" button', () => {
const alteredProps = (perm) => {
return {
...props(perm),
user: {
personal: { lastName: 'DcbSystem' },
type: 'dcb'
},
};
};
renderUserRequests(alteredProps(true));
expect(screen.queryByText('Create Request')).toBeNull();
});
});
});
7 changes: 7 additions & 0 deletions src/views/UserDetail/UserDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,11 @@ describe('UserDetail', () => {
expect(screen.queryByText('ui-users.patronBlocks')).toBeNull();
});
});

describe('when user type is dcb', () => {
it('should not render action menu', () => {
renderUserDetail(stripes, { resources: { ...resources, selUser: { records: [{ ...resources.selUser.records[0], type: 'dcb', personal: { lastName: 'DcbSystem' } }] } } });
expect(screen.queryByText('Actions')).toBeNull();
});
});
});

0 comments on commit 0fad4fc

Please sign in to comment.