From 29a30237bf1328a25addc581474f576585b4db7b Mon Sep 17 00:00:00 2001 From: German Saracca Date: Fri, 19 Apr 2024 15:00:12 -0300 Subject: [PATCH] test: add test for upload dataset files page --- .../UploadDatasetFiles.spec.tsx | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx diff --git a/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx b/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx new file mode 100644 index 000000000..8cd23e138 --- /dev/null +++ b/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx @@ -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( + + {component} + + ) + } + + it('renders skeleton while loading', () => { + const testDataset = DatasetMother.create() + + mountWithDataset(, 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(, emptyDataset) + + cy.findByText('Page Not Found').should('exist') + }) + + it('renders the breadcrumbs', () => { + const testDataset = DatasetMother.create() + + mountWithDataset(, testDataset) + + cy.findByText('Dataset Title').should('exist').should('have.class', 'active') + cy.findByRole('link', { name: 'Root' }).should('exist') + }) +})