Skip to content

Commit 5a2e625

Browse files
authored
Merge pull request #608 from IQSS/feat/599-get-collection-description-html
Collection Page: convert html to markdown in description field
2 parents 64ab9a7 + 34a5d3b commit 5a2e625

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@dnd-kit/sortable": "8.0.0",
1818
"@dnd-kit/utilities": "3.2.2",
1919
"@faker-js/faker": "7.6.0",
20-
"@iqss/dataverse-client-javascript": "2.0.0-alpha.20",
20+
"@iqss/dataverse-client-javascript": "2.0.0-alpha.24",
2121
"@iqss/dataverse-design-system": "*",
2222
"@istanbuljs/nyc-config-typescript": "1.0.2",
2323
"@tanstack/react-table": "8.9.2",

src/sections/collection/CollectionInfo.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Collection } from '../../collection/domain/models/Collection'
2+
import TurndownService from 'turndown'
23
import styles from './Collection.module.scss'
34
import { MarkdownComponent } from '../dataset/markdown/MarkdownComponent'
45
import { Badge } from '@iqss/dataverse-design-system'
@@ -7,6 +8,7 @@ import { DatasetLabelSemanticMeaning } from '../../dataset/domain/models/Dataset
78
interface CollectionInfoProps {
89
collection: Collection
910
}
11+
const turndownService = new TurndownService()
1012

1113
export function CollectionInfo({ collection }: CollectionInfoProps) {
1214
return (
@@ -26,7 +28,7 @@ export function CollectionInfo({ collection }: CollectionInfoProps) {
2628
</header>
2729
{collection.description && (
2830
<div>
29-
<MarkdownComponent markdown={collection.description} />
31+
<MarkdownComponent markdown={turndownService.turndown(collection.description)} />
3032
</div>
3133
)}
3234
</>

tests/component/sections/collection/CollectionInfo.spec.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ describe('CollectionInfo', () => {
77
name: 'Collection Name',
88
affiliation: 'Affiliation',
99
isReleased: true,
10-
description: 'Here is a description with [a link](https://dataverse.org)'
10+
description: 'Here is a <b>description</b> with <a href="https://dataverse.org">a link</a>'
1111
})
1212
cy.customMount(<CollectionInfo collection={collection} />)
1313

1414
cy.findByRole('heading', { name: 'Collection Name' }).should('exist')
1515
cy.findByText('(Affiliation)').should('exist')
16-
cy.findByText(/Here is a description with/).should('exist')
16+
cy.findByText(/Here is a/).should('exist')
1717
cy.findByRole('link', { name: 'a link' }).should('exist')
18+
cy.get('strong').contains('description').should('exist')
1819
cy.findByText('Unpublished').should('not.exist')
1920
})
2021

tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ describe('File JSDataverse Repository', () => {
481481
dataset.persistentId,
482482
dataset.version,
483483
new FilePaginationInfo(),
484-
new FileCriteria().withFilterByType('text/tab-separated-values')
484+
new FileCriteria().withFilterByType('text/plain')
485485
)
486486
.then((files) => {
487-
expect(files.length).to.equal(1)
487+
expect(files.length).to.equal(2)
488488
})
489489
})
490490

0 commit comments

Comments
 (0)