r92253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92252‎ | r92253 | r92254 >
Date:17:29, 15 July 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.util.js (modified) (history)
  • /trunk/phase3/tests/qunit/index.html (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.localize.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -3473,9 +3473,6 @@
34743474 'ajax-add-category-summary',
34753475 'ajax-edit-category-summary',
34763476 'ajax-remove-category-summary',
3477 - 'ajax-add-category-question',
3478 - 'ajax-edit-category-question',
3479 - 'ajax-remove-category-question',
34803477 'ajax-confirm-actionsummary',
34813478 'ajax-error-title',
34823479 'ajax-error-dismiss',
Index: trunk/phase3/tests/qunit/index.html
@@ -47,11 +47,9 @@
4848 <script src="../../resources/jquery/jquery.localize.js"></script>
4949 <script src="../../resources/jquery/jquery.tabIndex.js"></script>
5050 <script src="../../resources/jquery/jquery.tablesorter.js"></script>
51 - <script src="../../resources/jquery/jquery.suggestions.js"></script>
5251 <script src="../../resources/mediawiki/mediawiki.Title.js"></script>
5352 <script src="../../resources/mediawiki.special/mediawiki.special.js"></script>
5453 <script src="../../resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
55 - <script src="../../resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script>
5654
5755 <!-- QUnit: Load framework -->
5856 <link rel="stylesheet" href="../../resources/jquery/jquery.qunit.css" />
@@ -77,7 +75,6 @@
7876 <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script>
7977 <script src="suites/resources/mediawiki/mediawiki.Title.js"></script>
8078 <script src="suites/resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
81 - <!--<script src="suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script>-->
8279 </head>
8380 <body>
8481 <h1 id="qunit-header">MediaWiki JavaScript Test Suite</h1>
@@ -88,7 +85,7 @@
8986 <h2 id="qunit-userAgent"></h2>
9087 <ol id="qunit-tests"></ol>
9188
92 -<!-- Scripts inserting stuff here shall remove it themselves! -->
 89+<!-- Scripts inserting stuff here shall remove it themselfs! -->
9390 <div id="content"></div>
9491 </body>
9592 </html>
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.localize.js
@@ -12,14 +12,16 @@
1313 mw.messages.set( 'basic', 'Basic stuff' );
1414
1515 // Tag: html:msg
16 - html = '<div><span><html:msg key="basic"></span></div>';
 16+ html = '<div><span><html:msg key="basic"/></span></div>';
1717 $lc = $( html ).localize().find( 'span' );
 18+ console.log($lc.length);
1819
1920 strictEqual( $lc.text(), 'Basic stuff', 'Tag: html:msg' );
2021
2122 // Tag: msg (deprecated)
22 - html = '<div><span><msg key="basic"></span></div>';
 23+ html = '<div><span><msg key="basic"/></span></div>';
2324 $lc = $( html ).localize().find( 'span' );
 25+ $('body').append($lc);
2426
2527 strictEqual( $lc.text(), 'Basic stuff', 'Tag: msg' );
2628
@@ -46,7 +48,7 @@
4749 // making sure it is actually using text() and attr() (or something with the same effect)
4850
4951 // Text escaping
50 - html = '<div><span><html:msg key="properfoo"></span></div>';
 52+ html = '<div><span><html:msg key="properfoo"/></span></div>';
5153 $lc = $( html ).localize().find( 'span' );
5254
5355 strictEqual( $lc.text(), mw.msg( 'properfoo' ), 'Content is inserted as text, not as html.' );
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js
@@ -33,4 +33,42 @@
3434 equal(ret, true);
3535 });
3636
 37+})( mediaWiki );
 38+console.log('wtf0');
 39+(function( mw ) {
 40+
 41+console.log('wtf1');
 42+module( 'mediawiki.page.ajaxCategories.js' );
 43+mw.config.set( 'wgNamespaceIds', {'category' : 14} );
 44+test( '-- Initial check', function() {
 45+ expect(1);
 46+ ok( mw.ajaxCategories, 'mw.ajaxCategories defined' );
 47+});
 48+
 49+/**
 50+ * Create a category list like the one found below articles.
 51+ * @param {String[]} categories
 52+ * @return jQuery
 53+ */
 54+var listCreate = function( categories ) {
 55+ var $container = $('<div id="catlinks" class="catlinks"><div id="mw-normal-catlinks"><ul></ul></div></div>'),
 56+ $ul = $container.find('ul');
 57+ $.each( categories, function(i, str) {
 58+ var $li = $('<li>');
 59+ $li.text(str).appendTo($ul);
 60+ });
 61+
 62+ return $container;
 63+};
 64+catList1 = ['Earth satellites', 'Space stations', 'astronauts'];
 65+
 66+test( 'Testing containsCat', function() {
 67+ expect(1);
 68+ $( 'body' ).append( listCreate(catList1) );
 69+ mw.ajaxCategories.setup();
 70+ var ret = mw.ajaxCategories.containsCat('Earth satellites')
 71+
 72+ equal(ret, true);
 73+});
 74+
3775 })( mediaWiki );
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4602,9 +4602,6 @@
46034603 'ajax-add-category-summary' => 'Add category "$1"',
46044604 'ajax-edit-category-summary' => 'Change category "$1" to "$2"',
46054605 'ajax-remove-category-summary' => 'Remove category "$1"',
4606 -'ajax-add-category-question' => 'Why do you want to add category "$1"?',
4607 -'ajax-edit-category-question' => 'Why do you want to change category "$1" to "$2"?',
4608 -'ajax-remove-category-question'=> 'Why do you want to remove category "$1"?',
46094606 'ajax-confirm-actionsummary' => 'Action to take:',
46104607 'ajax-error-title' => 'Error',
46114608 'ajax-error-dismiss' => 'OK',
Index: trunk/phase3/resources/Resources.php
@@ -508,9 +508,6 @@
509509 'ajax-add-category-summary',
510510 'ajax-remove-category-summary',
511511 'ajax-edit-category-summary',
512 - 'ajax-add-category-question',
513 - 'ajax-edit-category-question',
514 - 'ajax-remove-category-question',
515512 'ajax-confirm-actionsummary',
516513 'ajax-error-title',
517514 'ajax-error-dismiss',
Index: trunk/phase3/resources/mediawiki/mediawiki.util.js
@@ -99,12 +99,6 @@
100100 $tocToggleLink.click();
101101 }
102102 }
103 - /* Ajax Categories */
104 - if ( mw.ajaxCategories ) {
105 - // Execute only on doc.ready, so that everyone
106 - // gets a chance to set mw.config.set('disableAJAXCategories')
107 - mw.ajaxCategories.setup()
108 - }
109103 } );
110104
111105 return true;
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js
@@ -85,7 +85,7 @@
8686 // strip out bad characters
8787 cat = _stripIllegals ( cat );
8888
89 - if ( $.isEmpty( cat ) || this.containsCat( cat ) ) {
 89+ if ( $.isEmpty( cat ) || _containsCat( cat ) ) {
9090 return;
9191 }
9292
@@ -157,7 +157,7 @@
158158 *
159159 * @return boolean True for exists
160160 */
161 - this.containsCat = function ( cat ) {
 161+ _containsCat = function ( cat ) {
162162 return _getCats().filter( function() { return $.ucFirst(this) == $.ucFirst(cat); } ).length !== 0;
163163 };
164164
@@ -449,7 +449,7 @@
450450 var category = $( this ).parent().find( '.mw-addcategory-input' ).val();
451451 category = $.ucFirst( category );
452452
453 - if ( this.containsCat(category) ) {
 453+ if ( _containsCat(category) ) {
454454 _showError( mw.msg( 'ajax-category-already-present', category ) );
455455 return;
456456 }
@@ -463,7 +463,6 @@
464464 },
465465 summary,
466466 function() {
467 - $container.find( '#mw-normal-catlinks>.mw-addcategory-prompt' ).toggle();
468467 _insertCatDOM( category, false );
469468 }
470469 );
@@ -688,4 +687,8 @@
689688 // Now make a new version
690689 mw.ajaxCategories = new ajaxCategories();
691690
 691+// Executing only on doc.ready, so that everyone
 692+// gets a chance to set mw.config.set('disableAJAXCategories')
 693+$( document ).ready( mw.ajaxCategories.setup() );
 694+
692695 } )( jQuery, mediaWiki );
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r92255followup r92253: revert accidental commit of test codebrion17:34, 15 July 2011
r92264r92253 : readd useful changesdiebuche18:19, 15 July 2011
r92271Fix r92253diebuche18:34, 15 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92238AjaxCategories: move self init to mw.util.init; start with qunitdiebuche11:12, 15 July 2011

Comments

#Comment by DieBuche (talk | contribs)   18:23, 15 July 2011

You reverted a lot, but don't seem to have actually reverted the problematic files...

Status & tagging log