2020-06-02 21:21:44 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-04-05 21:09:47 +00:00
|
|
|
const assert = require( 'assert' );
|
|
|
|
const { ArticlePageWithEditorOverlay, ArticlePage } = require( '../support/world.js' );
|
|
|
|
|
2023-04-06 22:25:40 +00:00
|
|
|
const iClickTheEditButton = async () => {
|
|
|
|
await ArticlePage.edit_link_element.waitForDisplayed();
|
|
|
|
await ArticlePage.edit_link_element.click();
|
2019-04-05 21:09:47 +00:00
|
|
|
};
|
2023-04-06 22:25:40 +00:00
|
|
|
const iSeeTheWikitextEditorOverlay = async () => {
|
|
|
|
await ArticlePageWithEditorOverlay.editor_overlay_element.waitForDisplayed();
|
|
|
|
await ArticlePageWithEditorOverlay.editor_textarea_element.waitForExist();
|
2019-04-05 21:09:47 +00:00
|
|
|
};
|
|
|
|
const iClearTheEditor = () => {
|
|
|
|
ArticlePageWithEditorOverlay.editor_textarea_element.setValue( '' );
|
|
|
|
};
|
|
|
|
const iDoNotSeeTheWikitextEditorOverlay = () => {
|
2024-07-27 05:52:33 +00:00
|
|
|
browser.waitUntil( () => ArticlePageWithEditorOverlay.editor_overlay_element.isDisplayed() === false, 10000 );
|
2019-04-05 21:09:47 +00:00
|
|
|
};
|
|
|
|
const iTypeIntoTheEditor = ( text ) => {
|
|
|
|
ArticlePageWithEditorOverlay.editor_overlay_element.waitForExist();
|
|
|
|
ArticlePageWithEditorOverlay.editor_textarea_element.waitForExist();
|
2020-06-15 14:54:05 +00:00
|
|
|
ArticlePageWithEditorOverlay.editor_textarea_element.waitForDisplayed();
|
2023-10-31 21:41:46 +00:00
|
|
|
// Make sure the slow connection load basic button is gone (T348539)
|
2024-07-27 05:52:33 +00:00
|
|
|
browser.waitUntil( () => ArticlePageWithEditorOverlay.editor_load_basic_element.isDisplayed() === false );
|
2019-04-05 21:09:47 +00:00
|
|
|
ArticlePageWithEditorOverlay.editor_textarea_element.addValue( text );
|
2024-07-27 05:52:33 +00:00
|
|
|
browser.waitUntil( () => !ArticlePageWithEditorOverlay
|
|
|
|
.continue_element.getAttribute( 'disabled' ) );
|
2019-04-05 21:09:47 +00:00
|
|
|
};
|
|
|
|
const iClickContinue = () => {
|
|
|
|
ArticlePageWithEditorOverlay.continue_element.waitForExist();
|
|
|
|
ArticlePageWithEditorOverlay.continue_element.click();
|
|
|
|
};
|
|
|
|
const iClickSubmit = () => {
|
|
|
|
ArticlePageWithEditorOverlay.submit_element.waitForExist();
|
|
|
|
ArticlePageWithEditorOverlay.submit_element.click();
|
|
|
|
};
|
|
|
|
const iSayOkayInTheConfirmDialog = () => {
|
|
|
|
browser.waitUntil( () => {
|
|
|
|
try {
|
2020-06-15 14:54:05 +00:00
|
|
|
const text = browser.getAlertText();
|
2019-04-05 21:09:47 +00:00
|
|
|
return text && true;
|
|
|
|
} catch ( e ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}, 2000 );
|
2020-06-15 14:54:05 +00:00
|
|
|
browser.acceptAlert();
|
2019-04-05 21:09:47 +00:00
|
|
|
};
|
2023-04-06 22:25:40 +00:00
|
|
|
const theTextOfTheFirstHeadingShouldBe = async ( title ) => {
|
|
|
|
await ArticlePage.first_heading_element.waitForDisplayed();
|
2024-03-24 19:02:27 +00:00
|
|
|
title = mw.util.escapeRegExp( title );
|
2023-04-06 22:25:40 +00:00
|
|
|
assert.match(
|
|
|
|
await ArticlePage.first_heading_element.getText(),
|
2024-03-24 19:02:27 +00:00
|
|
|
// eslint-disable-next-line security/detect-non-literal-regexp
|
2024-01-24 22:02:12 +00:00
|
|
|
new RegExp( `.*${ title }$` )
|
2019-04-05 21:09:47 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
const thereShouldBeARedLinkWithText = ( text ) => {
|
|
|
|
ArticlePage.red_link_element.waitForExist();
|
|
|
|
assert.strictEqual(
|
|
|
|
ArticlePage.red_link_element.getText(),
|
|
|
|
text
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
iClickTheEditButton, iSeeTheWikitextEditorOverlay, iClearTheEditor,
|
|
|
|
thereShouldBeARedLinkWithText,
|
|
|
|
iDoNotSeeTheWikitextEditorOverlay,
|
|
|
|
iTypeIntoTheEditor, iClickContinue, iClickSubmit, iSayOkayInTheConfirmDialog,
|
|
|
|
theTextOfTheFirstHeadingShouldBe
|
|
|
|
};
|