From be83d0811ac10da553595e7a5a8e46c8f39387ae Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Thu, 5 Sep 2024 14:13:37 +0200 Subject: [PATCH] fix(cypress): wait for ressource load Signed-off-by: skjnldsv --- cypress/e2e/visual-regression.cy.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/visual-regression.cy.ts b/cypress/e2e/visual-regression.cy.ts index 4488b4017..ddd922179 100644 --- a/cypress/e2e/visual-regression.cy.ts +++ b/cypress/e2e/visual-regression.cy.ts @@ -39,7 +39,6 @@ describe('Visual regression tests ', function() { }) it('See files in the list', function() { - // TODO: Do we care about the file name being split by a ' ' in the text property? cy.getFile('test-card.mp4', { timeout: 10000 }) .should('contain', 'test-card .mp4') cy.getFile('test-card.png', { timeout: 10000 }) @@ -47,7 +46,12 @@ describe('Visual regression tests ', function() { }) it('Open the viewer on file click', function() { + cy.intercept('GET', '**/core/preview*').as('image1') + cy.intercept('GET', '/remote.php/dav/files/*/test-card.mp4').as('video') cy.openFile('test-card.mp4') + cy.wait('@video') + // We preload images, so we can check its loading here and not when clicking next + cy.wait('@image1') cy.get('body > .viewer').should('be.visible') }) @@ -82,7 +86,7 @@ describe('Visual regression tests ', function() { // eslint-disable-next-line cy.wait(250) cy.compareSnapshot('video', 0.02) - }) + }, { retries: 0 }) it('Show second file on next', function() { cy.get('body > .viewer button.next').click() @@ -101,12 +105,15 @@ describe('Visual regression tests ', function() { it('Take test-card.png screenshot', function() { cy.compareSnapshot('image') - }) + }, { retries: 0 }) it('Close and open image again', function() { cy.get('body > .viewer button.header-close').click() cy.get('body > .viewer').should('not.exist') + + // No need to intercept the request again, it's cached cy.openFile('test-card.png') + cy.get('body > .viewer').should('be.visible') cy.get('body > .viewer .modal-header__name').should('contain', 'test-card.png') cy.get('body > .viewer .modal-container img').should('have.length', 1) @@ -124,7 +131,7 @@ describe('Visual regression tests ', function() { it('Take test-card.png screenshot 2', function() { cy.compareSnapshot('image2') - }) + }, { retries: 0 }) it('Open non-dav image', function() { const fileInfo = { @@ -136,13 +143,14 @@ describe('Visual regression tests ', function() { hasPreview: false, fileid: 123, } - + cy.intercept('GET', '/core/img/favicon.png').as('favicon') cy.window().then((win) => { win.OCA.Viewer.open({ fileInfo, list: [fileInfo], }) }) + cy.wait('@favicon') cy.get('body > .viewer .modal-container img').should('have.length', 1) cy.get('body > .viewer .modal-container img').should('have.attr', 'src') @@ -159,5 +167,5 @@ describe('Visual regression tests ', function() { it('Take non-dav logo.png screenshot', function() { cy.compareSnapshot('non-dav') - }) + }, { retries: 0 }) })