Skip to content

Commit

Permalink
Merge pull request #247 from IQSS/feature/223-integration-citation-fo…
Browse files Browse the repository at this point in the history
…r-deaccessioned-dataset

Feature/223 integration citation for deaccessioned dataset
  • Loading branch information
GPortas authored Dec 21, 2023
2 parents bab6619 + 4c35f2a commit b7fa0f5
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-pr99.c36f1db",
"@iqss/dataverse-client-javascript": "2.0.0-pr105.302daff",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { DatasetPreview } from '../../domain/models/DatasetPreview'
import { DatasetPreviewMother } from '../../../../tests/component/dataset/domain/models/DatasetPreviewMother'

const includeDeaccessioned = true

export class DatasetJSDataverseRepository implements DatasetRepository {
// eslint-disable-next-line unused-imports/no-unused-vars
getAll(paginationInfo: DatasetPaginationInfo): Promise<DatasetPreview[]> {
Expand Down Expand Up @@ -53,7 +54,11 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
Promise.all([
jsDataset,
getDatasetSummaryFieldNames.execute(),
getDatasetCitation.execute(jsDataset.id, this.versionToVersionId(version)),
getDatasetCitation.execute(
jsDataset.id,
this.versionToVersionId(version),
includeDeaccessioned
),
getDatasetUserPermissions.execute(jsDataset.id),
getDatasetLocks.execute(jsDataset.id),
getDatasetFilesTotalDownloadSize.execute(
Expand Down
5 changes: 5 additions & 0 deletions src/stories/dataset/Dataset.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { WithDatasetNotFound } from './WithDatasetNotFound'
import { WithDatasetLoading } from './WithDatasetLoading'
import { WithLoggedInUser } from '../WithLoggedInUser'
import { WithAlerts } from '../WithAlerts'
import { WithDeaccessionedDataset } from './WithDeaccessionedDataset'
import { WithNotImplementedModal } from '../WithNotImplementedModal'

const meta: Meta<typeof Dataset> = {
Expand Down Expand Up @@ -46,6 +47,10 @@ export const DraftWithAllDatasetPermissions: Story = {
],
render: () => <Dataset fileRepository={new FileMockRepository()} />
}
export const Deaccessioned: Story = {
decorators: [WithLayout, WithDeaccessionedDataset, WithLoggedInUser, WithFilePermissionsGranted],
render: () => <Dataset fileRepository={new FileMockRepository()} />
}
export const LoggedInAsOwner: Story = {
decorators: [
WithDataset,
Expand Down
44 changes: 44 additions & 0 deletions src/stories/dataset/WithDeaccessionedDataset.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { StoryFn } from '@storybook/react'
import { DatasetProvider } from '../../sections/dataset/DatasetProvider'
import { DatasetRepository } from '../../dataset/domain/repositories/DatasetRepository'
import {
Dataset,
DatasetPublishingStatus,
DatasetVersion
} from '../../dataset/domain/models/Dataset'
import { DatasetMother } from '../../../tests/component/dataset/domain/models/DatasetMother'

export const WithDeaccessionedDataset = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
datasetRepository.getByPersistentId = (
// eslint-disable-next-line unused-imports/no-unused-vars
persistentId: string,
// eslint-disable-next-line unused-imports/no-unused-vars
version?: string | undefined
): Promise<Dataset | undefined> => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
DatasetMother.createRealistic({
version: new DatasetVersion(
1,
DatasetPublishingStatus.DEACCESSIONED,
true,
false,
DatasetPublishingStatus.DEACCESSIONED,
1,
0
)
})
)
}, 1000)
})
}
return (
<DatasetProvider
repository={datasetRepository}
searchParams={{ persistentId: 'doi:10.5072/FK2/8YOKQI' }}>
<Story />
</DatasetProvider>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import {
DatasetPermissionsMother,
DatasetVersionMother
} from '../../../../tests/component/dataset/domain/models/DatasetMother'
import { WithLoggedInUser } from '../../WithLoggedInUser'

const meta: Meta<typeof DatasetActionButtons> = {
title: 'Sections/Dataset Page/DatasetActionButtons',
component: DatasetActionButtons,
decorators: [WithI18next, WithSettings],
decorators: [WithI18next, WithSettings, WithLoggedInUser],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
DatasetVersionMother
} from '../../../../../tests/component/dataset/domain/models/DatasetMother'
import { PublishDatasetMenu } from '../../../../sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu'
import { WithLoggedInUser } from '../../../WithLoggedInUser'

const meta: Meta<typeof PublishDatasetMenu> = {
title: 'Sections/Dataset Page/DatasetActionButtons/PublishDatasetMenu',
component: PublishDatasetMenu,
decorators: [WithI18next, WithSettings],
decorators: [WithI18next, WithSettings, WithLoggedInUser],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ describe('Dataset', () => {
})
})

it.skip('successfully loads a dataset deaccessioned', () => {
// TODO - Implement once the getDatasetCitation includes deaccessioned datasets
it('successfully loads a dataset deaccessioned', () => {
cy.wrap(DatasetHelper.create())
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
.then((dataset) => Promise.all([dataset, DatasetHelper.publish(dataset.persistentId)]))
Expand Down

0 comments on commit b7fa0f5

Please sign in to comment.