mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-27 17:40:06 +00:00
tests: Make mmv.ui.metadataPanel.js pass with non-English locale
My browser is configured with en-GB as its locale. This meant that when qqx was passed down, it fell back to my browser's default locale and thus made the tests fail, as the expected data was set against lang=en. Ironically, MMV actually prefers the en-GB date format, and outside tests even replaces 'en' with 'en-GB' when formatting dates in the user interface. It was only in the tests that it asserted the 'en' format that would otherwise never be used by MMV. Ironically, the reason my locale is affecting the test is because we switched from hardcoded lang=en to hardcoded lang=qqx which is meant to disable any influence from localisation. However, when passed to browser-native Intl API, qqx is not valid and thus caused us to not have a hardcoded 'en' but a completely variable UI language based on the developer's browser settings. Bug: T250045 Change-Id: I94ad25cc7060ac5e9db41c6b6767aa9fd687a0db
This commit is contained in:
parent
c8eae3585a
commit
5e1dece304
|
@ -844,7 +844,13 @@
|
|||
MPP.formatDate = function ( dateString ) {
|
||||
var date,
|
||||
lang = mw.config.get( 'wgUserLanguage' );
|
||||
if ( lang === 'en' ) { lang = 'en-GB'; } // for D MMMM YYYY format
|
||||
if ( lang === 'en' || lang === 'qqx' ) {
|
||||
// prefer "D MMMM YYYY" format
|
||||
// avoid passing invalid "qqx" to native toLocaleString(),
|
||||
// which would cause developer's browser locale to be used,
|
||||
// and thus sometimes cause tests to fail.
|
||||
lang = 'en-GB';
|
||||
}
|
||||
date = new Date( dateString );
|
||||
try {
|
||||
if ( date instanceof Date && !isNaN( date ) ) {
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
assert.strictEqual( panel.creditField.$element.find( '.mw-mmv-source' ).html(), '<b>Lost</b><a href="foo">Bar</a>', 'Source text is correctly set' );
|
||||
// Either multimediaviewer-credit-popup-text or multimediaviewer-credit-popup-text-more.
|
||||
assert.ok( creditPopupText === '(multimediaviewer-credit-popup-text)' || creditPopupText === '(multimediaviewer-credit-popup-text-more)', 'Source tooltip is correctly set' );
|
||||
assert.strictEqual( panel.$datetime.text(), '(multimediaviewer-datetime-created: August 26, 2013)', 'Correct date is displayed' );
|
||||
assert.strictEqual( panel.$datetime.text(), '(multimediaviewer-datetime-created: 26 August 2013)', 'Correct date is displayed' );
|
||||
assert.strictEqual( panel.$license.text(), '(multimediaviewer-license-cc-by-2.0)', 'License is correctly set' );
|
||||
assert.ok( panel.$license.prop( 'target' ), 'License information opens in new window' );
|
||||
assert.strictEqual( panel.$restrictions.children().last().children().hasClass( 'mw-mmv-restriction-default' ), true, 'Default restriction is correctly displayed last' );
|
||||
|
@ -154,7 +154,7 @@
|
|||
panel.setImageInfo( image, imageData, repoData );
|
||||
clock.tick( 10 );
|
||||
|
||||
assert.strictEqual( panel.$datetime.text(), '(multimediaviewer-datetime-uploaded: August 25, 2013)', 'Correct date is displayed' );
|
||||
assert.strictEqual( panel.$datetime.text(), '(multimediaviewer-datetime-uploaded: 25 August 2013)', 'Correct date is displayed' );
|
||||
|
||||
clock.restore();
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue