Skip to content

Commit

Permalink
fix: display all collectors' names and add a test for this (#472)
Browse files Browse the repository at this point in the history
* chore: change the ahiqar arabic local karshuni file

* fix: display all collectors'names in metadata

* test: add a test for showing all collectors names

* chore: restore the file as it was before this PR

* refactor: write in a more compact way the function getCollectorName()

---------

Co-authored-by: malkja <[email protected]>
  • Loading branch information
orlinmalkja and malkja authored Sep 18, 2024
1 parent 9370d39 commit c6b1ebe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/metadata/CollectionMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import MetadataItem from '@/components/metadata/MetadataItem.vue';
const contentStore = useContentsStore();
function getCollectorName(collection: Collection) : string | null {
function getCollectorsName(collection: Collection) : string | null {
if (!collection) return null;
if (collection.collector.length === 0) return null;
return collection.collector[0].name;
if (collection.collector.length === 1) return collection.collector[0].name;
return collection.collector.map((collector) => collector.name).join(', ')
}
const collection = computed<Collection>(() => contentStore.collection);
Expand All @@ -40,7 +42,7 @@ const metadata = computed(() => {
sub: 'subtitle',
};
const collectorName: string | null = getCollectorName(collection.value);
const collectorsName: string | null = getCollectorsName(collection.value);
const { description } = collection.value;
const collectionTitle: Title[] = collection.value.title;
Expand All @@ -51,7 +53,7 @@ const metadata = computed(() => {
key: mappings[title.type] || 'title',
value: title.title,
})),
...(collectorName ? [{ key: 'collector', value: collectorName }] : []),
...(collectorsName ? [{ key: 'collector', value: collectorsName }] : []),
...(description ? [{ key: 'description', value: description }] : []),
];
});
Expand Down
9 changes: 9 additions & 0 deletions tests/cypress/e2e/metadata.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ describe('Metadata', () => {
.next()
.should('contain', 'Textual witnesses in Arabic and Karshuni');

cy
.get(selectors.metadataView)
.find(selectors.collection)
.children()
.eq(2)
.find('h4', 'Collector')
.next()
.should('contain', 'Prof. Dr. theol. Kratz, Reinhard Gregor, Dr. Elrefai, Aly')

cy
.get(selectors.metadataView)
.find(selectors.collection)
Expand Down

0 comments on commit c6b1ebe

Please sign in to comment.