Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'forceLocalizationDefaults' config option #3128

Merged
merged 5 commits into from Oct 16, 2018

Conversation

DanFerrer
Copy link
Contributor

@DanFerrer DanFerrer commented Oct 11, 2018

This PR will...

  • Add new config option forceLocalizationDefaults
  • Add unit test for config option:
    • Check that page language doesn't change.
    • Check that we don't try to load translation files if config option is true
    • Check we don't use intl block if given.
    • Check localization options in config block still work.

Why is this Pull Request needed?

New a/b test

Are there any points in the code the reviewer needs to double check?

Are there any Pull Requests open in other repos which need to be merged with this?

https://github.com/jwplayer/borg/pull/1056
https://github.com/jwplayer/jwplayer-commercial/pull/5859

Addresses Issue(s):

JW8-2260

@DanFerrer DanFerrer added this to the v8.6.0 milestone Oct 11, 2018
@jwplayer-robot
Copy link

MULTI Build for commit 848d772 passed.
🏗️ jwplayer build SUCCESS
🏗️ jwplayer browserstack tests SUCCESS
🏗️ jwplayer-commercial build SUCCESS
🏗️ jwplayer-commercial browserstack tests SUCCESS
🥒 Automated Tests SUCCESS
🍆 Manual Tests
📺 Views

test/unit/language-test.js Show resolved Hide resolved
test/unit/language-test.js Show resolved Hide resolved
@@ -337,6 +341,30 @@ describe('languageUtils', function() {
expect(customLocalization.pause).to.equal(localizationPause);
expect(customLocalization.stop).to.equal(localizationStop);
});

it('should only use custom localization block if "forceLocalizationDefaults" is true', function() {
stubHtmlLanguage(document, 'fr');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to stub the language on the hmtl, we can stub getLanguage to return 'fr'
import the entire language module import * as Language from 'utils/language';
sandbox.stub(Language, 'getLanguage').returns('fr');

@jwplayer-robot
Copy link

⚠️ MULTI Build for commit f89339e is unstable (UNSTABLE).
🏗️ jwplayer build SUCCESS
🏗️ jwplayer browserstack tests SUCCESS
🏗️ jwplayer-commercial build SUCCESS
🏗️ jwplayer-commercial browserstack tests SUCCESS
🥒 Automated Tests UNSTABLE
🍆 Manual Tests
📺 Views

intl
});
const configLocalization = config.localization;
expect(Language.getLanguage()).to.equal('fr');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to test this; it would mean we are testing the stub

@jwplayer-robot
Copy link

⚠️ MULTI Build for commit 0e1cc97 is unstable (UNSTABLE).
🏗️ jwplayer build SUCCESS
🏗️ jwplayer browserstack tests SUCCESS
🏗️ jwplayer-commercial build SUCCESS
🏗️ jwplayer-commercial browserstack tests SUCCESS
🥒 Automated Tests UNSTABLE
🍆 Manual Tests
📺 Views

@@ -119,7 +119,7 @@ const Config = function(options, persisted) {
_copyToLocalization(allOptions);
_deserialize(allOptions);

const language = getLanguage();
const language = allOptions.forceLocalizationDefaults ? Defaults.language : getLanguage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value of Defaults.language? Why don't we just set a language in the config, and base the test on setupConfig.language? I much rather we use existing config options and support the setting of language in the config, than add a new option that no one need like forceLocalizationDefaults.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults.language is 'en'. I have mixed feelings about providing a config option to override language because we want to support google translate, which overrides the language tag on the page. If the player is setup after google translate then we read the updated language tag.
if the language is being overriden via the config by the developer, then we have to count on them to update it when the page has been translated, which i doubt they would do.

@jwplayer-robot
Copy link

⚠️ MULTI Build for commit 0e1cc97 is unstable (UNSTABLE).
🏗️ jwplayer build SUCCESS
🏗️ jwplayer browserstack tests SUCCESS
🏗️ jwplayer-commercial build SUCCESS
🏗️ jwplayer-commercial browserstack tests SUCCESS
🥒 Automated Tests UNSTABLE
🍆 Manual Tests
📺 Views

@@ -353,18 +343,23 @@ describe('languageUtils', function() {
});

it('should only use custom localization block if "forceLocalizationDefaults" is true', function() {
sandbox.stub(Language, 'getLanguage').returns('fr');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanFerrer why did you remove the stubbing ? If we don't stub then how are we verifying that we override the language when forceLocalizationDefaults is true ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might have misunderstood our conversation from friday. What i meant to say was that expect(Language.getLanguage()).to.equal('fr'); is unnecessary since get language is being stubbed and we don't need to unit test the stubbing.
In order to properly test that forceLocalizationDefaults overrides the language, we need to stub getLanguage. Does this make sense ?

Copy link
Collaborator

@karimMourra karimMourra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwplayer-robot
Copy link

MULTI Build for commit 09882c0 passed.
🏗️ jwplayer build SUCCESS
🏗️ jwplayer browserstack tests SUCCESS
🏗️ jwplayer-commercial build SUCCESS
🏗️ jwplayer-commercial browserstack tests SUCCESS
🥒 Automated Tests SUCCESS
🍆 Manual Tests
📺 Views

Copy link
Collaborator

@karimMourra karimMourra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanFerrer I am approving but let's wait for @robwalch's response in https://github.com/jwplayer/jwplayer/pull/3128/files#r225222580 before merging

@karimMourra karimMourra merged commit fb5b002 into master Oct 16, 2018
@robwalch robwalch deleted the feature/force-english-localization branch January 24, 2019 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants