Skip to content

Commit

Permalink
Merge branch 'master' into UIREQ-1188
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Dec 9, 2024
2 parents f24f6ac + ab3ef5e commit 48de066
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Migrate from `mod-circulation` to `mod-circulation-bff` for `Print pick slips` and `Print search slips`. Refs UIREQ-1154.
* Add optional column "Retrieval service point" to requests search list. Refs UIREQ-1188.
* Increase code coverage for src/ChooseRequestTypeDialog.js by Jest/RTL tests. Refs UIREQ-1044.

## [11.0.1] (https://github.com/folio-org/ui-requests/tree/v11.0.1) (2024-12-02)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v11.0.0...v11.0.1)
Expand Down
1 change: 1 addition & 0 deletions src/ChooseRequestTypeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ChooseRequestTypeDialog extends React.Component {
{isLoading ?
<Loading data-testid="loading" /> :
<Select
data-testid="requestType"
label={<FormattedMessage id="ui-requests.moveRequest.chooseRequestMessage" />}
name="requestType"
onChange={this.selectRequestType}
Expand Down
36 changes: 36 additions & 0 deletions src/ChooseRequestTypeDialog.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
render,
screen,
fireEvent,
} from '@folio/jest-config-stripes/testing-library/react';

import { Button } from '@folio/stripes/components';
Expand All @@ -23,9 +24,12 @@ jest.mock('./utils', () => ({

const labelIds = {
chooseRequestType: 'ui-requests.moveRequest.chooseRequestType',
confirmButtonLabel: 'ui-requests.moveRequest.confirm',
requestTypeError: 'ui-requests.moveRequest.error.itemLevelRequest',
};
const testIds = {
loading: 'loading',
requestType: 'requestType',
};

describe('ChooseRequestTypeDialog', () => {
Expand Down Expand Up @@ -85,6 +89,38 @@ describe('ChooseRequestTypeDialog', () => {
it('should not render Loading component', () => {
expect(screen.queryByTestId(testIds.loading)).not.toBeInTheDocument();
});

it('should handle confirmation after changing request type', () => {
const requestType = screen.getByTestId(testIds.requestType);
const confirmButton = screen.getByText(labelIds.confirmButtonLabel);
const event = {
target: {
value: '',
},
};

fireEvent.change(requestType, event);
fireEvent.click(confirmButton);

expect(mockOnConfirm).toHaveBeenCalledWith(event.target.value);
});
});

describe('When request type is not provided', () => {
const props = {
...defaultTestProps,
requestTypes: [],
};

beforeEach(() => {
render(<ChooseRequestTypeDialog {...props} />);
});

it('should render request type error', () => {
const requestTypeError = screen.getByText(labelIds.requestTypeError);

expect(requestTypeError).toBeInTheDocument();
});
});

describe('when isLoading is true', () => {
Expand Down
1 change: 1 addition & 0 deletions test/jest/__mock__/stripesComponents.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ jest.mock('@folio/stripes/components', () => ({
<select {...props}>
{props.children}
</select>
<span>{props.error}</span>
</div>)),
TextArea: jest.fn(({
'data-testid': testId,
Expand Down

0 comments on commit 48de066

Please sign in to comment.