diff --git a/package-lock.json b/package-lock.json
index 1284be569..8d445f32d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -43627,7 +43627,6 @@
"react-bootstrap": "2.7.2",
"react-bootstrap-icons": "1.10.3",
"sass": "1.58.1",
- "typescript": "4.9.5",
"vite-plugin-istanbul": "4.0.1"
},
"devDependencies": {
@@ -43639,6 +43638,7 @@
"chromatic": "6.17.4",
"cypress": "12.5.1",
"react": "18.2.0",
+ "typescript": "^5.2.2",
"vite": "4.1.5",
"vite-plugin-dts": "2.3.0",
"vite-plugin-libcss": "1.0.6"
@@ -43755,6 +43755,19 @@
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
+ },
+ "packages/design-system/node_modules/typescript": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
+ "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
+ "dev": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
}
}
}
diff --git a/packages/design-system/package.json b/packages/design-system/package.json
index b3502cb41..5ff03ee7b 100644
--- a/packages/design-system/package.json
+++ b/packages/design-system/package.json
@@ -32,25 +32,25 @@
},
"dependencies": {
"@types/react": "18.0.27",
- "typescript": "4.9.5",
- "vite-plugin-istanbul": "4.0.1",
"bootstrap": "5.2.3",
"react-bootstrap": "2.7.2",
"react-bootstrap-icons": "1.10.3",
- "sass": "1.58.1"
+ "sass": "1.58.1",
+ "vite-plugin-istanbul": "4.0.1"
},
"devDependencies": {
- "@vitejs/plugin-react": "3.1.0",
- "@testing-library/cypress": "9.0.0",
"@storybook/react": "7.0.2",
"@storybook/test-runner": "0.10.0",
+ "@testing-library/cypress": "9.0.0",
+ "@vitejs/plugin-react": "3.1.0",
+ "axe-playwright": "1.2.3",
+ "chromatic": "6.17.4",
"cypress": "12.5.1",
+ "react": "18.2.0",
+ "typescript": "^5.2.2",
"vite": "4.1.5",
"vite-plugin-dts": "2.3.0",
- "vite-plugin-libcss": "1.0.6",
- "react": "18.2.0",
- "axe-playwright": "1.2.3",
- "chromatic": "6.17.4"
+ "vite-plugin-libcss": "1.0.6"
},
"files": [
"dist",
diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json
index 88a0983ec..9b970a3c3 100644
--- a/public/locales/en/dataset.json
+++ b/public/locales/en/dataset.json
@@ -56,5 +56,10 @@
"title": "Access Dataset"
},
"uploadFiles": "Upload Files"
+ },
+ "alerts": {
+ "draftVersion": "This draft version needs to be published. When ready for sharing, please publish it so that others can see these changes",
+ "requestedVersionNotFound": "Info – Version {0} was not found. This is version {1}",
+ "unpublishedDataset": "Privately share this dataset before it is published: {0}"
}
}
diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts
index 6819e62b7..ed9a1c84c 100644
--- a/src/dataset/domain/models/Dataset.ts
+++ b/src/dataset/domain/models/Dataset.ts
@@ -1,3 +1,5 @@
+import { AlertVariant } from '@iqss/dataverse-design-system/dist/components/alert/AlertVariant'
+
export enum DatasetLabelSemanticMeaning {
DATASET = 'dataset',
FILE = 'file',
@@ -22,6 +24,21 @@ export class DatasetLabel {
) {}
}
+export enum DatasetAlertMessageKey {
+ DRAFT_VERSION = 'draftVersion',
+ REQUESTED_VERSION_NOT_FOUND = 'requestedVersionNotFound',
+ UNPUBLISHED_DATASET = 'unpublishedDataset'
+}
+
+export class DatasetAlert {
+ constructor(
+ public readonly variant: AlertVariant,
+ public readonly message: DatasetAlertMessageKey,
+ public readonly dynamicFields?: string[],
+ public readonly customHeading?: string
+ ) {}
+}
+
export enum MetadataBlockName {
CITATION = 'citation',
GEOSPATIAL = 'geospatial',
@@ -191,6 +208,7 @@ export interface DatasetLicense {
uri: string
iconUri?: string
}
+
const defaultLicense: DatasetLicense = {
name: 'CC0 1.0',
uri: 'https://creativecommons.org/publicdomain/zero/1.0',
@@ -217,7 +235,9 @@ export class DatasetVersion {
public readonly isInReview: boolean,
public readonly latestVersionStatus: DatasetPublishingStatus,
public readonly majorNumber?: number,
- public readonly minorNumber?: number
+ public readonly minorNumber?: number,
+ // requestedVersion will be set if the user requested a version that did not exist.
+ public readonly requestedVersion?: string
) {}
toString(): string | DatasetNonNumericVersion {
@@ -260,6 +280,7 @@ export class Dataset {
public readonly version: DatasetVersion,
public readonly citation: string,
public readonly labels: DatasetLabel[],
+ public readonly alerts: DatasetAlert[],
public readonly summaryFields: DatasetMetadataBlock[],
public readonly license: DatasetLicense,
public readonly metadataBlocks: DatasetMetadataBlocks,
@@ -298,6 +319,7 @@ export class Dataset {
static Builder = class {
public readonly labels: DatasetLabel[] = []
+ public readonly alerts: DatasetAlert[] = []
constructor(
public readonly persistentId: string,
@@ -310,9 +332,11 @@ export class Dataset {
public readonly locks: DatasetLock[],
public readonly hasValidTermsOfAccess: boolean,
public readonly isValid: boolean,
- public readonly isReleased: boolean
+ public readonly isReleased: boolean,
+ public readonly privateUrl?: string
) {
this.withLabels()
+ this.withAlerts()
}
withLabels() {
@@ -360,12 +384,43 @@ export class Dataset {
}
}
+ private withAlerts(): void {
+ if (this.version.publishingStatus === DatasetPublishingStatus.DRAFT) {
+ this.alerts.push(
+ new DatasetAlert('warning', DatasetAlertMessageKey.DRAFT_VERSION, undefined, 'Info')
+ )
+ }
+ if (this.version.requestedVersion) {
+ const dynamicFields = [this.version.requestedVersion, `${this.version.toString()}`]
+
+ this.alerts.push(
+ new DatasetAlert(
+ 'info',
+ DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND,
+ dynamicFields
+ )
+ )
+ }
+ if (this.privateUrl) {
+ const dynamicFields = [this.privateUrl]
+ this.alerts.push(
+ new DatasetAlert(
+ 'info',
+ DatasetAlertMessageKey.UNPUBLISHED_DATASET,
+ dynamicFields,
+ 'Unpublished Dataset Private URL'
+ )
+ )
+ }
+ }
+
build(): Dataset {
return new Dataset(
this.persistentId,
this.version,
this.citation,
this.labels,
+ this.alerts,
this.summaryFields,
this.license,
this.metadataBlocks,
diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts
index ce3ade4b9..7b7bc47f8 100644
--- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts
+++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts
@@ -16,11 +16,41 @@ import {
MetadataBlockName
} from '../../domain/models/Dataset'
+/*
+
+ static Builder = class {
+ public readonly labels: DatasetLabel[] = []
+ public readonly alerts: DatasetAlert[] = []
+
+ constructor(
+ public readonly persistentId: string,
+ public readonly version: DatasetVersion,
+ public readonly citation: string,
+ public readonly summaryFields: DatasetMetadataBlock[],
+ public readonly license: DatasetLicense = defaultLicense,
+ public readonly metadataBlocks: DatasetMetadataBlocks,
+ public readonly permissions: DatasetPermissions,
+ public readonly locks: DatasetLock[],
+ public readonly hasValidTermsOfAccess: boolean,
+ public readonly isValid: boolean,
+ public readonly isReleased: boolean,
+ public readonly privateUrl?: string
+ ) {
+ this.withLabels()
+ this.withAlerts()
+ }
+ */
export class JSDatasetMapper {
- static toDataset(jsDataset: JSDataset, citation: string, summaryFieldsNames: string[]): Dataset {
+ static toDataset(
+ jsDataset: JSDataset,
+ citation: string,
+ summaryFieldsNames: string[],
+ requestedVersion?: string,
+ privateUrl?: string
+ ): Dataset {
return new Dataset.Builder(
jsDataset.persistentId,
- JSDatasetMapper.toVersion(jsDataset.versionId, jsDataset.versionInfo),
+ JSDatasetMapper.toVersion(jsDataset.versionId, jsDataset.versionInfo, requestedVersion),
citation,
JSDatasetMapper.toSummaryFields(jsDataset.metadataBlocks, summaryFieldsNames),
jsDataset.license,
@@ -41,13 +71,15 @@ export class JSDatasetMapper {
[], // TODO Connect with dataset locks
true, // TODO Connect with dataset hasValidTermsOfAccess
true, // TODO Connect with dataset isValid
- !!jsDataset.versionInfo.releaseTime // TODO Connect with dataset isReleased
+ !!jsDataset.versionInfo.releaseTime, // TODO Connect with dataset isReleased,
+ privateUrl
).build()
}
static toVersion(
jDatasetVersionId: number,
- jsDatasetVersionInfo: JSDatasetVersionInfo
+ jsDatasetVersionInfo: JSDatasetVersionInfo,
+ requestedVersion?: string
): DatasetVersion {
return new DatasetVersion(
jDatasetVersionId,
@@ -56,7 +88,8 @@ export class JSDatasetMapper {
false, // TODO Connect with dataset version isInReview
JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState
jsDatasetVersionInfo.majorNumber,
- jsDatasetVersionInfo.minorNumber
+ jsDatasetVersionInfo.minorNumber,
+ requestedVersion
)
}
diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts
index ea25c0aa2..a1409b317 100644
--- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts
+++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts
@@ -12,7 +12,11 @@ import {
import { JSDatasetMapper } from '../mappers/JSDatasetMapper'
export class DatasetJSDataverseRepository implements DatasetRepository {
- getByPersistentId(persistentId: string, version?: string): Promise {
+ getByPersistentId(
+ persistentId: string,
+ version?: string,
+ requestedVersion?: string
+ ): Promise {
return getDataset
.execute(persistentId, this.versionToVersionId(version))
.then((jsDataset) =>
@@ -23,13 +27,13 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
])
)
.then(([jsDataset, summaryFieldsNames, citation]: [JSDataset, string[], string]) =>
- JSDatasetMapper.toDataset(jsDataset, citation, summaryFieldsNames)
+ JSDatasetMapper.toDataset(jsDataset, citation, summaryFieldsNames, requestedVersion)
)
.catch((error: WriteError) => {
if (!version) {
throw new Error(error.message)
}
- return this.getByPersistentId(persistentId)
+ return this.getByPersistentId(persistentId, undefined, (requestedVersion = version))
})
}
diff --git a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx
index a219b5017..61ddb0c44 100644
--- a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx
+++ b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx
@@ -7,7 +7,7 @@ export function FileDate({ date }: { date: FileDateModel }) {
{t(`table.date.${date.type}`)}{' '}
- {date.date.toLocaleDateString('en-US', {
+ {date.date.toLocaleDateString(Intl.DateTimeFormat().resolvedOptions().locale, {
year: 'numeric',
month: 'short',
day: 'numeric'
diff --git a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileEmbargoDate.tsx b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileEmbargoDate.tsx
index e7e5358ba..4c61171b9 100644
--- a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileEmbargoDate.tsx
+++ b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileEmbargoDate.tsx
@@ -17,7 +17,7 @@ export function FileEmbargoDate({ embargo, publishingStatus }: FileEmbargoDatePr
{t(embargoTypeOfDate(embargo.isActive, publishingStatus))}{' '}
- {embargo.dateAvailable.toLocaleDateString('en-US', {
+ {embargo.dateAvailable.toLocaleDateString(Intl.DateTimeFormat().resolvedOptions().locale, {
year: 'numeric',
month: 'short',
day: 'numeric'
diff --git a/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts b/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts
index 123b2bb29..070205b36 100644
--- a/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts
+++ b/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts
@@ -16,11 +16,11 @@ const jsDataset = {
versionId: 101,
versionInfo: {
state: DatasetVersionState.DRAFT,
+ majorNumber: 0,
+ minorNumber: 0,
createTime: new Date('2023-09-07T13:40:04.000Z'),
lastUpdateTime: new Date('2023-09-07T13:40:04.000Z'),
- releaseTime: undefined,
- majorNumber: 0,
- minorNumber: 0
+ releaseTime: undefined
},
metadataBlocks: [
{
@@ -59,7 +59,8 @@ const expectedDataset = {
isInReview: false,
latestVersionStatus: 'draft',
majorNumber: 0,
- minorNumber: 0
+ minorNumber: 0,
+ requestedVersion: undefined
},
citation:
'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/B4B2MJ, Root, DRAFT VERSION',
@@ -67,6 +68,9 @@ const expectedDataset = {
{ semanticMeaning: 'dataset', value: 'Draft' },
{ semanticMeaning: 'warning', value: 'Unpublished' }
],
+ alerts: [
+ { variant: 'warning', message: 'draftVersion', dynamicFields: undefined, customHeading: 'Info' }
+ ],
summaryFields: [
{
name: 'citation',
@@ -118,12 +122,105 @@ const expectedDataset = {
isValid: true,
isReleased: false
}
-
+const expectedDatasetAlternateVersion = {
+ persistentId: 'doi:10.5072/FK2/B4B2MJ',
+ version: {
+ id: 101,
+ publishingStatus: 'draft',
+ isLatest: true,
+ isInReview: false,
+ latestVersionStatus: 'draft',
+ minorNumber: 0,
+ majorNumber: 0,
+ requestedVersion: '4.0'
+ },
+ citation:
+ 'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/B4B2MJ, Root, DRAFT VERSION',
+ hasValidTermsOfAccess: true,
+ isReleased: false,
+ isValid: true,
+ labels: [
+ { semanticMeaning: 'dataset', value: 'Draft' },
+ { semanticMeaning: 'warning', value: 'Unpublished' }
+ ],
+ alerts: [
+ {
+ variant: 'warning',
+ message: 'draftVersion',
+ dynamicFields: undefined,
+ customHeading: 'Info'
+ },
+ {
+ message: 'requestedVersionNotFound',
+ variant: 'info',
+ dynamicFields: ['4.0', '0.0'],
+ customHeading: undefined
+ }
+ ],
+ summaryFields: [
+ {
+ name: 'citation',
+ fields: {
+ dsDescription: [
+ {
+ dsDescriptionValue:
+ "Darwin's finches (also known as the Galápagos finches) are a group of about fifteen species of passerine birds."
+ }
+ ],
+ subject: ['Medicine, Health and Life Sciences']
+ }
+ }
+ ],
+ license: {
+ name: 'CC0 1.0',
+ uri: 'http://creativecommons.org/publicdomain/zero/1.0',
+ iconUri: 'https://licensebuttons.net/p/zero/1.0/88x31.png'
+ },
+ locks: [],
+ metadataBlocks: [
+ {
+ name: 'citation',
+ fields: {
+ title: "Darwin's Finches",
+ author: [{ authorName: 'Finch, Fiona', authorAffiliation: 'Birds Inc.' }],
+ datasetContact: [
+ { datasetContactName: 'Finch, Fiona', datasetContactEmail: 'finch@mailinator.com' }
+ ],
+ dsDescription: [
+ {
+ dsDescriptionValue:
+ "Darwin's finches (also known as the Galápagos finches) are a group of about fifteen species of passerine birds."
+ }
+ ],
+ subject: ['Medicine, Health and Life Sciences']
+ }
+ }
+ ],
+ permissions: {
+ canDeleteDataset: true,
+ canDownloadFiles: true,
+ canManageDatasetPermissions: true,
+ canManageFilesPermissions: true,
+ canPublishDataset: true,
+ canUpdateDataset: true
+ }
+}
describe('JS Dataset Mapper', () => {
it('maps jsDataset model to the domain Dataset model', () => {
- expect(expectedDataset).to.deep.equal(
- JSDatasetMapper.toDataset(jsDataset, citation, datasetSummaryFields)
+ const mapped = JSDatasetMapper.toDataset(jsDataset, citation, datasetSummaryFields)
+ expect(expectedDataset).to.deep.equal(mapped)
+ })
+ it('maps jsDataset model to the domain Dataset model for alternate version', () => {
+ const mappedWithAlternate = JSDatasetMapper.toDataset(
+ jsDataset,
+ citation,
+ datasetSummaryFields,
+ '4.0'
)
+ console.log('mapped: ' + JSON.stringify(mappedWithAlternate))
+ console.log('expected: ' + JSON.stringify(expectedDatasetAlternateVersion))
+
+ expect(expectedDatasetAlternateVersion).to.deep.equal(mappedWithAlternate)
})
it('maps jsDataset model to the domain Dataset model when alternativePersistentId is provided', () => {
diff --git a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileDate.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileDate.spec.tsx
index 040a5758c..851029fa5 100644
--- a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileDate.spec.tsx
+++ b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileDate.spec.tsx
@@ -1,10 +1,16 @@
import { FileDate } from '../../../../../../../../../src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate'
import { FileDateType } from '../../../../../../../../../src/files/domain/models/File'
+
describe('FileDate', () => {
it('renders the date', () => {
- const date = { type: FileDateType.PUBLISHED, date: new Date('2023-09-18') }
+ const fileDate = new Date('2023-09-18')
+ const date = { type: FileDateType.PUBLISHED, date: fileDate }
cy.customMount()
-
- cy.findByText(`Published Sep 18, 2023`).should('exist')
+ const dateString = fileDate.toLocaleDateString(Intl.DateTimeFormat().resolvedOptions().locale, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric'
+ })
+ cy.findByText(`Published ` + dateString).should('exist')
})
})
diff --git a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileEmbargoDate.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileEmbargoDate.spec.tsx
index 4ef4fe87b..0e72039f8 100644
--- a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileEmbargoDate.spec.tsx
+++ b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/FileEmbargoDate.spec.tsx
@@ -4,29 +4,53 @@ import { FileEmbargoMother } from '../../../../../../../files/domain/models/File
describe('FileEmbargoDate', () => {
it('renders the embargo date when embargo exists', () => {
- const embargo = FileEmbargoMother.create(new Date('2123-09-18'))
+ const embargoDate = new Date('2123-09-18')
+ const embargo = FileEmbargoMother.create(embargoDate)
const status = FilePublishingStatus.RELEASED
cy.customMount()
-
- cy.findByText(`Embargoed until Sep 18, 2123`).should('exist')
+ const dateString = embargoDate.toLocaleDateString(
+ Intl.DateTimeFormat().resolvedOptions().locale,
+ {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric'
+ }
+ )
+ cy.findByText(`Embargoed until ` + dateString).should('exist')
})
it('renders the until embargo date when embargo is not active and the file is not released', () => {
- const embargo = FileEmbargoMother.create(new Date('2023-09-15'))
+ const embargoDate = new Date('2023-09-15')
+ const embargo = FileEmbargoMother.create(embargoDate)
const status = FilePublishingStatus.RELEASED
cy.customMount()
-
- cy.findByText(`Was embargoed until Sep 15, 2023`).should('exist')
+ const dateString = embargoDate.toLocaleDateString(
+ Intl.DateTimeFormat().resolvedOptions().locale,
+ {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric'
+ }
+ )
+ cy.findByText(`Was embargoed until ` + dateString).should('exist')
})
it('renders the draft until embargo date when embargo is active and the file is not released', () => {
- const embargo = FileEmbargoMother.create(new Date('2123-09-18'))
+ const embargoDate = new Date('2123-09-18')
+ const embargo = FileEmbargoMother.create(embargoDate)
const status = FilePublishingStatus.DRAFT
cy.customMount()
-
- cy.findByText(`Draft: will be embargoed until Sep 18, 2123`).should('exist')
+ const dateString = embargoDate.toLocaleDateString(
+ Intl.DateTimeFormat().resolvedOptions().locale,
+ {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric'
+ }
+ )
+ cy.findByText(`Draft: will be embargoed until ` + dateString).should('exist')
})
it('renders an empty fragment when embargo is undefined', () => {
diff --git a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts
index 480456aeb..65f01dbfc 100644
--- a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts
+++ b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts
@@ -76,6 +76,7 @@ const datasetData = (persistentId: string, versionId: number) => {
majorNumber: undefined,
minorNumber: undefined,
publishingStatus: 'draft',
+ requestedVersion: undefined,
latestVersionStatus: 'draft',
isLatest: true,
isInReview: false
diff --git a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts
index 18f6c842f..1dd07b335 100644
--- a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts
+++ b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts
@@ -91,7 +91,7 @@ describe('File JSDataverse Repository', () => {
expect(file.version).to.deep.equal(expectedFile.version)
expect(file.access).to.deep.equal(expectedFile.access)
expect(file.type).to.deep.equal(expectedFile.type)
- expect(file.date).to.deep.equal(expectedFile.date)
+ cy.compareDate(file.date.date, expectedFile.date.date)
expect(file.downloadCount).to.deep.equal(expectedFile.downloadCount)
expect(file.labels).to.deep.equal(expectedFile.labels)
expect(file.checksum?.algorithm).to.deep.equal(expectedFile.checksum?.algorithm)
@@ -151,7 +151,7 @@ describe('File JSDataverse Repository', () => {
files.forEach((file) => {
expect(file.version).to.deep.equal(expectedPublishedFile.version)
- expect(file.date).to.deep.equal(expectedFile.date)
+ cy.compareDate(file.date.date, expectedFile.date.date)
})
})
})
diff --git a/tests/support/commands.tsx b/tests/support/commands.tsx
index 7ea7bcc74..92229d209 100644
--- a/tests/support/commands.tsx
+++ b/tests/support/commands.tsx
@@ -85,3 +85,9 @@ Cypress.Commands.add('getApiToken', () => {
cy.loginAsAdmin('/dataverseuser.xhtml?selectTab=dataRelatedToMe')
return cy.findByRole('link', { name: 'API Token' }).click().get('#apiToken code').invoke('text')
})
+
+Cypress.Commands.add('compareDate', (date, expectedDate) => {
+ expect(date.getUTCDate()).to.deep.equal(expectedDate.getUTCDate())
+ expect(date.getUTCMonth()).to.deep.equal(expectedDate.getUTCMonth())
+ expect(date.getUTCFullYear()).to.deep.equal(expectedDate.getUTCFullYear())
+})
diff --git a/tests/support/component.ts b/tests/support/component.ts
index e366de486..12c3ff981 100644
--- a/tests/support/component.ts
+++ b/tests/support/component.ts
@@ -36,6 +36,7 @@ declare global {
mountAuthenticated: typeof mount
loginAsAdmin(go?: string): Chainable>
getApiToken(): Chainable
+ compareDate(date: Date, expectedDate: Date): Chainable
}
}
}