Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

305 update chromatic configurations #325

Merged
merged 32 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4fe24dc
use faker seed in chromatic run
ekraffmiller Feb 23, 2024
bd04d1d
set snapshot delay for Home and File pages
ekraffmiller Feb 23, 2024
a6cb61a
add helper method for static images
ekraffmiller Feb 24, 2024
fdc4eb5
add delay to DatasetsList.stories.tsx, fix preview.tsx env variable
ekraffmiller Feb 24, 2024
a78a714
use getImageUrl(), add chromatic delay
ekraffmiller Feb 24, 2024
578522a
fix: use picsum image, which is static
ekraffmiller Feb 24, 2024
b4b4600
refactoring, adding FakerHelper.fileSize()
ekraffmiller Feb 24, 2024
a96a192
add comment
ekraffmiller Feb 24, 2024
76d4211
add FakerHelper.fileLabel()
ekraffmiller Feb 24, 2024
ccbad1e
trigger a build
ekraffmiller Feb 24, 2024
30907af
set Faker seed in FakerHelper.ts
ekraffmiller Feb 25, 2024
6ea19d5
add FakerHelper.futureDate()
ekraffmiller Feb 25, 2024
a7c8aa7
fix: lint errors
ekraffmiller Feb 25, 2024
b7bd8b0
fix: remove decorator
ekraffmiller Feb 25, 2024
4549e05
add FakerHelper.fileDateType()
ekraffmiller Feb 25, 2024
d8b48a8
add FakerHelper.fileDateType()
ekraffmiller Feb 25, 2024
8976e6f
trigger build
ekraffmiller Feb 25, 2024
2e173a0
use hard-coded date for future in Chromatic
ekraffmiller Feb 25, 2024
76babfb
trigger build
ekraffmiller Feb 25, 2024
907f222
use hard-coded past dates in Chromatic
ekraffmiller Feb 25, 2024
0470b91
trigger build
ekraffmiller Feb 25, 2024
f6d8fd3
trigger build
ekraffmiller Feb 25, 2024
a6ef52c
fix lint error
ekraffmiller Feb 25, 2024
e9ec097
Update README.md
ekraffmiller Feb 25, 2024
bd1173a
Merge pull request #324 from ekraffmiller/fix-chromatic
ekraffmiller Feb 25, 2024
e576809
fix lint error
ekraffmiller Feb 26, 2024
d413274
trigger test for review completion and storybook state verification
Feb 29, 2024
e314c48
Resolve merge conflicts
ekraffmiller Feb 29, 2024
035930a
remove loading delay for Chromatic runs
ekraffmiller Mar 11, 2024
31adf9c
Merge branch 'develop' into 305-update-chromatic-configurations
ekraffmiller Mar 12, 2024
03abc56
use hard-coded description and directory path in FileMetadataMother.t…
ekraffmiller Mar 12, 2024
a9f9fda
test to trigger a build
ekraffmiller Mar 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
run: npm run build
- name: Publish to Chromatic
uses: chromaui/action@v1
env:
STORYBOOK_CHROMATIC_BUILD: 'true'

# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
Expand Down
18 changes: 11 additions & 7 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Preview } from '@storybook/react'
import { ThemeProvider } from '@iqss/dataverse-design-system'
import { MemoryRouter } from 'react-router-dom'
import { FakerHelper } from '../tests/component/shared/FakerHelper'

