1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-02 06:32:07 +02:00

fix(error-display): component remains displayed after player reset (#8482)

When `player.reset` is called, the `errorDisplay` component is not reset, and neither is `player.error`.

- Sets `player.error` to `null`, so that the `player.errorDisplay` and `player.error` are correctly reset.
- Adds an `error` function to the `testPlayer` stub to prevent tests from failing.
This commit is contained in:
André 2023-11-28 23:38:41 +01:00 committed by GitHub
parent 92b5e79ba9
commit 7972c23a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -3604,6 +3604,9 @@ class Player extends Component {
this.loadTech_(this.options_.techOrder[0], null);
this.techCall_('reset');
this.resetControlBarUI_();
this.error(null);
if (isEvented(this)) {
this.trigger('playerreset');
}

View File

@ -1910,6 +1910,7 @@ QUnit.test('player#reset loads the Html5 tech and then techCalls reset', functio
options_: {
techOrder: ['html5', 'youtube']
},
error() {},
resetCache_() {},
loadTech_(tech, source) {
loadedTech = tech;
@ -1942,6 +1943,7 @@ QUnit.test('player#reset loads the first item in the techOrder and then techCall
options_: {
techOrder: ['youtube', 'html5']
},
error() {},
resetCache_() {},
loadTech_(tech, source) {
loadedTech = tech;

View File

@ -144,3 +144,19 @@ QUnit.test('Calling resetVolumeBar player method should reset volume bar', funct
player.dispose();
});
QUnit.test('Calling reset player method should reset both error display and player error', function(assert) {
const player = TestHelpers.makePlayer({techOrder: ['html5']});
player.error('ERROR');
assert.notOk(player.errorDisplay.hasClass('vjs-hidden'), 'ErrorDisplay is displayed if there is an error');
assert.strictEqual(player.error().message, 'ERROR', 'player error has content');
player.reset();
assert.ok(player.errorDisplay.hasClass('vjs-hidden'), 'ErrorDisplay is not displayed if there is no error');
assert.strictEqual(player.error(), null, 'player error has content');
player.dispose();
});