Skip to content

Commit

Permalink
fix(error-display): component remains displayed after player reset (v…
Browse files Browse the repository at this point in the history
…ideojs#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.
  • Loading branch information
amtins authored Nov 28, 2023
1 parent 92b5e79 commit 7972c23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 2 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions test/unit/reset-ui.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 7972c23

Please sign in to comment.