From 080b4f2e21b8fe52a14af77dbed5059bbab3069c Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Mon, 23 Sep 2024 14:22:58 -0400 Subject: [PATCH] test: update component and e2e test --- .../PublishCollectionModal.spec.tsx | 2 +- .../e2e/sections/collection/Collection.spec.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/component/sections/collection/collection-publish/PublishCollectionModal.spec.tsx b/tests/component/sections/collection/collection-publish/PublishCollectionModal.spec.tsx index 4cb56939e..f6051500b 100644 --- a/tests/component/sections/collection/collection-publish/PublishCollectionModal.spec.tsx +++ b/tests/component/sections/collection/collection-publish/PublishCollectionModal.spec.tsx @@ -39,7 +39,7 @@ describe('PublishCollectionModal', () => { // Check if the modal is rendered cy.findByText('Publish Collection').should('exist') cy.contains('Are you sure you want to publish your collection?').should('exist') - cy.findByText('Continue').click() + cy.findByRole('button', { name: 'Continue' }).click() cy.get('@repositoryPublish').should('have.been.calledWith', 'testCollectionId') }) }) diff --git a/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts b/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts index 097db570d..411c7d713 100644 --- a/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts +++ b/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts @@ -31,7 +31,23 @@ describe('Collection Page', () => { cy.findAllByText(title).should('be.visible') }) }) + it('Successfully publishes a collection', () => { + const timestamp = new Date().valueOf() + const uniqueCollectionId = `test-publish-collection-${timestamp}` + cy.wrap(CollectionHelper.create(uniqueCollectionId)) + .its('id') + .then((collectionId: string) => { + console.log('collectionId', collectionId) + cy.visit(`/spa/collections/${collectionId}`) + cy.findByText('Unpublished').should('exist') + cy.findByRole('button', { name: 'Publish' }).click() + cy.findByText(/Publish Collection/i).should('exist') + cy.findByRole('button', { name: 'Continue' }).click() + cy.contains('Your collection is now public.').should('exist') + cy.findByText('Unpublished').should('not.exist') + }) + }) it('Navigates to Create Dataset page when New Dataset link clicked', () => { cy.visit('/spa/collections')