diff --git a/CHANGELOG.md b/CHANGELOG.md index 31338a493..319971825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## (IN PROGRESS) +## [2.2.3](https://github.com/folio-org/ui-orders/tree/v2.2.3) (2020-11-13) +[Full Changelog](https://github.com/folio-org/ui-orders/compare/v2.2.2...v2.2.3) + +* Unable to view PO Line when accessing via Agreements app. Refs UIOR-627 + ## [2.2.2](https://github.com/folio-org/ui-orders/tree/v2.2.2) (2020-11-12) [Full Changelog](https://github.com/folio-org/ui-orders/compare/v2.2.1...v2.2.2) diff --git a/package.json b/package.json index d5a55f43e..61ead63cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/orders", - "version": "2.2.2", + "version": "2.2.3", "description": "Description for orders", "main": "src/index.js", "repository": "", diff --git a/src/components/POLine/POLineAgreementLines/POLineAgreementLines.js b/src/components/POLine/POLineAgreementLines/POLineAgreementLines.js index 956846158..cae724276 100644 --- a/src/components/POLine/POLineAgreementLines/POLineAgreementLines.js +++ b/src/components/POLine/POLineAgreementLines/POLineAgreementLines.js @@ -8,6 +8,7 @@ import { Badge, Icon, MultiColumnList, + NoValue, } from '@folio/stripes/components'; import { acqRowFormatter, @@ -37,11 +38,15 @@ const resultFormatter = { startDate: ({ startDate }) => startDate || '', endDate: ({ endDate }) => endDate || '', // eslint-disable-next-line react/prop-types - status: ({ owner: { agreementStatus: { label, value } } }) => ( - + status: ({ owner: { agreementStatus } }) => ( + agreementStatus?.value + ? ( + + ) + : agreementStatus?.label || ), arrow: () => , }; diff --git a/src/components/POLine/POLineAgreementLines/POLineAgreementLines.test.js b/src/components/POLine/POLineAgreementLines/POLineAgreementLines.test.js new file mode 100644 index 000000000..4df542d94 --- /dev/null +++ b/src/components/POLine/POLineAgreementLines/POLineAgreementLines.test.js @@ -0,0 +1,60 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import { IntlProvider } from 'react-intl'; +import { MemoryRouter } from 'react-router-dom'; + +import '@folio/stripes-acq-components/test/jest/__mock__'; + +import POLineAgreementLines from './POLineAgreementLines'; + +const agrLines = [ + { + 'id': '44e744b4-a8fe-4311-96ad-5969114bb1ea', + 'type': 'external', + 'description': null, + 'authority': 'EKB-PACKAGE', + 'reference': '57-2755038', + 'explanation': null, + 'startDate': null, + 'endDate': null, + 'activeFrom': null, + 'activeTo': null, + 'contentUpdated': null, + 'haveAccess': true, + 'suppressFromDiscovery': false, + 'note': null, + 'tags': [], + 'owner': { + 'id': '8776871b-3472-426e-80eb-0225617192ed', + 'name': '2021 - 2023 Sage Collection', + }, + 'poLines': [{ 'id': 'cb4d4425-8faa-4f78-a624-076afe941f40', 'poLineId': '004b127b-35fc-476a-b6fd-b67c7d167e4d', 'owner': { 'id': '44e744b4-a8fe-4311-96ad-5969114bb1ea' } }], + 'customCoverage': false, + 'reference_object': { 'label': 'SAGE Communication and Media Studies Subject Collection', 'type': 'Package', 'provider': 'SAGE', 'titleCount': 60, 'selectedCount': 0, 'contentType': 'E-Journal', 'providerName': 'SAGE' }, + }, +]; + +const renderPOLineAgreementLines = ({ agreementLines = [], label = '', onNeedMoreData = () => { }, totalCount = 0 }) => (render( + + + + + , +)); + +describe('POLineAgreementLines', () => { + it('with empty lines it displays empty table', () => { + renderPOLineAgreementLines({}); + expect(screen.getByText('stripes-components.tableEmpty')).toBeDefined(); + }); + + it('with agreement lines provided it displays table with records', () => { + renderPOLineAgreementLines({ agreementLines: agrLines, totalCount: agrLines.length }); + expect(screen.getByText(agrLines[0].owner.name)).toBeInTheDocument(); + }); +});