Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/212274

Change subject: Fix two failing QUnit tests
......................................................................

Fix two failing QUnit tests

These two tests fail on my local machine. I am making the two
assertions independent from
a) the order of HTML attributes (the test should not care about
   the order, only if the attributes are there or not)
b) the message (both messages are possible and valid, the question
   which message should appear is not part of that specific test).

Change-Id: I69b4793d365d3afebb869c787316e4242cb15b25
---
M tests/qunit/mmv/mmv.bootstrap.test.js
M tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
2 files changed, 10 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer 
refs/changes/74/212274/1

diff --git a/tests/qunit/mmv/mmv.bootstrap.test.js 
b/tests/qunit/mmv/mmv.bootstrap.test.js
index f5b3dbc..9ddd3aa 100644
--- a/tests/qunit/mmv/mmv.bootstrap.test.js
+++ b/tests/qunit/mmv/mmv.bootstrap.test.js
@@ -284,7 +284,7 @@
                $link.trigger( { type: 'click', which: 1 } );
        } );
 
-       QUnit.test( 'Validate new LightboxImage object has sane constructor 
parameters', 8, function ( assert ) {
+       QUnit.test( 'Validate new LightboxImage object has sane constructor 
parameters', 9, function ( assert ) {
                var bootstrap,
                        $div,
                        $link,
@@ -299,11 +299,14 @@
                viewer.loadImage = $.noop;
 
                viewer.createNewImage = function ( fileLink, filePageLink, 
fileTitle, index, thumb, caption, alt ) {
+                       var html = thumb.outerHTML;
+
                        assert.ok( fileLink.match( imgRegex ), 'Thumbnail URL 
used in creating new image object' );
                        assert.strictEqual( filePageLink, '', 'File page link 
is sane when creating new image object' );
                        assert.strictEqual( fileTitle.title, fname, 'Filename 
is correct when passed into new image constructor' );
                        assert.strictEqual( index, 0, 'The only image we 
created in the gallery is set at index 0 in the images array' );
-                       assert.strictEqual( thumb.outerHTML, '<img src="' + 
imgSrc + '" alt="meow">', 'The image element passed in is the thumbnail we 
want.' );
+                       assert.ok( html.indexOf( ' src="' + imgSrc + '"' ) > 0, 
'The image element passed in contains the src=... we want.' );
+                       assert.ok( html.indexOf( ' alt="meow"' ) > 0, 'The 
image element passed in contains the alt=... we want.' );
                        assert.strictEqual( caption, 'Blah blah', 'The caption 
passed in is correct' );
                        assert.strictEqual( alt, 'meow', 'The alt text passed 
in is correct' );
                };
diff --git a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js 
b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
index 09b092c..0760bac 100644
--- a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
+++ b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
@@ -98,7 +98,8 @@
        } );
 
        QUnit.test( 'Setting image information works as expected', 18, function 
( assert ) {
-               var gender,
+               var creditPopupText,
+                       gender,
                        $qf = $( '#qunit-fixture' ),
                        panel = new mw.mmv.ui.MetadataPanel( $qf, $( '<div>' 
).appendTo( $qf ), window.localStorage, new mw.mmv.Config( {}, mw.config, 
mw.user, new mw.Api(), window.localStorage ) ),
                        title = 'Foo bar',
@@ -145,13 +146,15 @@
                imageData.lastUploader = 'Ursula';
 
                panel.setImageInfo( image, imageData, repoData, gender );
+               creditPopupText = panel.creditField.$element.attr( 
'original-title' );
 
                assert.strictEqual( panel.$title.text(), title, 'Title is 
correctly set' );
                assert.ok( !panel.$credit.hasClass( 'empty' ), 'Credit is not 
empty' );
                assert.ok( !panel.$datetimeLi.hasClass( 'empty' ), 'Date/Time 
is not empty' );
                assert.strictEqual( panel.creditField.$element.find( 
'.mw-mmv-author' ).text(), imageData.author, 'Author text is correctly set' );
                assert.strictEqual( panel.creditField.$element.find( 
'.mw-mmv-source' ).html(), '<b>Lost</b><a href="foo">Bar</a>', 'Source text is 
correctly set' );
-               assert.strictEqual( panel.creditField.$element.attr( 
'original-title' ), 'Author and source information', 'Source tooltip is 
correctly set' );
+               // Either multimediaviewer-credit-popup-text or 
multimediaviewer-credit-popup-text-more.
+               assert.ok( creditPopupText === 'Author and source information' 
|| creditPopupText === 'View full author and source', 'Source tooltip is 
correctly set' );
                assert.ok( panel.$datetime.text().indexOf( 'August 26, 2013' ) 
> 0, 'Correct date is displayed' );
                assert.strictEqual( panel.$license.text(), 'CC BY 2.0', 
'License is correctly set' );
                assert.ok( panel.$license.prop( 'target' ), 'License 
information opens in new window' );

-- 
To view, visit https://gerrit.wikimedia.org/r/212274
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I69b4793d365d3afebb869c787316e4242cb15b25
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to