From 677539a605ccbd1070c72cb16cc68aa44e9f9da4 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/visual-regression.cy.ts b/cypress/e2e/visual-regression.cy.ts index 4488b4017..085e14106 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') }) @@ -106,7 +110,11 @@ describe('Visual regression tests ', function() { it('Close and open image again', function() { cy.get('body > .viewer button.header-close').click() cy.get('body > .viewer').should('not.exist') + + cy.intercept('GET', '**/core/preview*').as('image2') cy.openFile('test-card.png') + cy.wait('@image2') + 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) @@ -136,13 +144,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')