diff --git a/CHANGELOG.md b/CHANGELOG.md index f530af07..e19619b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,11 @@ # Change history for ui-requests -## 10.0.0 IN PROGRESS +## 9.2.0 IN PROGRESS * Use settings/entries endpoint to get settings information. Refs UIREQ-1062. * Use Save & close button label stripes-component translation key. Refs UIREQ-1073. * Include single print and selection print options on results list and actions menu. Refs UIREQ-966. * Set up default pickup service point if it is available. Refs UIREQ-1095. -* Remove bigtests from github actions. Refs UIREQ-1099. * Requests app.: Editing requests (ECS with mod-tlr enabled). Refs UIREQ-1088. * Requests app.: Cancelling request (ECS with mod-tlr enabled). Refs UIREQ-1090. * Requests app.: Reorder request queue (ECS with mod-tlr enabled). Refs UIREQ-1098. @@ -22,14 +21,25 @@ * Implement availability of "Printed" and "# Copies" columns upon "Enable view print details (Pick slips)" configuration. Refs UIREQ-1121. * Implement availability of "Print status" filters upon "Enable view print details (Pick slips)" configuration. Refs UIREQ-1119. * Hide Duplicate and Move action buttons in ECS env with mod-tlr enabled. Refs UIREQ-1127, UIREQ-1125. -* Fix issue with Proxy's patron group and delivery address that shown instead of Sponsor's when creating request. Refs UIREQ-1132, UIREQ-1133. * Add missing sub-permissions to fetch staff slips records. Refs UIREQ-1129. * Add missing sub-permissions to fetch "pick-slips" and "search-slips" records in "Requests: View, edit, cancel" permission. Refs UIREQ-1137. * Update permissions set to be able to get item/instance information. Refs UIREQ-1148. +* Optimize performance of the "print-events-entry" API to reduce slowness during the initial call. Refs UIREQ-1130. * *BREAKING* Migrate to new endpoints to get request types and to create a new request. Refs UIREQ-1113. +* Revert Custom "Print Status" filter code implementation. Refs UIREQ-1146. +* Add sorting to 'Printed' and '# Copies' columns in the Request App. Refs UIREQ-1140. +* Implement "Print Status" filters as server-side filters. Refs UIREQ-1147. +* Navigate to first page when saving the pick slip print log from beyond the first page. Refs UIREQ-1145. + +## [9.1.2] (https://github.com/folio-org/ui-requests/tree/v9.1.2) (2024-09-13) +[Full Changelog](https://github.com/folio-org/ui-requests/compare/v9.1.1...v9.1.2) + +* Remove bigtests from github actions. Refs UIREQ-1099. +* Fix issue with Proxy's patron group and delivery address that shown instead of Sponsor's when creating request. Refs UIREQ-1132, UIREQ-1133. +* Update upload-artifact actions from v1 and v2 to v4. Refs UIREQ-1150. -## [9.1.1] (https://github.com/folio-org/ui-checkin/tree/v9.1.1) (2024-03-27) -[Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.1.0...v9.1.1) +## [9.1.1] (https://github.com/folio-org/ui-requests/tree/v9.1.1) (2024-03-27) +[Full Changelog](https://github.com/folio-org/ui-requests/compare/v9.1.0...v9.1.1) * Add support for Barcode tag with sanitize. Refs UIREQ-1080, UIREQ-1082. diff --git a/src/components/PrintButton/PrintButton.js b/src/components/PrintButton/PrintButton.js index df76284f..0782c06d 100644 --- a/src/components/PrintButton/PrintButton.js +++ b/src/components/PrintButton/PrintButton.js @@ -40,9 +40,9 @@ class PrintButton extends React.Component { this.props.onBeforeGetContent(); } - handleBeforePrint = () => { - this.props.onBeforePrint([this.props.requestId]); - } + handleBeforePrint = async () => { + await this.props.onBeforePrint([this.props.requestId]); + }; renderTriggerButton = () => { const fieldsToSkip = ['contentRef', 'onBeforePrint', 'onAfterPrint', 'onBeforeGetContent']; diff --git a/src/components/RequestsFilters/RequestsFiltersConfig.js b/src/components/RequestsFilters/RequestsFiltersConfig.js index b48322f4..8268f7d2 100644 --- a/src/components/RequestsFilters/RequestsFiltersConfig.js +++ b/src/components/RequestsFilters/RequestsFiltersConfig.js @@ -43,4 +43,19 @@ export default [ values: [], operator: '==', }, + { + name: requestFilterTypes.PRINT_STATUS, + cql: 'printStatus', + values: [], + operator: '==', + parse: (value) => { + if (value.length === 1 && value.includes('Printed')) { + return 'printDetails.isPrinted==true'; + } else if (value.length === 1 && value.includes('Not printed')) { + return 'cql.allRecords=1 NOT printDetails.isPrinted=""'; + } else { + return '(cql.allRecords=1 NOT printDetails.printed="" or printDetails.printed==true)'; + } + } + }, ]; diff --git a/src/components/RequestsFilters/RequestsFiltersConfig.test.js b/src/components/RequestsFilters/RequestsFiltersConfig.test.js index ff3fb106..b6d13606 100644 --- a/src/components/RequestsFilters/RequestsFiltersConfig.test.js +++ b/src/components/RequestsFilters/RequestsFiltersConfig.test.js @@ -81,6 +81,40 @@ describe('RequestsFiltersConfig', () => { expect(pickupServicePointFilter).toEqual(expectedResult); }); + describe('Print Status Filter configuration', () => { + it('should correctly match the filter configuration for printStatus', () => { + const printStatusFilter = filtersConfig.find(f => f.name === 'printStatus'); + const expectedResult = { + name: 'printStatus', + cql: 'printStatus', + values: [], + operator: '==', + parse: expect.any(Function), + }; + + expect(printStatusFilter).toEqual(expectedResult); + }); + + it('should generate the correct query string for the "Printed" filter', () => { + const printStatusFilter = filtersConfig.find(f => f.name === 'printStatus'); + + expect(printStatusFilter.parse(['Printed'])).toEqual('printDetails.isPrinted==true'); + }); + + it('should generate the correct query string for the "Not printed" filter', () => { + const printStatusFilter = filtersConfig.find(f => f.name === 'printStatus'); + + expect(printStatusFilter.parse(['Not printed'])).toEqual('cql.allRecords=1 NOT printDetails.isPrinted=""'); + }); + + it('should generate the correct query string for a combination of "Printed" and "Not printed" filters', () => { + const printStatusFilter = filtersConfig.find(f => f.name === 'printStatus'); + + expect(printStatusFilter.parse(['Printed', 'Not printed'])) + .toEqual('(cql.allRecords=1 NOT printDetails.printed="" or printDetails.printed==true)'); + }); + }); + describe('escapingForSpecialCharactersWhichCanBreakCQL', () => { it('should return empty string', () => { expect(escapingForSpecialCharactersWhichCanBreakCQL()).toBe(''); diff --git a/src/components/SinglePrintButtonForPickSlip/SinglePrintButtonForPickSlip.js b/src/components/SinglePrintButtonForPickSlip/SinglePrintButtonForPickSlip.js index d66047ec..db7651e6 100644 --- a/src/components/SinglePrintButtonForPickSlip/SinglePrintButtonForPickSlip.js +++ b/src/components/SinglePrintButtonForPickSlip/SinglePrintButtonForPickSlip.js @@ -15,6 +15,7 @@ const SinglePrintButtonForPickSlip = ({ pickSlipsData, onBeforeGetContentForSinglePrintButton, onBeforePrintForSinglePrintButton, + onAfterPrintForSinglePrintButton, getPrintContentRef, }) => { const disabled = !isPrintable(request.id, pickSlipsToCheck); @@ -28,6 +29,7 @@ const SinglePrintButtonForPickSlip = ({ requestId={request.id} onBeforeGetContent={onBeforeGetContentForSinglePrintButton} onBeforePrint={onBeforePrintForSinglePrintButton} + onAfterPrint={onAfterPrintForSinglePrintButton} > { ], onBeforeGetContentForSinglePrintButton: jest.fn(), onBeforePrintForSinglePrintButton: jest.fn(), + onAfterPrintForSinglePrintButton: jest.fn(), getPrintContentRef: mockAccordionStatusRef, }; diff --git a/src/constants.js b/src/constants.js index 20538fed..a2890983 100644 --- a/src/constants.js +++ b/src/constants.js @@ -170,7 +170,7 @@ export const requestableItemStatuses = [ ]; export const PRINT_DETAILS_COLUMNS = { - COPIES: 'printDetails.count', + COPIES: 'printDetails.printCount', PRINTED: 'printDetails.lastPrintedDetails', }; diff --git a/src/index.test.js b/src/index.test.js index 03399b5d..e082153f 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -62,7 +62,7 @@ describe('UI Requests', () => { it('should close keyboard shortcuts modal on clicking close button', () => { fireEvent.click(screen.getByText(labelIds.keyboardShortcuts)); - const button = screen.getByRole('button', { name: /stripes-components.dismissModal/i }); + const button = screen.getByLabelText('stripes-components.dismissModal'); fireEvent.click(button); diff --git a/src/routes/RequestsRoute.js b/src/routes/RequestsRoute.js index 5b28e6c7..9275ae21 100644 --- a/src/routes/RequestsRoute.js +++ b/src/routes/RequestsRoute.js @@ -112,8 +112,7 @@ import { getFormattedYears, getStatusQuery, getFullNameForCsvRecords, - getPrintStatusFilteredData, - filterRecordsByPrintStatus, + updateQuerySortString, } from './utils'; import SinglePrintButtonForPickSlip from '../components/SinglePrintButtonForPickSlip'; @@ -141,8 +140,8 @@ export const extractPickSlipRequestIds = (pickSlipsData) => { export const getLastPrintedDetails = (printDetails, intl) => { const fullName = getFullName(printDetails?.lastPrintRequester); - const formattedDate = intl.formatDate(printDetails?.lastPrintedDate); - const formattedTime = intl.formatTime(printDetails?.lastPrintedDate); + const formattedDate = intl.formatDate(printDetails?.printEventDate); + const formattedTime = intl.formatTime(printDetails?.printEventDate); const localizedDateTime = `${formattedDate}${formattedTime ? ', ' : ''}${formattedTime}`; return fullName + ' ' + localizedDateTime; @@ -258,6 +257,7 @@ export const getListFormatter = ( toggleRowSelection, onBeforeGetContentForSinglePrintButton, onBeforePrintForSinglePrintButton, + onAfterPrintForSinglePrintButton, } ) => ({ 'select': rq => ( @@ -284,7 +284,8 @@ export const getListFormatter = ( pickSlipsData, getPrintContentRef, ...(isViewPrintDetailsEnabled && { - onBeforePrintForSinglePrintButton + onBeforePrintForSinglePrintButton, + onAfterPrintForSinglePrintButton, }), }; return ( @@ -318,8 +319,6 @@ export const buildHoldRecords = (records) => { }); }; -export const viewPrintDetailsPath = 'circulationSettings.records[0].value.enablePrintLog'; - class RequestsRoute extends React.Component { static contextType = CalloutContext; @@ -365,6 +364,8 @@ class RequestsRoute extends React.Component { 'requestDate': 'requestDate', 'position': 'position/number', 'proxy': 'proxy', + 'copies': 'printDetails.printCount/number', + 'printed': 'printDetails.printEventDate', }, RequestsFiltersConfig, 2, // do not fetch unless we have a query or a filter @@ -528,6 +529,9 @@ class RequestsRoute extends React.Component { requestCount: PropTypes.shape({ replace: PropTypes.func, }), + resultOffset: PropTypes.shape({ + replace: PropTypes.func, + }), resultCount: PropTypes.shape({ replace: PropTypes.func, }), @@ -667,7 +671,6 @@ class RequestsRoute extends React.Component { titleLevelRequestsFeatureEnabled, createTitleLevelRequestsByDefault, isViewPrintDetailsEnabled: false, - selectedPrintStatusFilters: [], }; this.pickSlipsPrintContentRef = React.createRef(); @@ -679,7 +682,7 @@ class RequestsRoute extends React.Component { static getDerivedStateFromProps(props, state) { const layer = (props.resources.query || {}).layer; const newState = {}; - const currViewPrintDetailsSettings = get(props.resources, viewPrintDetailsPath) === 'true'; + const currViewPrintDetailsSettings = get(props.resources, 'circulationSettings.records[0].value.enablePrintLog') === 'true'; if (!layer) { newState.dupRequest = null; @@ -703,13 +706,12 @@ class RequestsRoute extends React.Component { } } - componentDidUpdate(prevProps, prevState) { + componentDidUpdate(prevProps) { + const { stripes } = this.props; const { submitting, isViewPrintDetailsEnabled, - selectedPrintStatusFilters, } = this.state; - const { stripes } = this.props; const patronBlocks = get(this.props.resources, ['patronBlocks', 'records'], []); const prevBlocks = get(prevProps.resources, ['patronBlocks', 'records'], []); const prevExpired = prevBlocks.filter(p => moment(moment(p.expirationDate).format()).isSameOrBefore(moment().format()) && p.expirationDate) || []; @@ -717,8 +719,9 @@ class RequestsRoute extends React.Component { const { id: currentServicePointId } = this.getCurrentServicePointInfo(); const prevStateServicePointId = get(prevProps.resources.currentServicePoint, 'id'); const { configs: prevConfigs } = prevProps.resources; - const { configs, query: { filters } } = this.props.resources; - const instanceId = parse(this.props.location?.search)?.instanceId; + const { resources, location, mutator } = this.props; + const { configs, query } = resources; + const instanceId = parse(location?.search)?.instanceId; if (prevExpired.length > 0 && expired.length === 0) { // eslint-disable-next-line react/no-did-update-set-state @@ -729,8 +732,8 @@ class RequestsRoute extends React.Component { // eslint-disable-next-line react/no-did-update-set-state this.setState({ submitting: true }); expired.forEach(p => { - this.props.mutator.activeRecord.update({ blockId: p.id }); - this.props.mutator.patronBlocks.DELETE({ id: p.id }); + mutator.activeRecord.update({ blockId: p.id }); + mutator.patronBlocks.DELETE({ id: p.id }); }); } @@ -751,22 +754,16 @@ class RequestsRoute extends React.Component { }); } - if (!this.props.resources.query.instanceId && instanceId) { - this.props.mutator.query.update({ instanceId }); - } - - if (!this.props.resources.records.isPending) { - this.onSearchComplete(this.props.resources.records); + if (!query.instanceId && instanceId) { + mutator.query.update({ instanceId }); } - if (isViewPrintDetailsEnabled !== prevState.isViewPrintDetailsEnabled && !isViewPrintDetailsEnabled) { - this.columnHeadersMap = getFilteredColumnHeadersMap(this.columnHeadersMap); + if (!resources.records.isPending) { + this.onSearchComplete(resources.records); } - if (filters?.includes(requestFilterTypes.PRINT_STATUS)) { - const printStatusFilterInQuery = this.getActiveFilters()[requestFilterTypes.PRINT_STATUS]; - - this.updateSelectedPrintStatusFilters(isViewPrintDetailsEnabled, selectedPrintStatusFilters, printStatusFilterInQuery); + if (!isViewPrintDetailsEnabled) { + this.handlePrintDetailsDisabled(); } if (stripes?.user?.user?.tenants && stripes.user.user !== prevProps.stripes?.user?.user) { @@ -805,22 +802,28 @@ class RequestsRoute extends React.Component { } } - updateSelectedPrintStatusFilters(isViewPrintDetailsEnabled, selectedPrintStatusFilters, printStatusFilterInQuery) { + handlePrintDetailsDisabled() { /** - * Updates the `selectedPrintStatusFilters` state based on pre selected filters when user navigates back to Request App. - * - * The function performs the following actions: - * 1. If `isViewPrintDetailsEnabled` is true and if `Print Status` filters contains exactly one filter: - * - it updates state to set `selectedPrintStatusFilters` to this one `Print Status` filter. + * The function handles the following actions when `isViewPrintDetailsEnabled` is false: * - * 2. If `isViewPrintDetailsEnabled` is false and `filters` in query includes 'PRINT STATUS' filter: + * 1. If `filters` in query includes 'PRINT STATUS' filter: * - it clears the 'PRINT STATUS' filter from query by invoking `handleFilterChange`. - */ - if (isViewPrintDetailsEnabled && selectedPrintStatusFilters.length === 0 && printStatusFilterInQuery?.length === 1) { - this.setState({ selectedPrintStatusFilters: [printStatusFilterInQuery[0]] }); - } else if (!isViewPrintDetailsEnabled && printStatusFilterInQuery?.length) { + * + * 2. If `sort` in query includes sort by 'printed' or 'copies' column: + * - it removes sorting by 'printed' or 'copies' from the sort query. If both are being sorted, + * the sorting is updated to 'requestDate' instead. + */ + const { resources: { query }, mutator } = this.props; + const printStatusFilterInQuery = this.getActiveFilters()[requestFilterTypes.PRINT_STATUS]; + + if (printStatusFilterInQuery?.length) { this.handleFilterChange({ name: requestFilterTypes.PRINT_STATUS, values: [] }); } + + if (query.sort?.includes('printed') || query.sort?.includes('copies')) { + const sort = updateQuerySortString(query.sort); + mutator.query.update({ sort }); + } } toggleAllRows = () => { @@ -897,11 +900,6 @@ class RequestsRoute extends React.Component { // Export function for the CSV search report action async exportData() { this.setState({ csvReportPending: true }); - const { isViewPrintDetailsEnabled, selectedPrintStatusFilters } = this.state; - - const activeFilters = this.getActiveFilters(); - const activeFilterKeys = Object.keys(activeFilters); - const isOnlyPrintStatusFilterSelected = activeFilterKeys.length === 1 && activeFilterKeys[0] === requestFilterTypes.PRINT_STATUS; // Build a custom query for the CSV record export, which has to include // all search and filter parameters @@ -909,21 +907,20 @@ class RequestsRoute extends React.Component { let queryString; const queryTerm = this.props.resources?.query?.query; - const filterQuery = filters2cql(RequestsFiltersConfig, deparseFilters(activeFilters)); + const filterQuery = filters2cql(RequestsFiltersConfig, deparseFilters(this.getActiveFilters())); if (queryTerm) { queryString = `(requesterId=="${queryTerm}" or requester.barcode="${queryTerm}*" or item.title="${queryTerm}*" or item.barcode=="${queryTerm}*" or itemId=="${queryTerm}")`; queryClauses.push(queryString); } if (filterQuery) queryClauses.push(filterQuery); - if (isOnlyPrintStatusFilterSelected) queryClauses.push('cql.allRecords=1'); queryString = queryClauses.join(' and '); const records = await this.fetchReportData(this.props.mutator.reportRecords, queryString); + const recordsToCSV = this.buildRecords(records); - const printStatusFilteredRecords = isViewPrintDetailsEnabled && selectedPrintStatusFilters.length === 1 && - filterRecordsByPrintStatus(records, selectedPrintStatusFilters); - const recordsToCSV = this.buildRecords(printStatusFilteredRecords || records); + this.columnHeadersMap = this.state.isViewPrintDetailsEnabled ? this.columnHeadersMap : + getFilteredColumnHeadersMap(this.columnHeadersMap); exportCsv(recordsToCSV, { onlyFields: this.columnHeadersMap, @@ -989,7 +986,7 @@ class RequestsRoute extends React.Component { } if (record.printDetails) { const fullName = getFullNameForCsvRecords(record.printDetails.lastPrintRequester); - const lastPrintedDate = record.printDetails.lastPrintedDate || ''; + const lastPrintedDate = record.printDetails.printEventDate || ''; const date = lastPrintedDate ? `, ${lastPrintedDate}` : ''; record.printDetails.lastPrintedDetails = `${fullName}${date}`; @@ -1317,10 +1314,6 @@ class RequestsRoute extends React.Component { } handleFilterChange = ({ name, values }) => { - if (name === requestFilterTypes.PRINT_STATUS) { - this.setState({ selectedPrintStatusFilters: values }); - } - const { mutator } = this.props; const newFilters = { ...this.getActiveFilters(), @@ -1375,18 +1368,23 @@ class RequestsRoute extends React.Component { ); }; - savePrintEventDetails = (requestIds) => { + savePrintEventDetails = async (requestIds) => { const currDateTime = new Date(); const printTimeStamp = currDateTime.toISOString(); const { id: loggedInUserId, username: loggedInUsername } = this.props.stripes.user.user; - this.props.mutator.savePrintDetails.POST({ - 'requestIds' : requestIds, - 'requesterName' : loggedInUsername, - 'requesterId' : loggedInUserId, - 'printEventDate' : printTimeStamp - }); - } + try { + await this.props.mutator.savePrintDetails.POST({ + 'requestIds': requestIds, + 'requesterName': loggedInUsername, + 'requesterId': loggedInUserId, + 'printEventDate': printTimeStamp + }); + } catch (error) { + // eslint-disable-next-line no-console + console.error('Failed to save print event details:', error); + } + }; onBeforeGetContentForPrintButton = (onToggle) => ( new Promise(resolve => { @@ -1405,6 +1403,12 @@ class RequestsRoute extends React.Component { }) ); + onAfterPrintForPrintButton = () => { + if (this.state.isViewPrintDetailsEnabled) { + this.props.mutator.resultOffset.replace(0); + } + } + printContentRefs = {}; getPrintContentRef = (rqId) => { @@ -1463,7 +1467,6 @@ class RequestsRoute extends React.Component { isViewPrintDetailsEnabled, isEcsTlrSettingReceived, isEcsTlrSettingEnabled, - selectedPrintStatusFilters, } = this.state; const isPrintHoldRequestsEnabled = getPrintHoldRequestsEnabled(resources.printHoldRequests); const { name: servicePointName } = this.getCurrentServicePointInfo(); @@ -1509,7 +1512,6 @@ class RequestsRoute extends React.Component { const isPickSlipsArePending = resources?.pickSlips?.isPending; const isSearchSlipsArePending = resources?.searchSlips?.isPending; - const isRequestsRecordsLoaded = resources.records.hasLoaded; const requestsEmpty = isEmpty(requests); const isPickSlipsEmpty = isEmpty(pickSlips); const isSearchSlipsEmpty = isEmpty(searchSlips); @@ -1518,14 +1520,6 @@ class RequestsRoute extends React.Component { const pickSlipsData = convertToSlipData(pickSlips, intl, timezone, locale, SLIPS_TYPE.PICK_SLIP, user); const searchSlipsData = convertToSlipData(searchSlips, intl, timezone, locale, SLIPS_TYPE.SEARCH_SLIP_HOLD_REQUESTS); let multiSelectPickSlipData = getSelectedSlipDataMulti(pickSlipsData, selectedRows); - /** - * For 'displayPrintStatusFilteredData' to be true the length of 'selectedPrintStatusFilters' must be 1. - * This is because we only filter data when exactly one PrintStatus filter is selected ([Printed] or [Not Printed]). - * If the filter array is empty or contains both filters ([] or [Printed, Not Printed]), - * no filtering is needed as the data should be used directly from the query response. - */ - const displayPrintStatusFilteredData = isViewPrintDetailsEnabled && - isRequestsRecordsLoaded && selectedPrintStatusFilters.length === 1; const resultsFormatter = getListFormatter( { @@ -1543,6 +1537,7 @@ class RequestsRoute extends React.Component { toggleRowSelection: this.toggleRowSelection, onBeforeGetContentForSinglePrintButton: this.onBeforeGetContentForSinglePrintButton, onBeforePrintForSinglePrintButton: this.savePrintEventDetails, + onAfterPrintForSinglePrintButton: this.onAfterPrintForPrintButton, } ); @@ -1606,12 +1601,13 @@ class RequestsRoute extends React.Component { template={pickSlipsPrintTemplate} contentRef={this.pickSlipsPrintContentRef} onBeforeGetContent={() => this.onBeforeGetContentForPrintButton(onToggle)} - onBeforePrint={() => { + onBeforePrint={async () => { if (isViewPrintDetailsEnabled) { const requestIds = extractPickSlipRequestIds(pickSlipsData); - this.savePrintEventDetails(requestIds); + await this.savePrintEventDetails(requestIds); } }} + onAfterPrint={this.onAfterPrintForPrintButton} > { + async () => { if (isViewPrintDetailsEnabled) { const selectedPickSlips = getSelectedSlipDataMulti(pickSlipsData, selectedRows); const selectedRequestIds = extractPickSlipRequestIds(selectedPickSlips); - this.savePrintEventDetails(selectedRequestIds); + await this.savePrintEventDetails(selectedRequestIds); } } } + onAfterPrint={this.onAfterPrintForPrintButton} > diff --git a/src/routes/RequestsRoute.test.js b/src/routes/RequestsRoute.test.js index d855d174..a6a4d2cf 100644 --- a/src/routes/RequestsRoute.test.js +++ b/src/routes/RequestsRoute.test.js @@ -123,8 +123,6 @@ jest.mock('./utils', () => ({ ...jest.requireActual('./utils'), getFormattedYears: jest.fn(), getStatusQuery: jest.fn(), - filterRecordsByPrintStatus: jest.fn(), - getPrintStatusFilteredData: jest.fn(), })); jest.mock('../components', () => ({ ErrorModal: jest.fn(({ onClose }) => ( @@ -141,11 +139,13 @@ jest.mock('../components', () => ({ PrintButton: jest.fn(({ onBeforeGetContent, onBeforePrint, + onAfterPrint, children, }) => { const handleClick = () => { - onBeforeGetContent(); - onBeforePrint(); + Promise.resolve(onBeforeGetContent()); + Promise.resolve(onBeforePrint()); + Promise.resolve(onAfterPrint()); }; return (
@@ -178,10 +178,12 @@ jest.mock('../RequestForm', () => jest.fn()); jest.mock('../components/SinglePrintButtonForPickSlip', () => jest.fn(({ onBeforeGetContentForSinglePrintButton, onBeforePrintForSinglePrintButton, + onAfterPrintForSinglePrintButton, }) => { const handleClick = () => { onBeforeGetContentForSinglePrintButton(); onBeforePrintForSinglePrintButton(['reqId']); + onAfterPrintForSinglePrintButton(); }; return (