mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
Merge "selenium: Refactor WebdriverIO tests from sync to async mode"
This commit is contained in:
commit
39a3ee0ce8
4363
package-lock.json
generated
4363
package-lock.json
generated
File diff suppressed because it is too large
Load diff
13
package.json
13
package.json
|
@ -7,18 +7,17 @@
|
|||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@wdio/cli": "7.4.6",
|
||||
"@wdio/dot-reporter": "7.4.2",
|
||||
"@wdio/junit-reporter": "7.4.2",
|
||||
"@wdio/local-runner": "7.4.6",
|
||||
"@wdio/mocha-framework": "7.13.2",
|
||||
"@wdio/sync": "7.4.6",
|
||||
"@wdio/cli": "7.30.1",
|
||||
"@wdio/spec-reporter": "7.29.1",
|
||||
"@wdio/junit-reporter": "7.29.1",
|
||||
"@wdio/local-runner": "7.30.1",
|
||||
"@wdio/mocha-framework": "7.26.0",
|
||||
"eslint-config-wikimedia": "0.24.0",
|
||||
"grunt": "1.6.1",
|
||||
"grunt-banana-checker": "0.10.0",
|
||||
"grunt-eslint": "24.0.0",
|
||||
"grunt-stylelint": "0.18.0",
|
||||
"stylelint-config-wikimedia": "0.14.0",
|
||||
"wdio-mediawiki": "1.2.0"
|
||||
"wdio-mediawiki": "2.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ class CitePage extends Page {
|
|||
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' ); }
|
||||
|
||||
scriptsReady() {
|
||||
Util.waitForModuleState( 'ext.cite.ux-enhancements' );
|
||||
async scriptsReady() {
|
||||
await Util.waitForModuleState( 'ext.cite.ux-enhancements' );
|
||||
}
|
||||
|
||||
getFragmentFromLink( linkElement ) {
|
||||
async getFragmentFromLink( linkElement ) {
|
||||
// the href includes the full url so slice the fragment from it
|
||||
const href = linkElement.getAttribute( 'href' );
|
||||
const href = await linkElement.getAttribute( 'href' );
|
||||
return href.slice( href.indexOf( '#' ) + 1 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,86 +8,84 @@ const assert = require( 'assert' ),
|
|||
describe( 'Cite backlinks', function () {
|
||||
let title;
|
||||
|
||||
before( function () {
|
||||
before( async function () {
|
||||
title = Util.getTestString( 'CiteTest-title-' );
|
||||
|
||||
browser.call( async () => {
|
||||
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' +
|
||||
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( function () {
|
||||
CitePage.openTitle( title );
|
||||
CitePage.scriptsReady();
|
||||
beforeEach( async function () {
|
||||
await CitePage.openTitle( title );
|
||||
await CitePage.scriptsReady();
|
||||
} );
|
||||
|
||||
it( 'are highlighted in the reference list when there are multiple used references', function () {
|
||||
CitePage.getReference( 2 ).click();
|
||||
it( 'are highlighted in the reference list when there are multiple used references', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
assert(
|
||||
CitePage.getCiteSubBacklink( 2 ).getAttribute( 'class' )
|
||||
( 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', function () {
|
||||
it( 'clickable up arrow is hidden by default when there are multiple backlinks', async function () {
|
||||
assert(
|
||||
!CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
||||
!( 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', function () {
|
||||
CitePage.getReference( 2 ).click();
|
||||
it( 'clickable up arrow shows when jumping to multiple used references', async function () {
|
||||
await CitePage.getReference( 2 ).click();
|
||||
assert(
|
||||
CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
||||
await CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
||||
'the up-pointing arrow in the reference line is linked'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
CitePage.getFragmentFromLink( CitePage.getCiteMultiBacklink( 1 ) ),
|
||||
CitePage.getReference( 2 ).getAttribute( 'id' ),
|
||||
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', function () {
|
||||
CitePage.getReference( 2 ).click();
|
||||
CitePage.getReference( 1 ).click();
|
||||
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(
|
||||
CitePage.getFragmentFromLink( CitePage.getCiteMultiBacklink( 1 ) ),
|
||||
CitePage.getReference( 1 ).getAttribute( 'id' ),
|
||||
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', function () {
|
||||
CitePage.getReference( 2 ).click();
|
||||
CitePage.getCiteMultiBacklink( 1 ).click();
|
||||
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(
|
||||
!CitePage.getCiteMultiBacklink( 1 ).isDisplayed(),
|
||||
!( await CitePage.getCiteMultiBacklink( 1 ).isDisplayed() ),
|
||||
'the up-pointing arrow in the reference line is not linked'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'are not accidentally removed from unnamed references', function () {
|
||||
CitePage.getReference( 3 ).click();
|
||||
CitePage.getCiteSingleBacklink( 2 ).waitForDisplayed();
|
||||
CitePage.getCiteSingleBacklink( 2 ).click();
|
||||
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
|
||||
CitePage.getReference( 1 ).click();
|
||||
await CitePage.getReference( 1 ).click();
|
||||
|
||||
assert(
|
||||
CitePage.getCiteSingleBacklink( 2 ).isDisplayed(),
|
||||
await CitePage.getCiteSingleBacklink( 2 ).isDisplayed(),
|
||||
'the backlink on the unnamed reference is still visible'
|
||||
);
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue