Skip to content

Commit

Permalink
fix: Dataset object in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Oct 19, 2023
1 parent 8a73214 commit 8033dcc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
10 changes: 2 additions & 8 deletions src/stories/dataset/Dataset.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { WithDataset } from './WithDataset'
import { WithDatasetDraftAsOwner } from './WithDatasetDraftAsOwner'
import { WithDatasetNotFound } from './WithDatasetNotFound'
import { WithDatasetLoading } from './WithDatasetLoading'
import { DatasetMockDraftVersionRepository } from './DatasetMockDraftVersionRepository'
import { WithLoggedInUser } from '../WithLoggedInUser'

const meta: Meta<typeof Dataset> = {
Expand All @@ -36,16 +35,11 @@ export const Default: Story = {

export const DraftWithAllDatasetPermissions: Story = {
decorators: [WithLayout, WithDatasetDraftAsOwner, WithLoggedInUser, WithFilePermissionsGranted],
render: () => <Dataset fileRepository={new FileMockRepository()}/>
render: () => <Dataset fileRepository={new FileMockRepository()} />
}
export const LoggedInAsOwner: Story = {
decorators: [WithDataset, WithLayout, WithLoggedInUser, WithFilePermissionsGranted],
render: () => (
<Dataset
fileRepository={new FileMockRepository()}
searchParams={{ persistentId: 'doi:10.5082/FK2/ABC123' }}
/>
)
render: () => <Dataset fileRepository={new FileMockRepository()} />
}

export const Loading: Story = {
Expand Down
32 changes: 27 additions & 5 deletions src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { DatasetMockData } from '../DatasetMockData'

import {
DatasetAlert,
DatasetAlertMessageKey,
Expand All @@ -9,6 +9,10 @@ import {
import { DatasetAlerts } from '../../../sections/dataset/dataset-alerts/DatasetAlerts'
import { WithI18next } from '../../WithI18next'

import { WithDatasetDraftAsOwner } from '../WithDatasetDraftAsOwner'
import { useDataset } from '../../../sections/dataset/DatasetContext'

Check failure on line 13 in src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

'useDataset' is defined but never used
import { DatasetMother } from '../../../../tests/component/dataset/domain/models/DatasetMother'

const meta: Meta<typeof DatasetAlerts> = {
title: 'Sections/Dataset Page/DatasetAlerts',
component: DatasetAlerts,
Expand All @@ -19,9 +23,16 @@ export default meta
type Story = StoryObj<typeof DatasetAlerts>

export const DraftVersion: Story = {
decorators: [WithDatasetDraftAsOwner],
render: () => {
const dataset = DatasetMockData({
version: new DatasetVersion(1, DatasetPublishingStatus.DRAFT, 1, 0)
const dataset = DatasetMother.createRealistic({
version: new DatasetVersion(
1,
DatasetPublishingStatus.DRAFT,
true,
false,
DatasetPublishingStatus.DRAFT
)
})
return (
<div>
Expand All @@ -30,11 +41,22 @@ export const DraftVersion: Story = {
)
}
}

export const VersionNotFound: Story = {
render: () => {
const dataset = DatasetMockData({
version: new DatasetVersion(1, DatasetPublishingStatus.RELEASED, 1, 0, '3.0')
const dataset = DatasetMother.createRealistic({
version: new DatasetVersion(
1,
DatasetPublishingStatus.RELEASED,
true,
false,
DatasetPublishingStatus.RELEASED,
1,
0,
'3.0'
)
})

return (
<div>
<DatasetAlerts alerts={dataset.alerts} />
Expand Down

0 comments on commit 8033dcc

Please sign in to comment.