From 97ae0bdc95ecb95605fb2f292dd6962ad619aab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Mon, 21 Oct 2024 13:31:15 -0300 Subject: [PATCH] test: case for open and closing modal --- .../sections/collection/Collection.spec.tsx | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/component/sections/collection/Collection.spec.tsx b/tests/component/sections/collection/Collection.spec.tsx index 15f1e32de..8ce5aedc7 100644 --- a/tests/component/sections/collection/Collection.spec.tsx +++ b/tests/component/sections/collection/Collection.spec.tsx @@ -1,15 +1,26 @@ -import { Collection } from '../../../../src/sections/collection/Collection' -import { CollectionRepository } from '../../../../src/collection/domain/repositories/CollectionRepository' -import { CollectionMother } from '../../collection/domain/models/CollectionMother' +import { Collection } from '@/sections/collection/Collection' +import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' +import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother' +import { CollectionItemsMother } from '@tests/component/collection/domain/models/CollectionItemsMother' +import { CollectionItemSubset } from '@/collection/domain/models/CollectionItemSubset' const collectionRepository = {} as CollectionRepository const collection = CollectionMother.create({ name: 'Collection Name' }) const userPermissionsMock = CollectionMother.createUserPermissions() +const items = CollectionItemsMother.createItems({ + numberOfCollections: 4, + numberOfDatasets: 3, + numberOfFiles: 3 +}) + +const itemsWithCount: CollectionItemSubset = { items, totalItemCount: 200 } + describe('Collection page', () => { beforeEach(() => { collectionRepository.getById = cy.stub().resolves(collection) collectionRepository.getUserPermissions = cy.stub().resolves(userPermissionsMock) + collectionRepository.getItems = cy.stub().resolves(itemsWithCount) }) it('renders skeleton while loading', () => { @@ -161,4 +172,28 @@ describe('Collection page', () => { cy.findByRole('button', { name: /Add Data/i }).should('not.exist') }) + + it('opens and close the publish collection modal', () => { + cy.viewport(1200, 800) + const collection = CollectionMother.createUnpublished() + + collectionRepository.getById = cy.stub().resolves(collection) + + cy.mountAuthenticated( + + ) + cy.findByRole('button', { name: /Publish/i }).should('exist') + + cy.findByRole('button', { name: /Publish/i }).click() + cy.findByText('Publish Collection').should('exist') + + cy.findByRole('button', { name: /Cancel/i }).click() + cy.findByText('Publish Collection').should('not.exist') + }) })