Skip to content

Commit

Permalink
test: add test for upload dataset files page
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Apr 19, 2024
1 parent 0ddb143 commit 29a3023
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { DatasetRepository } from '../../../../src/dataset/domain/repositories/DatasetRepository'
import { DatasetMother } from '../../dataset/domain/models/DatasetMother'
import { FileRepository } from '../../../../src/files/domain/repositories/FileRepository'
import { Dataset as DatasetModel } from '../../../../src/dataset/domain/models/Dataset'
import { ReactNode } from 'react'
import { DatasetProvider } from '../../../../src/sections/dataset/DatasetProvider'
import { UploadDatasetFiles } from '../../../../src/sections/upload-dataset-files/UploadDatasetFiles'

const fileRepository: FileRepository = {} as FileRepository
const datasetRepository: DatasetRepository = {} as DatasetRepository

describe('Dataset', () => {
const mountWithDataset = (component: ReactNode, dataset: DatasetModel | undefined) => {
const searchParams = { persistentId: 'some-persistent-id' }
datasetRepository.getByPersistentId = cy.stub().resolves(dataset)

cy.customMount(
<DatasetProvider repository={datasetRepository} searchParams={searchParams}>
{component}
</DatasetProvider>
)
}

it('renders skeleton while loading', () => {
const testDataset = DatasetMother.create()

mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset)

cy.findByText('Temporary Loading until having shape of skeleton').should('exist')
cy.findByText(testDataset.version.title).should('not.exist')
})

it('renders page not found when dataset is null', () => {
const emptyDataset = DatasetMother.createEmpty()

mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, emptyDataset)

cy.findByText('Page Not Found').should('exist')
})

it('renders the breadcrumbs', () => {
const testDataset = DatasetMother.create()

mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset)

cy.findByText('Dataset Title').should('exist').should('have.class', 'active')
cy.findByRole('link', { name: 'Root' }).should('exist')
})
})

0 comments on commit 29a3023

Please sign in to comment.