mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-12-12 07:25:13 +00:00
dc838bc87d
This changes the previous behaviour of fetching always up to 500 most recent revisions. Now the extensions fetches N revisions including the newer revision selected to diff as the most recent revision. N is number of revisions that would fit in the current window when rendered as bars. When user is close to either "end" of the slider, extensions fetches another batch of up to N older or newer revisions, as long as user does not reach the oldest or the newest revision of the page. Among others, this removes the limitations of the previous approach: showing only 500 revisions, and failing to show anything when any of selected revisions was older than 500 recent revisions. This change also simplifies usage of Api class. Bug: T135005 Change-Id: Ib3f4a6ac57ff17008f9d8784c4716bd294443096
62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
( function ( mw ) {
|
|
var SliderView = mw.libs.revisionSlider.SliderView,
|
|
Slider = mw.libs.revisionSlider.Slider,
|
|
RevisionList = mw.libs.revisionSlider.RevisionList,
|
|
Revision = mw.libs.revisionSlider.Revision,
|
|
startHistoryState, startHref;
|
|
|
|
QUnit.module( 'ext.RevisionSlider.SliderView' );
|
|
|
|
QUnit.testStart( function () {
|
|
startHistoryState = history.state;
|
|
startHref = window.location.href;
|
|
} );
|
|
|
|
QUnit.testDone( function () {
|
|
history.replaceState( startHistoryState, 'QUnit', startHref );
|
|
} );
|
|
|
|
QUnit.test( 'render adds the slider view with defined revisions selected', function ( assert ) {
|
|
var $container = $( '<div>' ),
|
|
view = new SliderView( new Slider( new RevisionList( [
|
|
new Revision( { revid: 1, size: 5, comment: 'Comment1', user: 'User1' } ),
|
|
new Revision( { revid: 3, size: 21, comment: 'Comment2', user: 'User2' } ),
|
|
new Revision( { revid: 37, size: 13, comment: 'Comment3', user: 'User3' } )
|
|
] ) ) ),
|
|
$revisionOld,
|
|
$revisionNew;
|
|
|
|
mw.config.values.extRevisionSliderOldRev = 1;
|
|
mw.config.values.extRevisionSliderNewRev = 37;
|
|
|
|
view.render( $container );
|
|
|
|
assert.ok( $container.find( '.mw-revslider-revision-slider' ).length > 0 );
|
|
$revisionOld = $container.find( '.mw-revslider-revision-old' );
|
|
$revisionNew = $container.find( '.mw-revslider-revision-new' );
|
|
assert.ok( $revisionOld.length > 0 );
|
|
assert.equal( $revisionOld.attr( 'data-revid' ), 1 );
|
|
assert.ok( $revisionNew.length > 0 );
|
|
assert.equal( $revisionNew.attr( 'data-revid' ), 37 );
|
|
} );
|
|
|
|
QUnit.test( 'render throws an exception when no selected revisions provided', function ( assert ) {
|
|
var $container = $( '<div>' ),
|
|
view = new SliderView( new Slider( new RevisionList( [
|
|
new Revision( { revid: 1, size: 5, comment: 'Comment1', user: 'User1' } ),
|
|
new Revision( { revid: 3, size: 21, comment: 'Comment2', user: 'User2' } ),
|
|
new Revision( { revid: 37, size: 13, comment: 'Comment3', user: 'User3' } )
|
|
] ) ) );
|
|
|
|
mw.config.values.extRevisionSliderOldRev = null;
|
|
mw.config.values.extRevisionSliderNewRev = null;
|
|
|
|
assert.throws(
|
|
function () {
|
|
view.render( $container );
|
|
}
|
|
);
|
|
} );
|
|
|
|
} )( mediaWiki );
|