From b9c9df1362bfc644321981cf50fd2108b8ae8ed7 Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Wed, 28 Feb 2024 12:26:11 +0000 Subject: [PATCH 1/2] Added media e2e test --- test/e2e/media.cy.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/e2e/media.cy.js diff --git a/test/e2e/media.cy.js b/test/e2e/media.cy.js new file mode 100644 index 0000000..fce3308 --- /dev/null +++ b/test/e2e/media.cy.js @@ -0,0 +1,34 @@ +describe('Media', function () { + beforeEach(function () { + cy.getData() + }); + + it('should display the media component', function () { + const mediaComponents = this.data.components.filter((component) => component._component === 'media') + mediaComponents.forEach((mediaComponent) => { + cy.visit(`/#/preview/${mediaComponent._id}`); + const bodyWithoutHtml = mediaComponent.body.replace(/<[^>]*>/g, ''); + + cy.testContainsOrNotExists('.media__title', mediaComponent.displayTitle) + cy.testContainsOrNotExists('.media__body', bodyWithoutHtml) + cy.testContainsOrNotExists('.media__instruction', mediaComponent.instruction) + + if(mediaComponent._media.mp4) { + cy.get('.mejs-mediaelement video').should('have.attr', 'src', mediaComponent._media.mp4) + } + if(mediaComponent._media.poster) { + cy.get('.mejs-poster img').should('have.attr', 'src', mediaComponent._media.poster) + } + + if(mediaComponent._transcript) { + cy.get('.media__transcript-body-inline').should('not.be.visible') + cy.get('button.media__transcript-btn').should('contain', mediaComponent._transcript.inlineTranscriptButton).click() + cy.get('.media__transcript-body-inline-inner').should('be.visible').should('contain', mediaComponent._transcript.inlineTranscriptBody) + cy.get('button.media__transcript-btn').should('contain', mediaComponent._transcript.inlineTranscriptCloseButton).click() + cy.get('.media__transcript-body-inline').should('not.be.visible') + } + + cy.wait(1000) + }); + }); +}); \ No newline at end of file From ae4af0c5300194c733c51a08c702c7e3f570cce5 Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 1 Mar 2024 10:04:11 +0000 Subject: [PATCH 2/2] Added comments --- test/e2e/media.cy.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/e2e/media.cy.js b/test/e2e/media.cy.js index fce3308..ce9bfe4 100644 --- a/test/e2e/media.cy.js +++ b/test/e2e/media.cy.js @@ -9,18 +9,19 @@ describe('Media', function () { cy.visit(`/#/preview/${mediaComponent._id}`); const bodyWithoutHtml = mediaComponent.body.replace(/<[^>]*>/g, ''); + // Test basic media component cy.testContainsOrNotExists('.media__title', mediaComponent.displayTitle) cy.testContainsOrNotExists('.media__body', bodyWithoutHtml) cy.testContainsOrNotExists('.media__instruction', mediaComponent.instruction) - if(mediaComponent._media.mp4) { + if (mediaComponent._media.mp4) { cy.get('.mejs-mediaelement video').should('have.attr', 'src', mediaComponent._media.mp4) } - if(mediaComponent._media.poster) { + if (mediaComponent._media.poster) { cy.get('.mejs-poster img').should('have.attr', 'src', mediaComponent._media.poster) } - if(mediaComponent._transcript) { + if (mediaComponent._transcript) { cy.get('.media__transcript-body-inline').should('not.be.visible') cy.get('button.media__transcript-btn').should('contain', mediaComponent._transcript.inlineTranscriptButton).click() cy.get('.media__transcript-body-inline-inner').should('be.visible').should('contain', mediaComponent._transcript.inlineTranscriptBody) @@ -28,6 +29,7 @@ describe('Media', function () { cy.get('.media__transcript-body-inline').should('not.be.visible') } + // Allow the component to load and run external custom tests cy.wait(1000) }); });