diff --git a/lib/VersionHistory/VersionCard/VersionCard.js b/lib/VersionHistory/VersionCard/VersionCard.js
index e5dd4fb4..c5a07617 100644
--- a/lib/VersionHistory/VersionCard/VersionCard.js
+++ b/lib/VersionHistory/VersionCard/VersionCard.js
@@ -16,11 +16,11 @@ import css from './VersionCard.css';
const itemFormatter = (item, i) => (
{item});
const VersionCard = ({
- changedFields,
+ changedFields = [],
id,
isCurrent,
isLatest,
- isSystemChange,
+ isSystemChange = false,
onSelect,
source,
title,
@@ -79,7 +79,7 @@ const VersionCard = ({
);
}
- if (changedFields) {
+ if (changedFields.length) {
return (
<>
{
it('should display version history card with system update', () => {
renderVersionCard({ isSystemChange: true });
- expect(screen.getByText(/versionChange/)).toBeInTheDocument();
+ expect(screen.getByText(/systemChange/)).toBeInTheDocument();
});
it('should call \'onSelect\' when \'View this version\' icon button was clicked', async () => {
diff --git a/lib/VersionHistory/VersionHistoryPane/VersionHistoryPane.test.js b/lib/VersionHistory/VersionHistoryPane/VersionHistoryPane.test.js
index 20fce70c..5f1fe0d4 100644
--- a/lib/VersionHistory/VersionHistoryPane/VersionHistoryPane.test.js
+++ b/lib/VersionHistory/VersionHistoryPane/VersionHistoryPane.test.js
@@ -110,7 +110,7 @@ describe('VersionHistoryPane', () => {
systemUpdatedFields: ['searchLocationId'],
});
- expect(screen.getByText('stripes-acq-components.versionHistory.card.systemChange')).toBeInTheDocument();
+ expect(screen.getByText(/systemChange/)).toBeInTheDocument();
});
it('should not display version cards without changed fields', () => {
diff --git a/lib/VersionHistory/getFieldLabels.test.js b/lib/VersionHistory/getFieldLabels.test.js
index e221a43f..5295c82e 100644
--- a/lib/VersionHistory/getFieldLabels.test.js
+++ b/lib/VersionHistory/getFieldLabels.test.js
@@ -16,6 +16,10 @@ const paths = [
const intl = { formatMessage: ({ id }) => id };
describe('getFieldLabels', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
it('should use keys of labelsMap as regexp to parse labels of paths', () => {
expect(getFieldLabels(intl, paths, labelsMap).changedFields).toEqual(expect.arrayContaining([
...Object.values(labelsMap),
@@ -38,7 +42,7 @@ describe('getFieldLabels', () => {
it('should isSystemChange equal `true` if there are only systemChanges', () => {
const systemUpdatedFields = ['fundDistribution'];
- const result = getFieldLabels(intl, paths, labelsMap, [], systemUpdatedFields);
+ const result = getFieldLabels(intl, ['fundDistribution'], labelsMap, [], systemUpdatedFields);
expect(result.isSystemChange).toBeTruthy();
});