Skip to content

Commit

Permalink
fix(cypress): wait for ressource load
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Sep 5, 2024
1 parent 44195b2 commit 677539a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cypress/e2e/visual-regression.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ 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 })
.should('contain', 'test-card .png')
})

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')
})

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 677539a

Please sign in to comment.