2020-06-09 10:27:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const assert = require( 'assert' ),
|
2018-11-19 16:00:32 +00:00
|
|
|
Api = require( 'wdio-mediawiki/Api' ),
|
|
|
|
CitePage = require( '../pageobjects/cite.page' ),
|
|
|
|
Util = require( 'wdio-mediawiki/Util' );
|
|
|
|
|
|
|
|
describe( 'Cite backlinks', function () {
|
2020-06-09 10:27:52 +00:00
|
|
|
let title;
|
2018-11-19 16:00:32 +00:00
|
|
|
|
|
|
|
before( function () {
|
|
|
|
title = Util.getTestString( 'CiteTest-title-' );
|
|
|
|
|
2020-06-14 19:41:07 +00:00
|
|
|
browser.call( async () => {
|
|
|
|
const bot = await Api.bot();
|
|
|
|
await bot.edit(
|
2018-11-19 16:00:32 +00:00
|
|
|
title,
|
2019-03-20 15:31:00 +00:00
|
|
|
'This is reference #1: <ref name="a">This is citation #1 for reference #1 and #2</ref>\n\n' +
|
|
|
|
'This is reference #2: <ref name="a" />\n\n' +
|
|
|
|
'This is reference #3: <ref>This is citation #2</ref>\n\n' +
|
2018-11-19 16:00:32 +00:00
|
|
|
'<references />'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
beforeEach( function () {
|
|
|
|
CitePage.openTitle( title );
|
2019-04-08 11:26:45 +00:00
|
|
|
CitePage.scriptsReady();
|
2018-11-19 16:00:32 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'are highlighted in the reference list when there are multiple used references', function () {
|
|
|
|
CitePage.getReference( 2 ).click();
|
|
|
|
assert(
|
|
|
|
CitePage.getCiteSubBacklink( 2 ).getAttribute( 'class' )
|
|
|
|
.indexOf( 'mw-cite-targeted-backlink' ) !== -1,
|
|
|
|
'the jump mark symbol of the backlink is highlighted'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'clickable up arrow is hidden by default when there are multiple backlinks', function () {
|
|
|
|
assert(
|
2020-06-14 19:41:07 +00:00
|
|
|
!CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
2018-11-19 16:00:32 +00:00
|
|
|
'the up-pointing arrow in the reference line is not linked'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'clickable up arrow shows when jumping to multiple used references', function () {
|
|
|
|
CitePage.getReference( 2 ).click();
|
|
|
|
assert(
|
2020-06-14 19:41:07 +00:00
|
|
|
CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
2018-11-19 16:00:32 +00:00
|
|
|
'the up-pointing arrow in the reference line is linked'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2019-03-20 15:31:00 +00:00
|
|
|
CitePage.getFragmentFromLink( CitePage.getCiteMultiBacklink( 1 ) ),
|
2018-11-19 16:00:32 +00:00
|
|
|
CitePage.getReference( 2 ).getAttribute( 'id' ),
|
|
|
|
'the up-pointing arrow in the reference line is linked to the clicked reference'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'use the last clicked target for the clickable up arrow on multiple used references', function () {
|
|
|
|
CitePage.getReference( 2 ).click();
|
|
|
|
CitePage.getReference( 1 ).click();
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2019-03-20 15:31:00 +00:00
|
|
|
CitePage.getFragmentFromLink( CitePage.getCiteMultiBacklink( 1 ) ),
|
2018-11-19 16:00:32 +00:00
|
|
|
CitePage.getReference( 1 ).getAttribute( 'id' ),
|
|
|
|
'the up-pointing arrow in the reference line is linked to the last clicked reference'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'clickable up arrow is hidden when jumping back from multiple used references', function () {
|
|
|
|
CitePage.getReference( 2 ).click();
|
2019-03-20 15:31:00 +00:00
|
|
|
CitePage.getCiteMultiBacklink( 1 ).click();
|
2018-11-19 16:00:32 +00:00
|
|
|
|
|
|
|
assert(
|
2020-06-14 19:41:07 +00:00
|
|
|
!CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
2018-11-19 16:00:32 +00:00
|
|
|
'the up-pointing arrow in the reference line is not linked'
|
|
|
|
);
|
|
|
|
} );
|
2019-03-20 15:31:00 +00:00
|
|
|
|
|
|
|
it( 'are not accidentally removed from unnamed references', function () {
|
|
|
|
CitePage.getReference( 3 ).click();
|
2020-06-14 19:41:07 +00:00
|
|
|
CitePage.getCiteSingleBacklink( 2 ).waitForDisplayed();
|
2019-03-20 15:31:00 +00:00
|
|
|
CitePage.getCiteSingleBacklink( 2 ).click();
|
|
|
|
// It doesn't matter what is focussed next, just needs to be something else
|
|
|
|
CitePage.getReference( 1 ).click();
|
|
|
|
|
|
|
|
assert(
|
2020-06-14 19:41:07 +00:00
|
|
|
CitePage.getCiteSingleBacklink( 2 ).isDisplayed(),
|
2019-03-20 15:31:00 +00:00
|
|
|
'the backlink on the unnamed reference is still visible'
|
|
|
|
);
|
|
|
|
} );
|
2018-11-19 16:00:32 +00:00
|
|
|
} );
|