| 1 |
'use strict'; |
| 2 |
|
| 3 |
const assert = require( 'assert' ); |
| 4 |
const { ArticlePageWithEditorOverlay, ArticlePage } = require( '../support/world.js' ); |
| 5 |
|
| 6 |
const iClickTheEditButton = async () => { |
| 7 |
await ArticlePage.edit_link_element.waitForDisplayed(); |
| 8 |
await ArticlePage.edit_link_element.click(); |
| 9 |
}; |
| 10 |
const iSeeTheWikitextEditorOverlay = async () => { |
| 11 |
await ArticlePageWithEditorOverlay.editor_overlay_element.waitForDisplayed(); |
| 12 |
await ArticlePageWithEditorOverlay.editor_textarea_element.waitForExist(); |
| 13 |
}; |
| 14 |
const iClearTheEditor = () => { |
| 15 |
ArticlePageWithEditorOverlay.editor_textarea_element.setValue( '' ); |
| 16 |
}; |
| 17 |
const iDoNotSeeTheWikitextEditorOverlay = () => { |
| 18 |
browser.waitUntil( |
| 19 |
() => ArticlePageWithEditorOverlay.editor_overlay_element.isDisplayed() === false, 10000 |
| 20 |
); |
| 21 |
}; |
| 22 |
const iTypeIntoTheEditor = ( text ) => { |
| 23 |
ArticlePageWithEditorOverlay.editor_overlay_element.waitForExist(); |
| 24 |
ArticlePageWithEditorOverlay.editor_textarea_element.waitForExist(); |
| 25 |
ArticlePageWithEditorOverlay.editor_textarea_element.waitForDisplayed(); |
| 26 |
|
| 27 |
browser.waitUntil( |
| 28 |
() => ArticlePageWithEditorOverlay.editor_load_basic_element.isDisplayed() === false |
| 29 |
); |
| 30 |
ArticlePageWithEditorOverlay.editor_textarea_element.addValue( text ); |
| 31 |
browser.waitUntil( () => !ArticlePageWithEditorOverlay |
| 32 |
.continue_element.getAttribute( 'disabled' ) ); |
| 33 |
}; |
| 34 |
const iClickContinue = () => { |
| 35 |
ArticlePageWithEditorOverlay.continue_element.waitForExist(); |
| 36 |
ArticlePageWithEditorOverlay.continue_element.click(); |
| 37 |
}; |
| 38 |
const iClickSubmit = () => { |
| 39 |
ArticlePageWithEditorOverlay.submit_element.waitForExist(); |
| 40 |
ArticlePageWithEditorOverlay.submit_element.click(); |
| 41 |
}; |
| 42 |
const iSayOkayInTheConfirmDialog = () => { |
| 43 |
browser.waitUntil( () => { |
| 44 |
try { |
| 45 |
const text = browser.getAlertText(); |
| 46 |
return text && true; |
| 47 |
} catch ( e ) { |
| 48 |
return false; |
| 49 |
} |
| 50 |
}, 2000 ); |
| 51 |
browser.acceptAlert(); |
| 52 |
}; |
| 53 |
const theTextOfTheFirstHeadingShouldBe = async ( title ) => { |
| 54 |
await ArticlePage.first_heading_element.waitForDisplayed(); |
| 55 |
title = mw.util.escapeRegExp( title ); |
| 56 |
assert.match( |
| 57 |
await ArticlePage.first_heading_element.getText(), |
| 58 |
|
| 59 |
new RegExp( `.*${ title }$` ) |
| 60 |
); |
| 61 |
}; |
| 62 |
const thereShouldBeARedLinkWithText = ( text ) => { |
| 63 |
ArticlePage.red_link_element.waitForExist(); |
| 64 |
assert.strictEqual( |
| 65 |
ArticlePage.red_link_element.getText(), |
| 66 |
text |
| 67 |
); |
| 68 |
}; |
| 69 |
|
| 70 |
module.exports = { |
| 71 |
iClickTheEditButton, iSeeTheWikitextEditorOverlay, iClearTheEditor, |
| 72 |
thereShouldBeARedLinkWithText, |
| 73 |
iDoNotSeeTheWikitextEditorOverlay, |
| 74 |
iTypeIntoTheEditor, iClickContinue, iClickSubmit, iSayOkayInTheConfirmDialog, |
| 75 |
theTextOfTheFirstHeadingShouldBe |
| 76 |
}; |