Skip to content

Commit

Permalink
Merge pull request #833 from digirati-co-uk/feature/2.1.x-bug
Browse files Browse the repository at this point in the history
Feature/2.1.x bug
  • Loading branch information
stephenwf authored May 22, 2024
2 parents 1028db3 + b5d9739 commit 94c5d84
Show file tree
Hide file tree
Showing 13 changed files with 3,452 additions and 41 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
-->

### Fixed
- Project feedback not working for all users
- Fixed model root bug with empty submissions (NS-62)
- Fixing paging issue when hiding completed Manifests (NS-59)

## [v2.2.4](https://github.com/digirati-co-uk/madoc-platform/compare/v2.2.3...v2.2.4) - 14/05/2024

### Fixed
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { filterEmptyFields } from '../../../src/frontend/shared/capture-models/helpers/field-post-filters';
import { filterCaptureModel } from '../../../src/frontend/shared/capture-models/helpers/filter-capture-model';
import { CaptureModel } from '../../../src/frontend/shared/capture-models/types/capture-model';

Expand Down Expand Up @@ -132,4 +133,42 @@ describe('filterCaptureModel', () => {
}
`);
});

test('filter entity model root bug', () => {
const rev = '63642c5e-5e37-4bba-af33-7e4b9dbf653e';
const model = require(`../../../fixtures/97-bugs/06-model-root-filter.json`);
const flatFields = [
['pp2transcription', 'pp2-name'],
['pp2transcription', 'pp2-address'],
['pp2transcription', 'pp2-difficult'],
['pp2transcription', 'pp2-empty'],
];
const allRevisions = ['63642c5e-5e37-4bba-af33-7e4b9dbf653e', '178fca6d-3624-4b8a-9af7-2c50e4034edc'];

const filtered = filterCaptureModel(
rev,
model.document,
flatFields,
(field, parent, key) => {
if (field.revision) {
return allRevisions.indexOf(field.revision) !== -1;
}

// This will show additional fields - but also empty entities.
return true;
},
[
// Filter empty fields.
filterEmptyFields,
]
);

expect(filtered).toEqual(null);

// console.log(JSON.stringify(filtered, null, 2));
//
// expect(filtered?.properties.pp2transcription).not.toHaveLength(0);
// const keys = Object.keys((filtered?.properties.pp2transcription[0] as any).properties);
// expect(keys).toEqual(['pp2-name', 'pp2-address', 'pp2-difficult', 'pp2-empty']);
});
});
Loading

0 comments on commit 94c5d84

Please sign in to comment.