2020-05-14 21:14:42 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2019-09-29 01:59:56 +00:00
|
|
|
const Page = require( 'wdio-mediawiki/Page' );
|
2016-12-19 16:39:29 +00:00
|
|
|
|
|
|
|
|
class EditPage extends Page {
|
2019-09-27 03:08:00 +00:00
|
|
|
get content() { return $( '#wpTextbox1' ); }
|
|
|
|
|
get conflictingContent() { return $( '#wpTextbox2' ); }
|
|
|
|
|
get displayedContent() { return $( '#mw-content-text .mw-parser-output' ); }
|
2021-03-09 14:26:56 +00:00
|
|
|
get heading() { return $( '#firstHeading' ); }
|
2019-09-27 03:08:00 +00:00
|
|
|
get save() { return $( '#wpSave' ); }
|
|
|
|
|
get previewButton() { return $( '#wpPreview' ); }
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2023-01-04 22:49:42 +00:00
|
|
|
async openForEditing( title ) {
|
2023-01-11 19:19:13 +00:00
|
|
|
await super.openTitle( title, { action: 'submit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
|
2023-01-04 22:49:42 +00:00
|
|
|
// Compatibility with CodeMirror extension (T324879)
|
|
|
|
|
const cmButton = $( '.mw-editbutton-codemirror-active' );
|
|
|
|
|
if ( await cmButton.isExisting() ) {
|
|
|
|
|
await cmButton.click();
|
|
|
|
|
}
|
2016-12-19 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-23 17:50:28 +00:00
|
|
|
async preview( name, content ) {
|
|
|
|
|
await this.openForEditing( name );
|
|
|
|
|
await this.content.setValue( content );
|
|
|
|
|
await this.previewButton.click();
|
2018-11-29 18:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-23 17:50:28 +00:00
|
|
|
async edit( name, content ) {
|
|
|
|
|
await this.openForEditing( name );
|
|
|
|
|
await this.content.setValue( content );
|
|
|
|
|
await this.save.click();
|
2016-12-19 16:39:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
selenium: Minor clean-up in preparation for packaging
This is functionally a no-op, purely refactoring (mostly style).
* Consistently require packages at the top of a file.
(e.g. MWBot in edit.page.js).
* Remove unused .call(this) from mwbot interaction closures,
which didn't use 'this'.
* Use Node.js regular Promise chaining with then(), instead of
complex bluebird.coroutine generator function yields, which
are intended to emulate async-await, but the syntax is quite
error-prone for inexperienced developers and hard to debug.
Once we require Node 7+ for the selenium tests, we can use
async-await here natively, but until then, might as well use
regular then() syntax, which we already use elsewhere in the
tests, and is also what MWBot documentation uses.
* Also applied some minor whitespace changes for consistency
among these files and other MediaWiki JS. E.g. no empty line
before the first statement of a function. Add a new line between
different methods, and between the end of a class and the
export statement.
* Remove 'use strict' from test files. The patterns that would expose
the bad non-strict behaviour are mostly already forbidden by ESLint,
and the run-time optimisation to disable non-strict can't be noticed
in tests (more useful in prod where e.g. the same process would run
a function 1 million times). Main reason here is to keep things
simple for new-comers and reduce boilerplate, given that these tests
will mainly be worked on by browser-JS developers, not Node.js devs,
and we don't currently use strict mode in our front-end code, either.
* Remove unused bluebird dependency.
Bug: T193088
Change-Id: I59f9211299e8e884c28c7733bcee3b7b28542610
2018-05-02 03:48:36 +00:00
|
|
|
|
2016-12-19 16:39:29 +00:00
|
|
|
module.exports = new EditPage();
|