Skip to content

Commit a6e5921

Browse files
committed
test: code coverage
1 parent 03cb7c5 commit a6e5921

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/IdentifierField.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export const collectionNameToAlias = (name: string) => {
1919

2020
// This is only to avoid difference snapshots in Chromatic builds, the real display origin will be the current window location
2121
const locationOrigin =
22-
import.meta.env.STORYBOOK_CHROMATIC_BUILD === 'true' ? 'https://foo.com' : window.location.origin
22+
import.meta.env.STORYBOOK_CHROMATIC_BUILD === 'true'
23+
? /* istanbul ignore next */ 'https://foo.com'
24+
: window.location.origin
2325

24-
const BASENAME_URL = import.meta.env.BASE_URL ?? ''
26+
const BASENAME_URL = import.meta.env.BASE_URL ?? /* istanbul ignore next */ ''
2527

2628
interface IdentifierFieldProps {
2729
rules: UseControllerProps['rules']

tests/component/sections/dataset/dataset-metadata/DatasetMetadata.spec.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,75 @@ describe('DatasetMetadata', () => {
413413
cy.findByRole('button', { name: 'Citation Metadata' }).should('exist')
414414
cy.findByRole('button', { name: 'Geospatial Metadata' }).should('not.exist')
415415
})
416+
417+
it('adds name and description to extra fields of the citation metadata block', () => {
418+
const mockDatasetWithExtraFields = DatasetMother.create({
419+
metadataBlocks: [
420+
{
421+
name: MetadataBlockName.CITATION,
422+
fields: {
423+
title: 'Some Title',
424+
subject: ['subject-one', 'subject-two'],
425+
author: [
426+
{
427+
authorName: 'Foo',
428+
authorAffiliation: 'Bar'
429+
},
430+
{
431+
authorName: 'Another Foo',
432+
authorAffiliation: 'Another Bar'
433+
}
434+
],
435+
datasetContact: [
436+
{
437+
datasetContactName: 'John Doe',
438+
datasetContactEmail: '[email protected]',
439+
datasetContactAffiliation: 'Doe Inc.'
440+
}
441+
],
442+
dsDescription: [
443+
{
444+
dsDescriptionValue: 'Description of the dataset'
445+
}
446+
],
447+
producer: [
448+
{
449+
producerName: 'Foo',
450+
producerAffiliation: 'XYZ',
451+
producerURL: 'http://foo.com',
452+
producerLogoURL:
453+
'https://beta.dataverse.org/resources/images/dataverse_project_logo.svg'
454+
}
455+
],
456+
// Extra fields
457+
publicationDate: '2023-01-01',
458+
alternativePersistentId: 'some-alternative-pid'
459+
}
460+
}
461+
]
462+
})
463+
464+
cy.customMount(
465+
<DatasetMetadata
466+
persistentId={mockDatasetWithExtraFields.persistentId}
467+
metadataBlocks={mockDatasetWithExtraFields.metadataBlocks}
468+
metadataBlockInfoRepository={metadataBlockInfoRepository}
469+
/>
470+
)
471+
472+
cy.get('.accordion > :nth-child(1)').within(() => {
473+
cy.findByText(/Citation Metadata/i).should('exist')
474+
475+
cy.findByText('Persistent Identifier')
476+
.parent()
477+
.siblings('div')
478+
.should('contain', mockDatasetWithExtraFields.persistentId)
479+
480+
cy.findByText('Publication Date').should('exist')
481+
cy.findByText('2023-01-01').should('exist')
482+
483+
cy.findByText('Previous Dataset Persistent ID').should('exist')
484+
cy.findByText('some-alternative-pid').should('exist')
485+
})
486+
})
416487
})

tests/component/sections/file/file-embargo/FileEmbargoDate.spec.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,17 @@ describe('FileEmbargoDate', () => {
6060
cy.findByText(`Embargoed until`).should('exist')
6161
cy.get('time').should('have.text', dateString)
6262
})
63+
64+
it('renders the embargo date in short format', () => {
65+
const embargoDate = new Date('2123-09-18')
66+
const embargo = FileEmbargoMother.create({ dateAvailable: embargoDate })
67+
const status = DatasetPublishingStatus.RELEASED
68+
69+
cy.customMount(
70+
<FileEmbargoDate embargo={embargo} datasetPublishingStatus={status} format="short" />
71+
)
72+
const dateString = DateHelper.toDisplayFormat(embargoDate)
73+
cy.findByText(`Embargoed until`).should('exist')
74+
cy.get('time').should('have.text', dateString)
75+
})
6376
})

0 commit comments

Comments
 (0)