-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIREQMED-42: Add Decline Action for Mediated request with status of N…
…ew - Awaiting confirmation
- Loading branch information
1 parent
cfe0c4d
commit 85ac249
Showing
13 changed files
with
319 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...uestsActivities/components/MediatedRequestsDetail/components/DeclineModal/DeclineModal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { | ||
Button, | ||
Modal, | ||
ModalFooter, | ||
} from '@folio/stripes/components'; | ||
|
||
const DeclineModal = ({ | ||
open, | ||
title, | ||
onConfirm, | ||
onClose, | ||
}) => { | ||
const footer = ( | ||
<ModalFooter> | ||
<Button | ||
data-testid="confirmButton" | ||
buttonStyle="primary" | ||
onClick={onConfirm} | ||
> | ||
<FormattedMessage id="ui-requests-mediated.declineModal.confirm" /> | ||
</Button> | ||
<Button | ||
data-testid="backButton" | ||
onClick={onClose} | ||
> | ||
<FormattedMessage id="ui-requests-mediated.declineModal.back" /> | ||
</Button> | ||
</ModalFooter> | ||
); | ||
|
||
return ( | ||
<Modal | ||
dismissible | ||
label={<FormattedMessage id="ui-requests-mediated.declineModal.title" />} | ||
open={open} | ||
size="small" | ||
footer={footer} | ||
onClose={onClose} | ||
> | ||
<FormattedMessage | ||
id="ui-requests-mediated.declineModal.message" | ||
values={{ title }} | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
|
||
DeclineModal.propTypes = { | ||
open: PropTypes.bool.isRequired, | ||
title: PropTypes.string.isRequired, | ||
onConfirm: PropTypes.func.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default DeclineModal; |
76 changes: 76 additions & 0 deletions
76
...Activities/components/MediatedRequestsDetail/components/DeclineModal/DeclineModal.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
render, | ||
screen, | ||
fireEvent, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import DeclineModal from './DeclineModal'; | ||
|
||
const testIds = { | ||
confirmButton: 'confirmButton', | ||
backButton: 'backButton', | ||
}; | ||
const messageIds = { | ||
title: 'ui-requests-mediated.declineModal.title', | ||
message: 'ui-requests-mediated.declineModal.message', | ||
confirmButton: 'ui-requests-mediated.declineModal.confirm', | ||
backButton: 'ui-requests-mediated.declineModal.back', | ||
}; | ||
const defaultProps = { | ||
open: true, | ||
title: 'Title', | ||
onConfirm: jest.fn(), | ||
onClose: jest.fn(), | ||
}; | ||
|
||
describe('DeclineModal', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
beforeEach(() => { | ||
render( | ||
<DeclineModal {...defaultProps} /> | ||
); | ||
}); | ||
|
||
it('should render title', () => { | ||
expect(screen.getByText(messageIds.title)).toBeVisible(); | ||
}); | ||
|
||
it('should render message', () => { | ||
expect(screen.getByText(messageIds.message)).toBeVisible(); | ||
}); | ||
|
||
describe('Confirm button', () => { | ||
it('should render confirm button', () => { | ||
expect(screen.getByTestId(testIds.confirmButton)).toBeVisible(); | ||
}); | ||
|
||
it('should render confirm button text', () => { | ||
expect(screen.getByText(messageIds.confirmButton)).toBeVisible(); | ||
}); | ||
|
||
it('should call onConfirm', () => { | ||
fireEvent.click(screen.getByTestId(testIds.confirmButton)); | ||
|
||
expect(defaultProps.onConfirm).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('Back button', () => { | ||
it('should render back button', () => { | ||
expect(screen.getByTestId(testIds.backButton)).toBeVisible(); | ||
}); | ||
|
||
it('should render back button text', () => { | ||
expect(screen.getByText(messageIds.backButton)).toBeVisible(); | ||
}); | ||
|
||
it('should call onClose', () => { | ||
fireEvent.click(screen.getByTestId(testIds.backButton)); | ||
|
||
expect(defaultProps.onClose).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
...atedRequestsActivities/components/MediatedRequestsDetail/components/DeclineModal/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './DeclineModal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.