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 = () => {
|
|
|
|
browser.waitUntil( () => {
|
2020-06-15 14:54:05 +00:00
|
|
|
return ArticlePageWithEditorOverlay.editor_overlay_element.isDisplayed() === false;
|
2019-04-05 21:09:47 +00:00
|
|
|
}, 10000 );
|
|
|
|
};
|
|
|
|
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();
|
2019-04-05 21:09:47 +00:00
|
|
|
ArticlePageWithEditorOverlay.editor_textarea_element.addValue( text );
|
|
|
|
browser.waitUntil( () => {
|
|
|
|
return !ArticlePageWithEditorOverlay
|
|
|
|
.continue_element.getAttribute( 'disabled' );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
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();
|
|
|
|
assert.match(
|
|
|
|
await ArticlePage.first_heading_element.getText(),
|
|
|
|
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
|
|
|
|
};
|