2024-05-31 11:42:15 +00:00
|
|
|
import * as helpers from './functions.helper.js';
|
|
|
|
|
2024-06-04 07:18:22 +00:00
|
|
|
export function setVECookiesToDisableDialogs() {
|
|
|
|
cy.window().then( async ( win ) => {
|
|
|
|
win.localStorage.setItem( 've-beta-welcome-dialog', 1 );
|
2024-06-21 15:18:36 +00:00
|
|
|
// Don't show the VE education popups with the blue
|
|
|
|
// pulsating dots (ve.ui.MWEducationPopupWidget)
|
2024-06-04 07:18:22 +00:00
|
|
|
win.localStorage.setItem( 've-hideusered', 1 );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2024-05-31 11:42:15 +00:00
|
|
|
export function openVEForEditingReferences( title, usesCitoid ) {
|
|
|
|
helpers.visitTitle( title, { veaction: 'edit' } );
|
|
|
|
waitForVECiteToLoad();
|
|
|
|
if ( usesCitoid ) {
|
|
|
|
waitForVECitoidToLoad();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-17 11:26:16 +00:00
|
|
|
export function openVEForSourceEditingReferences( title, usesCitoid ) {
|
|
|
|
helpers.visitTitle( title, { veaction: 'editsource' } );
|
|
|
|
waitForVECiteToLoad();
|
|
|
|
if ( usesCitoid ) {
|
|
|
|
waitForVECitoidToLoad();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-31 11:42:15 +00:00
|
|
|
export function waitForVECiteToLoad() {
|
2024-09-17 11:26:16 +00:00
|
|
|
cy.get( '.ve-init-mw-desktopArticleTarget-toolbar-open', { timeout: 20000 } )
|
2024-05-31 11:42:15 +00:00
|
|
|
.should( 'be.visible' );
|
2024-06-04 07:18:22 +00:00
|
|
|
helpers.waitForModuleReady( 'ext.cite.visualEditor' );
|
2024-05-31 11:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function waitForVECitoidToLoad() {
|
2024-06-04 07:18:22 +00:00
|
|
|
helpers.waitForModuleReady( 'ext.citoid.visualEditor' );
|
2024-05-31 11:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getVEFootnoteMarker( refName, sequenceNumber, index ) {
|
|
|
|
return cy.get( `sup.ve-ce-mwReferenceNode#cite_ref-${ refName }_${ sequenceNumber }-${ index - 1 }` );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getVEReferenceContextItem() {
|
|
|
|
return cy.get( '.ve-ui-context-menu .ve-ui-mwReferenceContextItem' );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getVEReferenceContextItemEdit() {
|
|
|
|
return cy.get( '.ve-ui-context-menu .ve-ui-mwReferenceContextItem .oo-ui-buttonElement-button' );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getVEReferenceEditDialog() {
|
|
|
|
return cy.get( '.ve-ui-mwReferenceDialog' );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function openVECiteReuseDialog() {
|
|
|
|
helpers.clickUntilVisible(
|
|
|
|
cy.get( '.ve-ui-toolbar-group-cite' ),
|
|
|
|
'.ve-ui-toolbar .oo-ui-tool-name-reference-existing'
|
|
|
|
);
|
|
|
|
cy.get( '.ve-ui-toolbar .oo-ui-tool-name-reference-existing' ).click();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function openVECiteoidReuseDialog() {
|
|
|
|
cy.get( '.ve-ui-toolbar-group-citoid' ).click();
|
|
|
|
// TODO: Sometimes enabling the tab does not work right away.
|
|
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
|
|
cy.wait( 500 );
|
2024-07-16 13:01:12 +00:00
|
|
|
cy.get( '.oo-ui-tabSelectWidget .oo-ui-labelElement-label' ).contains( 'Re-use' ).click();
|
2024-05-31 11:42:15 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 08:49:08 +00:00
|
|
|
export function saveEdits() {
|
|
|
|
// TODO: Even if the button is enabled it seems we need a delay before we can click it.
|
|
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
|
|
cy.wait( 500 );
|
|
|
|
cy.get( '.ve-ui-toolbar-saveButton' ).click();
|
|
|
|
cy.get( '.ve-ui-mwSaveDialog .oo-ui-processDialog-actions-primary .oo-ui-buttonWidget' ).click();
|
|
|
|
cy.get( '.mw-notification-visible .oo-ui-icon-success' ).should( 'be.visible' );
|
2024-05-31 11:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getCiteReuseDialogRefResult( rowNumber ) {
|
|
|
|
return cy.get( '.ve-ui-mwReferenceSearchWidget .ve-ui-mwReferenceResultWidget' )
|
|
|
|
.eq( rowNumber - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getCiteReuseDialogRefResultName( rowNumber ) {
|
|
|
|
return cy.get( '.ve-ui-mwReferenceSearchWidget .ve-ui-mwReferenceResultWidget .ve-ui-mwReferenceSearchWidget-name' )
|
|
|
|
.eq( rowNumber - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getCiteReuseDialogRefResultCitation( rowNumber ) {
|
2024-09-02 10:26:41 +00:00
|
|
|
return cy.get( '.ve-ui-mwReferenceSearchWidget .ve-ui-mwReferenceResultWidget .ve-ui-mwReferenceSearchWidget-footnote' )
|
2024-05-31 11:42:15 +00:00
|
|
|
.eq( rowNumber - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getCiteReuseDialogRefText( rowNumber ) {
|
|
|
|
return cy.get( '.oo-ui-widget.oo-ui-widget-enabled .ve-ui-mwReferenceResultWidget .ve-ce-paragraphNode' )
|
|
|
|
.eq( rowNumber - 1 );
|
|
|
|
}
|