mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Merge "Cypress Improvements"
This commit is contained in:
commit
53bc13024b
|
@ -18,19 +18,22 @@ describe( 'Cite backlinks test', () => {
|
|||
|
||||
// Rely on the retry behavior of Cypress assertions to use this as a "wait" until the specified conditions are met.
|
||||
cy.window().should( 'have.property', 'mw' ).and( 'have.property', 'loader' ).and( 'have.property', 'using' );
|
||||
cy.window().then( async ( win ) => {
|
||||
|
||||
await win.mw.loader.using( 'mediawiki.api' ).then(
|
||||
async function () {
|
||||
await new win.mw.Api().create( title, {}, wikiText );
|
||||
}
|
||||
);
|
||||
cy.window().then( ( win ) => {
|
||||
win.mw.loader.using( 'mediawiki.api' ).then( () => {
|
||||
new win.mw.Api().create( title, {}, wikiText );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
beforeEach( () => {
|
||||
// cy.visit( `/wiki/${ encodedTitle }` );
|
||||
cy.visit( `/index.php?title=${ encodedTitle }` );
|
||||
|
||||
cy.window().should( 'have.property', 'mw' ).and( 'have.property', 'loader' ).and( 'have.property', 'using' );
|
||||
cy.window().then( async ( win ) => {
|
||||
await win.mw.loader.using( 'mediawiki.base' ).then( async function () {
|
||||
await win.mw.hook( 'wikipage.content' ).add( function () {} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'hides clickable up arrow by default when there are multiple backlinks', () => {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"wikimedia/selenium"
|
||||
],
|
||||
"globals": {
|
||||
"mw": "readonly"
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# Selenium tests
|
||||
|
||||
For more information see https://www.mediawiki.org/wiki/Selenium
|
||||
|
||||
## Setup
|
||||
|
||||
See https://www.mediawiki.org/wiki/MediaWiki-Docker/Extension/Cite
|
||||
|
||||
## Run all specs
|
||||
|
||||
npm run selenium-test
|
||||
|
||||
## Run specific tests
|
||||
|
||||
Filter by file name:
|
||||
|
||||
npm run selenium-test -- --spec tests/selenium/specs/[FILE-NAME]
|
||||
|
||||
Filter by file name and test name:
|
||||
|
||||
npm run selenium-test -- --spec tests/selenium/specs/[FILE-NAME] --mochaOpts.grep [TEST-NAME]
|
|
@ -1,34 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const Page = require( 'wdio-mediawiki/Page' ),
|
||||
Util = require( 'wdio-mediawiki/Util' );
|
||||
|
||||
class CitePage extends Page {
|
||||
getReference( num ) {
|
||||
return $$( '#mw-content-text .reference' )[ num - 1 ];
|
||||
}
|
||||
|
||||
getCiteMultiBacklink( num ) {
|
||||
return $( '.references li:nth-of-type(' + num + ') .mw-cite-up-arrow-backlink' );
|
||||
}
|
||||
|
||||
getCiteSingleBacklink( num ) {
|
||||
return $( '.references li:nth-of-type(' + num + ') .mw-cite-backlink a' );
|
||||
}
|
||||
|
||||
getCiteSubBacklink( num ) {
|
||||
return $( '.mw-cite-backlink sup:nth-of-type(' + num + ') a' );
|
||||
}
|
||||
|
||||
async scriptsReady() {
|
||||
await Util.waitForModuleState( 'ext.cite.ux-enhancements' );
|
||||
}
|
||||
|
||||
async getFragmentFromLink( linkElement ) {
|
||||
// the href includes the full url so slice the fragment from it
|
||||
const href = await linkElement.getAttribute( 'href' );
|
||||
return href.slice( href.indexOf( '#' ) + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new CitePage();
|
|
@ -1,92 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require( 'assert' ),
|
||||
Api = require( 'wdio-mediawiki/Api' ),
|
||||
CitePage = require( '../pageobjects/cite.page' ),
|
||||
Util = require( 'wdio-mediawiki/Util' );
|
||||
|
||||
describe( 'Cite backlinks', function () {
|
||||
let title;
|
||||
|
||||
before( async function () {
|
||||
title = Util.getTestString( 'CiteTest-title-' );
|
||||
|
||||
const bot = await Api.bot();
|
||||
await bot.edit(
|
||||
title,
|
||||
'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' +
|
||||
'<references />'
|
||||
);
|
||||
} );
|
||||
|
||||
beforeEach( async function () {
|
||||
await CitePage.openTitle( title );
|
||||
await CitePage.scriptsReady();
|
||||
} );
|
||||
|
||||
it( 'are highlighted in the reference list when there are multiple used references', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
assert(
|
||||
( await CitePage.getCiteSubBacklink( 2 ).getAttribute( 'class' ) )
|
||||
.includes( 'mw-cite-targeted-backlink' ),
|
||||
'the jump mark symbol of the backlink is highlighted'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'clickable up arrow is hidden by default when there are multiple backlinks', async function () {
|
||||
assert(
|
||||
!( await CitePage.getCiteMultiBacklink( 1 ).isDisplayed() ),
|
||||
'the up-pointing arrow in the reference line is not linked'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'clickable up arrow shows when jumping to multiple used references', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
assert(
|
||||
await CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
||||
'the up-pointing arrow in the reference line is linked'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
await CitePage.getFragmentFromLink( await CitePage.getCiteMultiBacklink( 1 ) ),
|
||||
await 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', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
await CitePage.getReference( 1 ).click();
|
||||
|
||||
assert.strictEqual(
|
||||
await CitePage.getFragmentFromLink( CitePage.getCiteMultiBacklink( 1 ) ),
|
||||
await 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', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
await CitePage.getCiteMultiBacklink( 1 ).click();
|
||||
|
||||
assert(
|
||||
!( await CitePage.getCiteMultiBacklink( 1 ).isDisplayed() ),
|
||||
'the up-pointing arrow in the reference line is not linked'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'are not accidentally removed from unnamed references', async function () {
|
||||
await CitePage.getReference( 3 ).click();
|
||||
await CitePage.getCiteSingleBacklink( 2 ).waitForDisplayed();
|
||||
await CitePage.getCiteSingleBacklink( 2 ).click();
|
||||
// It doesn't matter what is focussed next, just needs to be something else
|
||||
await CitePage.getReference( 1 ).click();
|
||||
|
||||
assert(
|
||||
await CitePage.getCiteSingleBacklink( 2 ).isDisplayed(),
|
||||
'the backlink on the unnamed reference is still visible'
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,11 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const { config } = require( 'wdio-mediawiki/wdio-defaults.conf.js' );
|
||||
|
||||
exports.config = { ...config
|
||||
// Override, or add to, the setting from wdio-mediawiki.
|
||||
// Learn more at https://webdriver.io/docs/configurationfile/
|
||||
//
|
||||
// Example:
|
||||
// logLevel: 'info',
|
||||
};
|
Loading…
Reference in a new issue