diff --git a/src/sections/shared/form/DatasetMetadataForm/MetadataForm/index.tsx b/src/sections/shared/form/DatasetMetadataForm/MetadataForm/index.tsx
index 049d7a276..68a0bf352 100644
--- a/src/sections/shared/form/DatasetMetadataForm/MetadataForm/index.tsx
+++ b/src/sections/shared/form/DatasetMetadataForm/MetadataForm/index.tsx
@@ -2,16 +2,17 @@ import { MouseEvent, useEffect, useMemo, useRef } from 'react'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { FieldErrors, FormProvider, useForm } from 'react-hook-form'
-import { useSession } from '../../../../session/SessionContext'
+import { useSession } from '@/sections/session/SessionContext'
import { Accordion, Alert, Button } from '@iqss/dataverse-design-system'
-import { type DatasetRepository } from '../../../../../dataset/domain/repositories/DatasetRepository'
-import { type MetadataBlockInfo } from '../../../../../metadata-block-info/domain/models/MetadataBlockInfo'
+import { type DatasetRepository } from '@/dataset/domain/repositories/DatasetRepository'
+import { type MetadataBlockInfo } from '@/metadata-block-info/domain/models/MetadataBlockInfo'
import { type DatasetMetadataFormValues } from '../MetadataFieldsHelper'
import { type DatasetMetadataFormMode } from '..'
import { SubmissionStatus, useSubmitDataset } from '../useSubmitDataset'
import { MetadataBlockFormFields } from './MetadataBlockFormFields'
import { RequiredFieldText } from '../../RequiredFieldText/RequiredFieldText'
-import { SeparationLine } from '../../../layout/SeparationLine/SeparationLine'
+import { SeparationLine } from '@/sections/shared/layout/SeparationLine/SeparationLine'
+import { DateHelper } from '@/shared/helpers/DateHelper'
import styles from './index.module.scss'
interface FormProps {
@@ -64,6 +65,9 @@ export const MetadataForm = ({
setValue('citation.datasetContact.0.datasetContactEmail', user.email, {
shouldValidate: true
})
+ setValue('citation.depositor', displayName)
+ setValue('citation.dateOfDeposit', DateHelper.toISO8601Format(new Date()))
+
if (user.affiliation) {
setValue('citation.datasetContact.0.datasetContactAffiliation', user.affiliation)
setValue('citation.author.0.authorAffiliation', user.affiliation)
diff --git a/src/shared/helpers/DateHelper.ts b/src/shared/helpers/DateHelper.ts
index 44ffacf85..690b83c91 100644
--- a/src/shared/helpers/DateHelper.ts
+++ b/src/shared/helpers/DateHelper.ts
@@ -20,4 +20,8 @@ export class DateHelper {
day: '2-digit'
})
}
+
+ static toISO8601Format(date: Date): string {
+ return date.toISOString().split('T')[0]
+ }
}
diff --git a/tests/component/metadata-block-info/domain/models/MetadataBlockInfoMother.ts b/tests/component/metadata-block-info/domain/models/MetadataBlockInfoMother.ts
index f50fa2570..fed19e33e 100644
--- a/tests/component/metadata-block-info/domain/models/MetadataBlockInfoMother.ts
+++ b/tests/component/metadata-block-info/domain/models/MetadataBlockInfoMother.ts
@@ -513,6 +513,37 @@ export class MetadataBlockInfoMother {
displayOrder: 34,
typeClass: 'primitive',
displayOnCreate: true
+ },
+ depositor: {
+ name: 'depositor',
+ displayName: 'Depositor',
+ displayOnCreate: true,
+ title: 'Depositor',
+ type: 'TEXT',
+ typeClass: 'primitive',
+ watermark: '1) FamilyName, GivenName or 2) Organization',
+ description:
+ 'The entity, such as a person or organization, that deposited the Dataset in the repository',
+ multiple: false,
+ isControlledVocabulary: false,
+ displayFormat: '',
+ displayOrder: 58,
+ isRequired: false
+ },
+ dateOfDeposit: {
+ name: 'dateOfDeposit',
+ displayName: 'Deposit Date',
+ displayOnCreate: true,
+ title: 'Deposit Date',
+ type: 'DATE',
+ typeClass: 'primitive',
+ watermark: 'YYYY-MM-DD',
+ description: 'The date when the Dataset was deposited into the repository',
+ multiple: false,
+ isControlledVocabulary: false,
+ displayFormat: '',
+ displayOrder: 59,
+ isRequired: false
}
}
},
diff --git a/tests/component/sections/collection/Collection.spec.tsx b/tests/component/sections/collection/Collection.spec.tsx
index 15f1e32de..8ce5aedc7 100644
--- a/tests/component/sections/collection/Collection.spec.tsx
+++ b/tests/component/sections/collection/Collection.spec.tsx
@@ -1,15 +1,26 @@
-import { Collection } from '../../../../src/sections/collection/Collection'
-import { CollectionRepository } from '../../../../src/collection/domain/repositories/CollectionRepository'
-import { CollectionMother } from '../../collection/domain/models/CollectionMother'
+import { Collection } from '@/sections/collection/Collection'
+import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository'
+import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother'
+import { CollectionItemsMother } from '@tests/component/collection/domain/models/CollectionItemsMother'
+import { CollectionItemSubset } from '@/collection/domain/models/CollectionItemSubset'
const collectionRepository = {} as CollectionRepository
const collection = CollectionMother.create({ name: 'Collection Name' })
const userPermissionsMock = CollectionMother.createUserPermissions()
+const items = CollectionItemsMother.createItems({
+ numberOfCollections: 4,
+ numberOfDatasets: 3,
+ numberOfFiles: 3
+})
+
+const itemsWithCount: CollectionItemSubset = { items, totalItemCount: 200 }
+
describe('Collection page', () => {
beforeEach(() => {
collectionRepository.getById = cy.stub().resolves(collection)
collectionRepository.getUserPermissions = cy.stub().resolves(userPermissionsMock)
+ collectionRepository.getItems = cy.stub().resolves(itemsWithCount)
})
it('renders skeleton while loading', () => {
@@ -161,4 +172,28 @@ describe('Collection page', () => {
cy.findByRole('button', { name: /Add Data/i }).should('not.exist')
})
+
+ it('opens and close the publish collection modal', () => {
+ cy.viewport(1200, 800)
+ const collection = CollectionMother.createUnpublished()
+
+ collectionRepository.getById = cy.stub().resolves(collection)
+
+ cy.mountAuthenticated(
+
+ )
+ cy.findByRole('button', { name: /Publish/i }).should('exist')
+
+ cy.findByRole('button', { name: /Publish/i }).click()
+ cy.findByText('Publish Collection').should('exist')
+
+ cy.findByRole('button', { name: /Cancel/i }).click()
+ cy.findByText('Publish Collection').should('not.exist')
+ })
})
diff --git a/tests/component/sections/shared/dataset-metadata-form/DatasetMetadataForm.spec.tsx b/tests/component/sections/shared/dataset-metadata-form/DatasetMetadataForm.spec.tsx
index 4a1bac3f6..2ff3752d9 100644
--- a/tests/component/sections/shared/dataset-metadata-form/DatasetMetadataForm.spec.tsx
+++ b/tests/component/sections/shared/dataset-metadata-form/DatasetMetadataForm.spec.tsx
@@ -1,9 +1,10 @@
-import { MetadataBlockName } from '../../../../../src/dataset/domain/models/Dataset'
-import { DatasetRepository } from '../../../../../src/dataset/domain/repositories/DatasetRepository'
-import { TypeMetadataFieldOptions } from '../../../../../src/metadata-block-info/domain/models/MetadataBlockInfo'
-import { MetadataBlockInfoRepository } from '../../../../../src/metadata-block-info/domain/repositories/MetadataBlockInfoRepository'
-import { DatasetMetadataForm } from '../../../../../src/sections/shared/form/DatasetMetadataForm'
-import { UserRepository } from '../../../../../src/users/domain/repositories/UserRepository'
+import { DateHelper } from '@/shared/helpers/DateHelper'
+import { MetadataBlockName } from '@/dataset/domain/models/Dataset'
+import { DatasetRepository } from '@/dataset/domain/repositories/DatasetRepository'
+import { TypeMetadataFieldOptions } from '@/metadata-block-info/domain/models/MetadataBlockInfo'
+import { MetadataBlockInfoRepository } from '@/metadata-block-info/domain/repositories/MetadataBlockInfoRepository'
+import { DatasetMetadataForm } from '@/sections/shared/form/DatasetMetadataForm'
+import { UserRepository } from '@/users/domain/repositories/UserRepository'
import { DatasetMother } from '../../../dataset/domain/models/DatasetMother'
import { MetadataBlockInfoMother } from '../../../metadata-block-info/domain/models/MetadataBlockInfoMother'
import { UserMother } from '../../../users/domain/models/UserMother'
@@ -1446,6 +1447,8 @@ describe('DatasetMetadataForm', () => {
it('pre-fills the form with user data', () => {
const displayName = `${testUser.lastName}, ${testUser.firstName}`
+ const expectedDepositDate = DateHelper.toISO8601Format(new Date())
+
cy.mountAuthenticated(
{
cy.findByLabelText(/^Affiliation/i).should('have.value', testUser.affiliation)
})
cy.findByLabelText(/^E-mail/i).should('have.value', testUser.email)
+ cy.findByLabelText(/^Depositor/i).should('have.value', displayName)
+ cy.findByLabelText(/^Deposit Date/i).should('have.value', expectedDepositDate)
})
it('shows the skeleton while loading', () => {