mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "[Cypress] Wait for VE modules to load"
This commit is contained in:
commit
56d7dd2496
|
@ -8,7 +8,7 @@ const wikiText = `This is reference #1: <ref name="a">${ refText1 }</ref><br> `
|
|||
`This is reference #3 <ref>${ refText2 }</ref><br>` +
|
||||
'<references />';
|
||||
|
||||
let citoidLoaded;
|
||||
let usesCitoid;
|
||||
|
||||
describe( 'Re-using refs in Visual Editor', () => {
|
||||
beforeEach( () => {
|
||||
|
@ -19,7 +19,7 @@ describe( 'Re-using refs in Visual Editor', () => {
|
|||
|
||||
helpers.editPage( title, wikiText );
|
||||
cy.window().then( async ( win ) => {
|
||||
citoidLoaded = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
usesCitoid = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
win.localStorage.setItem( 've-beta-welcome-dialog', 1 );
|
||||
win.localStorage.setItem( 've-hideusered', 1 );
|
||||
} );
|
||||
|
@ -34,9 +34,7 @@ describe( 'Re-using refs in Visual Editor', () => {
|
|||
|
||||
} );
|
||||
|
||||
helpers.visitTitle( title, { veaction: 'edit' } );
|
||||
|
||||
helpers.waitForVEToLoad();
|
||||
helpers.openVEForEditingReferences( title, usesCitoid );
|
||||
} );
|
||||
|
||||
it( 'should display re-used reference in article with correct footnote number and notification in context dialog', () => {
|
||||
|
@ -46,7 +44,7 @@ describe( 'Re-using refs in Visual Editor', () => {
|
|||
// Place cursor next to ref #2 in order to add re-use ref next to it
|
||||
cy.contains( '.mw-reflink-text', '[2]' ).type( '{rightarrow}' );
|
||||
|
||||
if ( citoidLoaded ) {
|
||||
if ( usesCitoid ) {
|
||||
helpers.openVECiteoidReuseDialog();
|
||||
} else {
|
||||
helpers.openVECiteReuseDialog();
|
||||
|
@ -87,7 +85,7 @@ describe( 'Re-using refs in Visual Editor', () => {
|
|||
// Place cursor next to ref #1 in order to add re-used ref next to it
|
||||
cy.contains( '.mw-reflink-text', '[1]' ).first().type( '{rightarrow}' );
|
||||
|
||||
if ( citoidLoaded ) {
|
||||
if ( usesCitoid ) {
|
||||
helpers.openVECiteoidReuseDialog();
|
||||
} else {
|
||||
helpers.openVECiteReuseDialog();
|
||||
|
|
|
@ -11,7 +11,7 @@ const refText1 = 'This is citation #1 for reference #1';
|
|||
const wikiText = `${ wikiText1 } <ref name="a">${ refText1 }</ref><br> ` +
|
||||
'<references />';
|
||||
|
||||
let citoidLoaded;
|
||||
let usesCitoid;
|
||||
|
||||
describe( 'Re-using refs in Visual Editor using templates', () => {
|
||||
|
||||
|
@ -65,20 +65,18 @@ describe( 'Re-using refs in Visual Editor using templates', () => {
|
|||
await win.mw.loader.using( 'mediawiki.base' ).then( async function () {
|
||||
await win.mw.hook( 'wikipage.content' ).add( function () { } );
|
||||
} );
|
||||
citoidLoaded = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
usesCitoid = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
win.localStorage.setItem( 've-beta-welcome-dialog', 1 );
|
||||
win.localStorage.setItem( 've-hideusered', 1 );
|
||||
} );
|
||||
|
||||
// Open VE edit mode
|
||||
helpers.visitTitle( title, { veaction: 'edit' } );
|
||||
helpers.waitForVEToLoad();
|
||||
helpers.openVEForEditingReferences( title, usesCitoid );
|
||||
} );
|
||||
|
||||
it( 'should add a template reference and verify correct content in both saved and edit mode', () => {
|
||||
cy.contains( '.mw-reflink-text', '[1]' ).type( '{rightarrow}' );
|
||||
|
||||
if ( citoidLoaded ) {
|
||||
if ( usesCitoid ) {
|
||||
cy.get( '.ve-ui-toolbar-group-citoid' ).click();
|
||||
|
||||
// Switch to Manual tab
|
||||
|
|
|
@ -9,7 +9,7 @@ const wikiText = `This is reference #1: <ref name="a">${ refText1 }</ref><br> `
|
|||
`This is reference #3 <ref>${ refText2 }</ref><br>` +
|
||||
'<references />';
|
||||
|
||||
let citoidLoaded;
|
||||
let usesCitoid;
|
||||
|
||||
describe( 'Visual Editor Cite Integration', () => {
|
||||
before( () => {
|
||||
|
@ -22,13 +22,12 @@ describe( 'Visual Editor Cite Integration', () => {
|
|||
helpers.waitForMWLoader();
|
||||
|
||||
cy.window().then( async ( win ) => {
|
||||
citoidLoaded = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
usesCitoid = win.mw.loader.getModuleNames().includes( 'ext.citoid.visualEditor' );
|
||||
win.localStorage.setItem( 've-beta-welcome-dialog', 1 );
|
||||
win.localStorage.setItem( 've-hideusered', 1 );
|
||||
} );
|
||||
|
||||
helpers.visitTitle( title, { veaction: 'edit' } );
|
||||
helpers.waitForVEToLoad();
|
||||
helpers.openVEForEditingReferences( title, usesCitoid );
|
||||
} );
|
||||
|
||||
it( 'should edit and verify reference content in Visual Editor', () => {
|
||||
|
@ -49,7 +48,7 @@ describe( 'Visual Editor Cite Integration', () => {
|
|||
} );
|
||||
|
||||
it( 'should display existing references in the Cite re-use dialog', () => {
|
||||
if ( citoidLoaded ) {
|
||||
if ( usesCitoid ) {
|
||||
helpers.openVECiteoidReuseDialog();
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
import querystring from 'querystring';
|
||||
|
||||
export function waitForVEToLoad() {
|
||||
export function openVEForEditingReferences( title, usesCitoid ) {
|
||||
visitTitle( title, { veaction: 'edit' } );
|
||||
waitForVECiteToLoad();
|
||||
if ( usesCitoid ) {
|
||||
waitForVECitoidToLoad();
|
||||
}
|
||||
}
|
||||
|
||||
export function waitForVECiteToLoad() {
|
||||
cy.get( '.ve-init-mw-desktopArticleTarget-toolbar-open', { timeout: 7000 } )
|
||||
.should( 'be.visible' );
|
||||
cy.window()
|
||||
.should( 'have.property', 'mw' )
|
||||
.and( 'have.property', 'loader' )
|
||||
.and( 'have.property', 'getState' );
|
||||
cy.window()
|
||||
.should(
|
||||
( win ) => win.mw.loader.getState( 'ext.cite.visualEditor' ) === 'ready'
|
||||
);
|
||||
}
|
||||
|
||||
export function waitForVECitoidToLoad() {
|
||||
cy.window()
|
||||
.should( 'have.property', 'mw' )
|
||||
.and( 'have.property', 'loader' )
|
||||
.and( 'have.property', 'getState' );
|
||||
cy.window()
|
||||
.should(
|
||||
( win ) => win.mw.loader.getState( 'ext.citoid.visualEditor' ) === 'ready'
|
||||
);
|
||||
}
|
||||
|
||||
function clickUntilVisible( clickElement, expectedSelector, timeout = 5000 ) {
|
||||
|
|
Loading…
Reference in a new issue