Skip to content

Commit

Permalink
UIOR-627 fix dsiplaying of agr lines (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaksei-chumakou authored Nov 13, 2020
1 parent 723ee35 commit 034cbb6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/orders",
"version": "2.2.2",
"version": "2.2.3",
"description": "Description for orders",
"main": "src/index.js",
"repository": "",
Expand Down
15 changes: 10 additions & 5 deletions src/components/POLine/POLineAgreementLines/POLineAgreementLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Badge,
Icon,
MultiColumnList,
NoValue,
} from '@folio/stripes/components';
import {
acqRowFormatter,
Expand Down Expand Up @@ -37,11 +38,15 @@ const resultFormatter = {
startDate: ({ startDate }) => startDate || '',
endDate: ({ endDate }) => endDate || '',
// eslint-disable-next-line react/prop-types
status: ({ owner: { agreementStatus: { label, value } } }) => (
<FormattedMessage
id={`ui-orders.relatedAgreementLines.status.${value}`}
defaultMessage={label}
/>
status: ({ owner: { agreementStatus } }) => (
agreementStatus?.value
? (
<FormattedMessage
id={`ui-orders.relatedAgreementLines.status.${agreementStatus?.value}`}
defaultMessage={agreementStatus?.label}
/>
)
: agreementStatus?.label || <NoValue />
),
arrow: () => <Icon icon="caret-right" />,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
<IntlProvider locale="en">
<MemoryRouter>
<POLineAgreementLines
agreementLines={agreementLines}
label={label}
onNeedMoreData={onNeedMoreData}
totalCount={totalCount}
/>
</MemoryRouter>
</IntlProvider>,
));

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();
});
});

0 comments on commit 034cbb6

Please sign in to comment.