Skip to content

Commit

Permalink
fix(FEC-11525): disableUserCache is not working properly for text sty…
Browse files Browse the repository at this point in the history
…le (#487)

### Description of the Changes

**issue:**
when disableUserCache=true, the captions text style is still being overridden by local storage.

**solution:**
check disableUserCache value when setting textStyle from local storage.

Solves FEC-11525
  • Loading branch information
lianbenjamin authored Sep 14, 2021
1 parent 32a2a16 commit a44e060
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function applyCastSupport(defaultOptions: KPOptionsObject, player: KalturaPlayer
* @returns {void}
*/
function setStorageTextStyle(player: KalturaPlayer): void {
if (StorageManager.isLocalStorageAvailable()) {
if (!player.config.disableUserCache && StorageManager.isLocalStorageAvailable()) {
const textStyleObj = StorageManager.getPlayerTextStyle();
if (textStyleObj) {
player.textStyle = Utils.Object.mergeDeep(new TextStyle(), textStyleObj);
Expand Down
31 changes: 31 additions & 0 deletions test/src/common/storage/storage-manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import StorageWrapper from '../../../../src/common/storage/storage-wrapper';
import * as TestUtils from '../../utils/test-utils';
import {setup} from '../../../../src';
import {FakeEvent} from '@playkit-js/playkit-js';
import {setStorageTextStyle} from '../../../../src/common/utils/setup-helpers';

const targetId = 'player-placeholder_storage-manager.spec';

Expand Down Expand Up @@ -92,4 +93,34 @@ describe('StorageManager', function () {
StorageManager.getStorageConfig().playback.volume.should.equals(0);
});
});

it('should set textStyle of player with textStyle from local storage', function () {
let player = {
config: {
disableUserCache: false
},
textStyle: {
fontFamily: 'Verdana'
}
};
sandbox.stub(StorageManager, 'getPlayerTextStyle').returns({fontFamily: 'Arial'});
sandbox.stub(StorageManager, 'isLocalStorageAvailable').returns(true);
setStorageTextStyle(player);
player.textStyle.fontFamily.should.equal('Arial');
});

it('should not change textStyle of player', function () {
let player = {
config: {
disableUserCache: true
},
textStyle: {
fontFamily: 'Verdana'
}
};
sandbox.stub(StorageManager, 'getPlayerTextStyle').returns({fontFamily: 'Arial'});
sandbox.stub(StorageManager, 'isLocalStorageAvailable').returns(true);
setStorageTextStyle(player);
player.textStyle.fontFamily.should.equal('Verdana');
});
});

0 comments on commit a44e060

Please sign in to comment.