diff --git a/client/cypress/tests/players/MediaPlayerContainer.cy.js b/client/cypress/tests/players/MediaPlayerContainer.cy.js index 97a881cb..9fb3f0be 100644 --- a/client/cypress/tests/players/MediaPlayerContainer.cy.js +++ b/client/cypress/tests/players/MediaPlayerContainer.cy.js @@ -256,16 +256,25 @@ describe('MediaPlayerContainer', () => { } cy.stub(win.HTMLMediaElement.prototype, 'load').callsFake(function load() { + if (this.__absLoadedMetadataDispatched) return + + this.__absLoadedMetadataDispatched = true this.dispatchEvent(new win.Event('loadedmetadata')) }).as('mediaLoad') cy.stub(win.HTMLMediaElement.prototype, 'play').callsFake(function play() { + if (this.__absIsPlaying) return Promise.resolve() + + this.__absIsPlaying = true this.dispatchEvent(new win.Event('play')) this.dispatchEvent(new win.Event('playing')) return Promise.resolve() - }).as('mediaPlay') + }).as('mediaPlayCall') cy.stub(win.HTMLMediaElement.prototype, 'pause').callsFake(function pause() { + if (!this.__absIsPlaying) return + + this.__absIsPlaying = false this.dispatchEvent(new win.Event('pause')) }).as('mediaPause') }) @@ -284,7 +293,7 @@ describe('MediaPlayerContainer', () => { cy.get('button[aria-label="Play"]').click() cy.get('@mediaLoad').should('have.been.called') - cy.get('@mediaPlay').should('have.been.calledOnce') + cy.get('@mediaPlayCall').should('have.been.calledTwice') cy.get('@createMediaElementSource').should('have.been.calledOnce') cy.get('audio#audio-player').should(($audio) => { expect($audio[0].src).to.include(FIXTURE_URL)