const preview: Preview = {
parameters: {
Expand All @@ -13,13 +14,16 @@ const preview: Preview = {
}
},
decorators: [
(Story) => (
<ThemeProvider>
<MemoryRouter>
<Story />
</MemoryRouter>
</ThemeProvider>
)
(Story) => {
FakerHelper.setFakerSeed()
return (
<ThemeProvider>
<MemoryRouter>
<Story />
</MemoryRouter>
</ThemeProvider>
)
}
]
}

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ There are 2 Storybook instances, one for the Design System and one for the Datav
Open [http://localhost:6006](http://localhost:6006) to view the Dataverse Frontend Storybook in your browser.
Open [http://localhost:6007](http://localhost:6007) to view the Design System Storybook in your browser.

Note that both Storybook instances are also published to Chromatic:
Note that both Storybook instances are also published to Chromatic (the Chromatic build contains
less dynamic content than the local Storybook):

- [Dataverse Frontend](https://www.chromatic.com/builds?appId=646f68aa9beb01b35c599acd)
- [Dataverse Design System](https://www.chromatic.com/builds?appId=646fbe232a8d3b501a1943f3)
Expand Down
6 changes: 5 additions & 1 deletion src/stories/collection/Collection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { WithLoggedInUser } from '../WithLoggedInUser'
const meta: Meta<typeof Collection> = {
title: 'Pages/Collection',
component: Collection,
decorators: [WithI18next, WithLayout]
decorators: [WithI18next, WithLayout],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}

export default meta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { NoDatasetsMockRepository } from '../../dataset/NoDatasetsMockRepository
const meta: Meta<typeof DatasetsList> = {
title: 'Sections/Collection/DatasetsList',
component: DatasetsList,
decorators: [WithI18next]
decorators: [WithI18next],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}

export default meta
Expand Down
11 changes: 6 additions & 5 deletions src/stories/dataset/DatasetMockRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ import { DatasetPaginationInfo } from '../../dataset/domain/models/DatasetPagina
import { DatasetPreview } from '../../dataset/domain/models/DatasetPreview'
import { DatasetPreviewMother } from '../../../tests/component/dataset/domain/models/DatasetPreviewMother'
import { DatasetFormFields } from '../../dataset/domain/models/DatasetFormFields'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'
export class DatasetMockRepository implements DatasetRepository {
// eslint-disable-next-line unused-imports/no-unused-vars
getAll(collectionId: string, paginationInfo: DatasetPaginationInfo): Promise<DatasetPreview[]> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(DatasetPreviewMother.createManyRealistic(paginationInfo.pageSize))
}, 1000)
}, FakerHelper.loadingTimout())
})
}
// eslint-disable-next-line unused-imports/no-unused-vars
getTotalDatasetsCount(collectionId: string): Promise<TotalDatasetsCount> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(200)
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -33,7 +34,7 @@ export class DatasetMockRepository implements DatasetRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(DatasetMother.createRealistic())
}, 1000)
}, FakerHelper.loadingTimout())
})
}
getByPrivateUrlToken(
Expand All @@ -43,7 +44,7 @@ export class DatasetMockRepository implements DatasetRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(DatasetMother.createRealistic())
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -52,7 +53,7 @@ export class DatasetMockRepository implements DatasetRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(returnMsg)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
}
3 changes: 2 additions & 1 deletion src/stories/dataset/WithDatasetAllPermissionsGranted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DatasetMother,
DatasetPermissionsMother
} from '../../../tests/component/dataset/domain/models/DatasetMother'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export const WithDatasetAllPermissionsGranted = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
Expand All @@ -23,7 +24,7 @@ export const WithDatasetAllPermissionsGranted = (Story: StoryFn) => {
hasValidTermsOfAccess: true
})
)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
return (
Expand Down
3 changes: 2 additions & 1 deletion src/stories/dataset/WithDatasetDraftAsOwner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { DatasetRepository } from '../../dataset/domain/repositories/DatasetRepository'
import { Dataset } from '../../dataset/domain/models/Dataset'
import { DatasetProvider } from '../../sections/dataset/DatasetProvider'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export const WithDatasetDraftAsOwner = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
Expand All @@ -24,7 +25,7 @@ export const WithDatasetDraftAsOwner = (Story: StoryFn) => {
version: DatasetVersionMother.createDraftAsLatestVersion()
})
)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
return (
Expand Down
3 changes: 2 additions & 1 deletion src/stories/dataset/WithDatasetLockedFromEdits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DatasetPermissionsMother
} from '../../../tests/component/dataset/domain/models/DatasetMother'
import { DatasetProvider } from '../../sections/dataset/DatasetProvider'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export const WithDatasetLockedFromEdits = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
Expand All @@ -24,7 +25,7 @@ export const WithDatasetLockedFromEdits = (Story: StoryFn) => {
locks: [DatasetLockMother.createLockedInEditInProgress()]
})
)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
return (
Expand Down
3 changes: 2 additions & 1 deletion src/stories/dataset/WithDatasetPrivateUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DatasetProvider } from '../../sections/dataset/DatasetProvider'
import { DatasetRepository } from '../../dataset/domain/repositories/DatasetRepository'
import { Dataset } from '../../dataset/domain/models/Dataset'
import { DatasetMother } from '../../../tests/component/dataset/domain/models/DatasetMother'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export const WithDatasetPrivateUrl = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
Expand All @@ -20,7 +21,7 @@ export const WithDatasetPrivateUrl = (Story: StoryFn) => {
}
})
)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
return (
Expand Down
3 changes: 2 additions & 1 deletion src/stories/dataset/WithDeaccessionedDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DatasetMother,
DatasetVersionMother
} from '../../../tests/component/dataset/domain/models/DatasetMother'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export const WithDeaccessionedDataset = (Story: StoryFn) => {
const datasetRepository = {} as DatasetRepository
Expand All @@ -22,7 +23,7 @@ export const WithDeaccessionedDataset = (Story: StoryFn) => {
version: DatasetVersionMother.createDeaccessioned()
})
)
}, 1000)
}, FakerHelper.loadingTimout())
})
}
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Meta, StoryObj } from '@storybook/react'
import { WithI18next } from '../../WithI18next'
import { DatasetCitation } from '../../../sections/dataset/dataset-citation/DatasetCitation'
import { faker } from '@faker-js/faker'
import {
DatasetMother,
DatasetVersionMother
} from '../../../../tests/component/dataset/domain/models/DatasetMother'
import { FakerHelper } from '../../../../tests/component/shared/FakerHelper'

const meta: Meta<typeof DatasetCitation> = {
title: 'Sections/Dataset Page/DatasetCitation',
Expand All @@ -31,7 +31,7 @@ export const Default: Story = {

export const WithThumbnailImage: Story = {
render: () => {
const dataset = DatasetMother.createRealistic({ thumbnail: faker.image.imageUrl() })
const dataset = DatasetMother.createRealistic({ thumbnail: FakerHelper.getImageUrl() })
return (
<div>
<br></br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const meta: Meta<typeof FileInfoMessages> = {
title:
'Sections/Dataset Page/DatasetFiles/FilesTable/FileActionsCell/FileInfoMessages/FileInfoMessages',
component: FileInfoMessages,
decorators: [WithI18next, WithSettings, WithDatasetAllPermissionsGranted]
decorators: [WithI18next, WithSettings, WithDatasetAllPermissionsGranted],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}

export default meta
Expand Down
6 changes: 5 additions & 1 deletion src/stories/file/File.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { FileMother } from '../../../tests/component/files/domain/models/FileMot
const meta: Meta<typeof File> = {
title: 'Pages/File',
component: File,
decorators: [WithI18next, WithLayout]
decorators: [WithI18next, WithLayout],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}

export default meta
Expand Down
5 changes: 3 additions & 2 deletions src/stories/file/FileMockLoadingRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DatasetVersion, DatasetVersionNumber } from '../../dataset/domain/model
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMockRepository } from './FileMockRepository'
import { File } from '../../files/domain/models/File'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export class FileMockLoadingRepository extends FileMockRepository implements FileRepository {
getAllByDatasetPersistentId(
Expand All @@ -31,7 +32,7 @@ export class FileMockLoadingRepository extends FileMockRepository implements Fil
return new Promise(() => {
setTimeout(() => {
// Do nothing
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -40,7 +41,7 @@ export class FileMockLoadingRepository extends FileMockRepository implements Fil
return new Promise(() => {
setTimeout(() => {
// Do nothing
}, 1000)
}, FakerHelper.loadingTimout())
})
}
}
5 changes: 3 additions & 2 deletions src/stories/file/FileMockNoFiltersRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FilesMockData } from './FileMockData'
import { DatasetVersion, DatasetVersionNumber } from '../../dataset/domain/models/Dataset'
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMockRepository } from './FileMockRepository'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export class FileMockNoFiltersRepository extends FileMockRepository implements FileRepository {
getAllByDatasetPersistentId(
Expand All @@ -17,7 +18,7 @@ export class FileMockNoFiltersRepository extends FileMockRepository implements F
return new Promise((resolve) => {
setTimeout(() => {
resolve(FilesMockData())
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -32,7 +33,7 @@ export class FileMockNoFiltersRepository extends FileMockRepository implements F
return new Promise((resolve) => {
setTimeout(() => {
resolve(FilesCountInfoMother.createOnlyTotal())
}, 1000)
}, FakerHelper.loadingTimout())
})
}
}
9 changes: 5 additions & 4 deletions src/stories/file/FileMockRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FilePaginationInfo } from '../../files/domain/models/FilePaginationInfo
import { FileMother } from '../../../tests/component/files/domain/models/FileMother'
import { File } from '../../files/domain/models/File'
import { FilePreview } from '../../files/domain/models/FilePreview'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'

export class FileMockRepository implements FileRepository {
constructor(public readonly fileMock?: File) {}
Expand All @@ -23,7 +24,7 @@ export class FileMockRepository implements FileRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FilesMockData(paginationInfo))
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -36,7 +37,7 @@ export class FileMockRepository implements FileRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FilesCountInfoMother.create({ total: 200 }))
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -51,7 +52,7 @@ export class FileMockRepository implements FileRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(19900)
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand All @@ -62,7 +63,7 @@ export class FileMockRepository implements FileRepository {
return new Promise((resolve) => {
setTimeout(() => {
resolve(this.fileMock ?? FileMother.createRealistic())
}, 1000)
}, FakerHelper.loadingTimout())
})
}

Expand Down
7 changes: 4 additions & 3 deletions tests/component/dataset/domain/models/DatasetPreviewMother.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { faker } from '@faker-js/faker'
import { DatasetPreview } from '../../../../../src/dataset/domain/models/DatasetPreview'
import { DatasetVersionMother } from './DatasetMother'
import { FakerHelper } from '../../../shared/FakerHelper'

export class DatasetPreviewMother {
static createMany(count: number): DatasetPreview[] {
Expand All @@ -15,9 +16,9 @@ export class DatasetPreviewMother {
const datasetPreview = {
persistentId: faker.datatype.uuid(),
version: DatasetVersionMother.create(),
releaseOrCreateDate: faker.date.past(),
releaseOrCreateDate: FakerHelper.pastDate(),
description: faker.lorem.paragraph(),
thumbnail: faker.datatype.boolean() ? faker.image.imageUrl() : undefined,
thumbnail: faker.datatype.boolean() ? FakerHelper.getImageUrl() : undefined,
...props
}

Expand All @@ -41,7 +42,7 @@ export class DatasetPreviewMother {
}

static createWithThumbnail(): DatasetPreview {
return this.create({ thumbnail: faker.image.imageUrl() })
return this.create({ thumbnail: FakerHelper.getImageUrl() })
}

static createWithNoThumbnail(): DatasetPreview {
Expand Down
Loading
Loading