Skip to content

Commit

Permalink
UIREQ-1138 Change import of exportToCsv from stripes-util to `str…
Browse files Browse the repository at this point in the history
…ipes-components`
  • Loading branch information
BogdanDenis committed Jan 27, 2025
1 parent ee3b85f commit db911ee
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* React v19: refactor away from default props for functional components. Refs UIREQ-1101.
* Add icons to requests action menu. Refs UIREQ-1116.
* Revise "Enter" button on New request page. Refs UIREQ-1114.
* Change import of `exportToCsv` from `stripes-util` to `stripes-components`. Refs UIREQ-1138.

## [11.0.3] (https://github.com/folio-org/ui-requests/tree/v11.0.3) (2025-01-10)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v11.0.2...v11.0.3)
Expand Down
8 changes: 4 additions & 4 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import {
NoValue,
MCLPagingTypes,
Icon,
exportToCsv,
} from '@folio/stripes/components';
import {
deparseFilters,
makeQueryFunction,
SearchAndSort,
} from '@folio/stripes/smart-components';
import {
exportCsv,
effectiveCallNumber,
getHeaderWithCredentials,
} from '@folio/stripes/util';
Expand Down Expand Up @@ -638,7 +638,7 @@ class RequestsRoute extends React.Component {
this.findResource = this.findResource.bind(this);
this.toggleModal = this.toggleModal.bind(this);
this.buildRecords = this.buildRecords.bind(this);
// Map to pass into exportCsv
// Map to pass into exportToCsv
this.columnHeadersMap = this.getColumnHeaders(reportHeaders);
this.expiredHoldsReportColumnHeaders = this.getColumnHeaders(expiredHoldsReportHeaders);

Expand Down Expand Up @@ -860,7 +860,7 @@ class RequestsRoute extends React.Component {
this.columnHeadersMap = this.state.isViewPrintDetailsEnabled ? this.columnHeadersMap :
getFilteredColumnHeadersMap(this.columnHeadersMap);

exportCsv(recordsToCSV, {
exportToCsv(recordsToCSV, {
onlyFields: this.columnHeadersMap,
excludeFields: ['id'],
});
Expand Down Expand Up @@ -1211,7 +1211,7 @@ class RequestsRoute extends React.Component {
}

const recordsToCSV = buildHoldRecords(requests);
exportCsv(recordsToCSV, {
exportToCsv(recordsToCSV, {
onlyFields: this.expiredHoldsReportColumnHeaders,
excludeFields: ['id'],
});
Expand Down
14 changes: 6 additions & 8 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import {
import {
TextLink,
Checkbox,
exportToCsv,
} from '@folio/stripes/components';
import {
exportCsv,
effectiveCallNumber,
} from '@folio/stripes/util';
import { effectiveCallNumber } from '@folio/stripes/util';

import RequestsRoute, {
buildHoldRecords,
Expand Down Expand Up @@ -610,11 +608,11 @@ describe('RequestsRoute', () => {
expect(printContent).toBeInTheDocument();
});

it('should trigger "exportCsv"', async () => {
it('should trigger "exportToCsv"', async () => {
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
expect(exportToCsv).toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -818,12 +816,12 @@ describe('RequestsRoute', () => {
expect(defaultProps.mutator.savePrintDetails.POST).not.toHaveBeenCalled();
});

it('should trigger "exportCsv"', async () => {
it('should trigger "exportToCsv"', async () => {
renderComponent(getPropsWithSortInQuery());
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
expect(exportToCsv).toHaveBeenCalled();
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/routes/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ import {
NoValue,
MCLPagingTypes,
Icon,
exportToCsv,
} from '@folio/stripes/components';
import {
deparseFilters,
makeQueryFunction,
SearchAndSort,
} from '@folio/stripes/smart-components';
import {
exportCsv,
effectiveCallNumber,
getHeaderWithCredentials,
} from '@folio/stripes/util';
Expand Down Expand Up @@ -647,7 +647,7 @@ class RequestsRoute extends React.Component {
this.findResource = this.findResource.bind(this);
this.toggleModal = this.toggleModal.bind(this);
this.buildRecords = this.buildRecords.bind(this);
// Map to pass into exportCsv
// Map to pass into exportToCsv
this.columnHeadersMap = this.getColumnHeaders(reportHeaders);
this.expiredHoldsReportColumnHeaders = this.getColumnHeaders(expiredHoldsReportHeaders);

Expand Down Expand Up @@ -921,7 +921,7 @@ class RequestsRoute extends React.Component {
this.columnHeadersMap :
this.columnHeadersMap.filter(({ value }) => (value !== PROXY_COLUMNS.BARCODE && value !== PROXY_COLUMNS.NAME));

exportCsv(recordsToCSV, {
exportToCsv(recordsToCSV, {
onlyFields: finalColumnHeadersMap,
excludeFields: ['id'],
});
Expand Down Expand Up @@ -1287,7 +1287,7 @@ class RequestsRoute extends React.Component {
}

const recordsToCSV = buildHoldRecords(requests);
exportCsv(recordsToCSV, {
exportToCsv(recordsToCSV, {
onlyFields: this.expiredHoldsReportColumnHeaders,
excludeFields: ['id'],
});
Expand Down
10 changes: 5 additions & 5 deletions src/routes/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
import {
TextLink,
Checkbox,
exportToCsv,
} from '@folio/stripes/components';
import {
exportCsv,
effectiveCallNumber,
getHeaderWithCredentials,
} from '@folio/stripes/util';
Expand Down Expand Up @@ -634,11 +634,11 @@ describe('RequestsRoute', () => {
expect(printContent).toBeInTheDocument();
});

it("should trigger 'exportCsv'", async () => {
it("should trigger 'exportToCsv'", async () => {
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
expect(exportToCsv).toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -974,12 +974,12 @@ describe('RequestsRoute', () => {
expect(defaultProps.mutator.savePrintDetails.POST).not.toHaveBeenCalled();
});

it('should trigger "exportCsv"', async () => {
it('should trigger "exportToCsv"', async () => {
renderComponent(getPropsWithSortInQuery());
await userEvent.click(screen.getByRole('button', { name: 'ui-requests.exportSearchResultsCsv' }));

await waitFor(() => {
expect(exportCsv).toHaveBeenCalled();
expect(exportToCsv).toHaveBeenCalled();
});
});

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 @@ -209,4 +209,5 @@ jest.mock('@folio/stripes/components', () => ({
}),
TextLink: jest.fn(({ to, children }) => <div><a href={to}>{children}</a></div>),
Timepicker: jest.fn(() => <div>Timepicker</div>),
exportToCsv: jest.fn(),
}));
1 change: 0 additions & 1 deletion test/jest/__mock__/stripesUtils.mock.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

jest.mock('@folio/stripes/util', () => ({
exportCsv: jest.fn(),
effectiveCallNumber: jest.fn().mockReturnValue('effectiveCallNumber'),
getHeaderWithCredentials: jest.fn()
}));

0 comments on commit db911ee

Please sign in to comment.