Phuedx has uploaded a new change for review.
https://gerrit.wikimedia.org/r/265482
Change subject: Fix the failing QUnit tests
......................................................................
Fix the failing QUnit tests
c27222b introduced test failures in the tablet-related Placement (image)
and Placement (no headings) cases.
Changes:
* Follow up on 213d845 and make the test results more readable too
* Break apart the long catch-most selector in #insertPanel and comment
the Minerva-specific part
* Add a new selector to the list, which fixes the Placement (image) case
by actually reflecting Minerva's DOM structure
* Fix the Placement (no headings) case by relaxing the requirement that
the first paragraph of an article should be an immediate child of a
div.
Note well that in some the browser tests, we are currently testing
placement on a stub article viewed on a tablet device, the
Placement (no headings) case and corresponding fix cover this.
Bug: T123593
Change-Id: I5b4e19e8669426879ed631ba0200bb0873f76e78
---
M resources/ext.quicksurveys.lib/lib.js
M tests/qunit/ext.quicksurveys.lib/test_lib.js
2 files changed, 21 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys
refs/changes/82/265482/1
diff --git a/resources/ext.quicksurveys.lib/lib.js
b/resources/ext.quicksurveys.lib/lib.js
index 971b09a..ccb2d7a 100644
--- a/resources/ext.quicksurveys.lib/lib.js
+++ b/resources/ext.quicksurveys.lib/lib.js
@@ -27,8 +27,19 @@
$panel.insertAfter( $place );
} else {
$place = $bodyContent
- // Account for the Mobile Frontend section
wrapper around .thumb.
- .find( '.infobox, > div > .thumb, > .thumb, h1,
h2, h3, h4, h5, h6' )
+ .find(
+ [
+ '.infobox',
+
+ // Account for the Mobile
Frontend section wrapper
+ // around .thumb.
+ '> div > div > .thumb',
+
+ '> div > .thumb',
+ '> .thumb',
+ 'h1, h2, h3, h4, h5, h6',
+ ].join(',')
+ )
.filter( ':not(.toc h2)' )
.eq( 0 );
if ( $place.length ) {
@@ -36,7 +47,7 @@
} else {
// Insert this after the first paragraph (for
pages with just one paragraph)
// or the lead section/content container when
no suitable element can be found (empty pages)
- $place = $bodyContent.find( '> div > p' ).eq( 0
);
+ $place = $bodyContent.find( 'p' ).eq( 0 );
// Do this test separately for cases where no
paragraph elements
// are returned in document order so > div
would always come first.
// See
http://blog.jquery.com/2009/02/20/jquery-1-3-2-released/
diff --git a/tests/qunit/ext.quicksurveys.lib/test_lib.js
b/tests/qunit/ext.quicksurveys.lib/test_lib.js
index 51e8c59..bf07c3c 100644
--- a/tests/qunit/ext.quicksurveys.lib/test_lib.js
+++ b/tests/qunit/ext.quicksurveys.lib/test_lib.js
@@ -59,14 +59,14 @@
qSurveys._insertPanel( $locationMinerva, this.getPanel(), true
);
qSurveys._insertPanel( $locationMinervaTablet, this.getPanel()
);
- assert.ok( $locationVector.find( '.test-panel' ).length === 1,
- 'Check only one panel got added.' );
- assert.ok( $locationMinerva.find( '.test-panel' ).length === 1,
- 'Check only one panel got added.' );
- assert.ok( $locationMinervaTablet.find( '.test-panel' ).length
=== 1,
- 'Check only one panel got added.' );
+ assert.equal( $locationVector.find( '.test-panel' ).length, 1,
+ 'Check only one panel got added on Vector' );
+ assert.equal( $locationMinerva.find( '.test-panel' ).length, 1,
+ 'Check only one panel got added on mobile' );
+ assert.equal( $locationMinervaTablet.find( '.test-panel'
).length, 1,
+ 'Check only one panel got added on tablet' );
assert.ok( this.isPanelElement( $locationVector.find( '#firstp'
).next() ),
- 'Check it is inserted in correct place on vector (after
first paragraph)' );
+ 'Check it is inserted in correct place on Vector (after
first paragraph)' );
assert.ok( this.isPanelElement( $locationMinerva.find(
'#firstp' ).next() ),
'Check it is inserted in correct place on mobile (after
first paragraph)' );
assert.ok( this.isPanelElement( $locationMinervaTablet.find(
'#firstp' ).next() ),
--
To view, visit https://gerrit.wikimedia.org/r/265482
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b4e19e8669426879ed631ba0200bb0873f76e78
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/QuickSurveys
Gerrit-Branch: dev
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits