From cf627bc707c17f32de697bbb0057655db2a3817f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 15 Jul 2011 17:29:17 +0000 Subject: [PATCH] Revert r92238: partial addition of broken test cases to qunit test suite; loading of modules with uninitialized data triggers errors in console and marks the entire revision black in TestSwarm. --- languages/messages/MessagesEn.php | 3 -- maintenance/language/messages.inc | 3 -- resources/Resources.php | 3 -- .../mediawiki.page.ajaxCategories.js | 11 ++++-- resources/mediawiki/mediawiki.util.js | 6 --- tests/qunit/index.html | 5 +-- .../resources/jquery/jquery.localize.js | 8 ++-- .../mediawiki.page.ajaxCategories.js | 38 +++++++++++++++++++ 8 files changed, 51 insertions(+), 26 deletions(-) diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index c34e88821d..e64fd6b777 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -4602,9 +4602,6 @@ Click "Save" to save your edit.', 'ajax-add-category-summary' => 'Add category "$1"', 'ajax-edit-category-summary' => 'Change category "$1" to "$2"', 'ajax-remove-category-summary' => 'Remove category "$1"', -'ajax-add-category-question' => 'Why do you want to add category "$1"?', -'ajax-edit-category-question' => 'Why do you want to change category "$1" to "$2"?', -'ajax-remove-category-question'=> 'Why do you want to remove category "$1"?', 'ajax-confirm-actionsummary' => 'Action to take:', 'ajax-error-title' => 'Error', 'ajax-error-dismiss' => 'OK', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 90b325290b..a66d1a57e7 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -3473,9 +3473,6 @@ $wgMessageStructure = array( 'ajax-add-category-summary', 'ajax-edit-category-summary', 'ajax-remove-category-summary', - 'ajax-add-category-question', - 'ajax-edit-category-question', - 'ajax-remove-category-question', 'ajax-confirm-actionsummary', 'ajax-error-title', 'ajax-error-dismiss', diff --git a/resources/Resources.php b/resources/Resources.php index 272a033bfb..98b508e3aa 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -508,9 +508,6 @@ return array( 'ajax-add-category-summary', 'ajax-remove-category-summary', 'ajax-edit-category-summary', - 'ajax-add-category-question', - 'ajax-edit-category-question', - 'ajax-remove-category-question', 'ajax-confirm-actionsummary', 'ajax-error-title', 'ajax-error-dismiss', diff --git a/resources/mediawiki.page/mediawiki.page.ajaxCategories.js b/resources/mediawiki.page/mediawiki.page.ajaxCategories.js index 9f52715ef9..ff3b727584 100644 --- a/resources/mediawiki.page/mediawiki.page.ajaxCategories.js +++ b/resources/mediawiki.page/mediawiki.page.ajaxCategories.js @@ -85,7 +85,7 @@ var ajaxCategories = function ( options ) { // strip out bad characters cat = _stripIllegals ( cat ); - if ( $.isEmpty( cat ) || this.containsCat( cat ) ) { + if ( $.isEmpty( cat ) || _containsCat( cat ) ) { return; } @@ -157,7 +157,7 @@ var ajaxCategories = function ( options ) { * * @return boolean True for exists */ - this.containsCat = function ( cat ) { + _containsCat = function ( cat ) { return _getCats().filter( function() { return $.ucFirst(this) == $.ucFirst(cat); } ).length !== 0; }; @@ -449,7 +449,7 @@ var ajaxCategories = function ( options ) { var category = $( this ).parent().find( '.mw-addcategory-input' ).val(); category = $.ucFirst( category ); - if ( this.containsCat(category) ) { + if ( _containsCat(category) ) { _showError( mw.msg( 'ajax-category-already-present', category ) ); return; } @@ -463,7 +463,6 @@ var ajaxCategories = function ( options ) { }, summary, function() { - $container.find( '#mw-normal-catlinks>.mw-addcategory-prompt' ).toggle(); _insertCatDOM( category, false ); } ); @@ -688,4 +687,8 @@ var ajaxCategories = function ( options ) { // Now make a new version mw.ajaxCategories = new ajaxCategories(); +// Executing only on doc.ready, so that everyone +// gets a chance to set mw.config.set('disableAJAXCategories') +$( document ).ready( mw.ajaxCategories.setup() ); + } )( jQuery, mediaWiki ); \ No newline at end of file diff --git a/resources/mediawiki/mediawiki.util.js b/resources/mediawiki/mediawiki.util.js index 38584c0a77..ebd63ef275 100644 --- a/resources/mediawiki/mediawiki.util.js +++ b/resources/mediawiki/mediawiki.util.js @@ -99,12 +99,6 @@ $tocToggleLink.click(); } } - /* Ajax Categories */ - if ( mw.ajaxCategories ) { - // Execute only on doc.ready, so that everyone - // gets a chance to set mw.config.set('disableAJAXCategories') - mw.ajaxCategories.setup() - } } ); return true; diff --git a/tests/qunit/index.html b/tests/qunit/index.html index f27f1d2db3..f0db23c295 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -47,11 +47,9 @@ - - @@ -77,7 +75,6 @@ -

MediaWiki JavaScript Test Suite

@@ -88,7 +85,7 @@

    - +
    diff --git a/tests/qunit/suites/resources/jquery/jquery.localize.js b/tests/qunit/suites/resources/jquery/jquery.localize.js index 43eac092b6..774cbc31f3 100644 --- a/tests/qunit/suites/resources/jquery/jquery.localize.js +++ b/tests/qunit/suites/resources/jquery/jquery.localize.js @@ -12,14 +12,16 @@ test( 'Handle basic replacements', function() { mw.messages.set( 'basic', 'Basic stuff' ); // Tag: html:msg - html = '
    '; + html = '
    '; $lc = $( html ).localize().find( 'span' ); + console.log($lc.length); strictEqual( $lc.text(), 'Basic stuff', 'Tag: html:msg' ); // Tag: msg (deprecated) - html = '
    '; + html = '
    '; $lc = $( html ).localize().find( 'span' ); + $('body').append($lc); strictEqual( $lc.text(), 'Basic stuff', 'Tag: msg' ); @@ -46,7 +48,7 @@ test( 'Proper escaping', function() { // making sure it is actually using text() and attr() (or something with the same effect) // Text escaping - html = '
    '; + html = '
    '; $lc = $( html ).localize().find( 'span' ); strictEqual( $lc.text(), mw.msg( 'properfoo' ), 'Content is inserted as text, not as html.' ); diff --git a/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js b/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js index 8d87b0e4ac..7e26300136 100644 --- a/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js +++ b/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js @@ -33,4 +33,42 @@ test( 'Testing containsCat', function() { equal(ret, true); }); +})( mediaWiki ); +console.log('wtf0'); +(function( mw ) { + +console.log('wtf1'); +module( 'mediawiki.page.ajaxCategories.js' ); +mw.config.set( 'wgNamespaceIds', {'category' : 14} ); +test( '-- Initial check', function() { + expect(1); + ok( mw.ajaxCategories, 'mw.ajaxCategories defined' ); +}); + +/** + * Create a category list like the one found below articles. + * @param {String[]} categories + * @return jQuery + */ +var listCreate = function( categories ) { + var $container = $(''), + $ul = $container.find('ul'); + $.each( categories, function(i, str) { + var $li = $('
  1. '); + $li.text(str).appendTo($ul); + }); + + return $container; +}; +catList1 = ['Earth satellites', 'Space stations', 'astronauts']; + +test( 'Testing containsCat', function() { + expect(1); + $( 'body' ).append( listCreate(catList1) ); + mw.ajaxCategories.setup(); + var ret = mw.ajaxCategories.containsCat('Earth satellites') + + equal(ret, true); +}); + })( mediaWiki ); \ No newline at end of file -- 2.20.1