Skip to content

Commit

Permalink
feat: add non root editing storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Nov 25, 2024
1 parent c836d0e commit 95601e2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
46 changes: 42 additions & 4 deletions src/stories/edit-collection/EditCollection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { WithLoggedInUser } from '../WithLoggedInUser'
import { CollectionMockRepository } from '../collection/CollectionMockRepository'
import { CollectionLoadingMockRepository } from '../collection/CollectionLoadingMockRepository'
import { NoCollectionMockRepository } from '../collection/NoCollectionMockRepository'
import { CollectionMother } from '../../../tests/component/collection/domain/models/CollectionMother'
import { FakerHelper } from '../../../tests/component/shared/FakerHelper'
import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother'
import { FakerHelper } from '@tests/component/shared/FakerHelper'
import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS'
import { UpwardHierarchyNodeMother } from '@tests/component/shared/hierarchy/domain/models/UpwardHierarchyNodeMother'
import { MetadataBlockInfoMockRepository } from '../shared-mock-repositories/metadata-block-info/MetadataBlockInfoMockRepository'
import { MetadataBlockInfoMockLoadingRepository } from '../shared-mock-repositories/metadata-block-info/MetadataBlockInfoMockLoadingRepository'
import { MetadataBlockInfoMockErrorRepository } from '../shared-mock-repositories/metadata-block-info/MetadataBlockInfoMockErrorRepository'

import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS'

const meta: Meta<typeof EditCollection> = {
title: 'Pages/Edit Collection',
component: EditCollection,
Expand All @@ -27,6 +27,43 @@ export default meta
type Story = StoryObj<typeof EditCollection>

export const Default: Story = {
render: () => {
const collectionRepo = new CollectionMockRepository()
collectionRepo.getById = () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
CollectionMother.create({
id: 'science',
isReleased: true,
name: 'Collection Name',
description: 'We do all the science.',
affiliation: 'Scientific Research University',
hierarchy: UpwardHierarchyNodeMother.createCollection({
id: 'science',
name: 'Collection Name',
parent: UpwardHierarchyNodeMother.createCollection({
id: ROOT_COLLECTION_ALIAS,
name: 'Root'
})
})
})
)
}, FakerHelper.loadingTimout())
})
}

return (
<EditCollection
collectionId="science"
collectionRepository={collectionRepo}
metadataBlockInfoRepository={new MetadataBlockInfoMockRepository()}
/>
)
}
}

export const EditingRoot: Story = {
render: () => (
<EditCollection
collectionId={ROOT_COLLECTION_ALIAS}
Expand All @@ -35,6 +72,7 @@ export const Default: Story = {
/>
)
}

export const Loading: Story = {
render: () => (
<EditCollection
Expand Down
2 changes: 1 addition & 1 deletion tests/component/sections/collection/Collection.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('Collection page', () => {
cy.mountAuthenticated(
<Collection
collectionRepository={collectionRepository}
collectionId="collection"
collectionIdFromParams="collection"
created={false}
published={false}
collectionQueryParams={{ pageQuery: 1 }}
Expand Down

0 comments on commit 95601e2

Please sign in to comment.