Debian Codegraph @

tests/selenium/pageobjects/edit.page.js

raw symbols SCIP
1 'use strict';
2
3 const Page = require( 'wdio-mediawiki/Page' ),
4 Util = require( 'wdio-mediawiki/Util' );
5
6 class EditPage extends Page {
7 get content() {
8 return $( '#wpTextbox1' );
9 }
10
11 get conflictingContent() {
12 return $( '#wpTextbox2' );
13 }
14
15 get displayedContent() {
16 return $( '#mw-content-text .mw-parser-output' );
17 }
18
19 get heading() {
20 return $( '#firstHeading' );
21 }
22
23 get save() {
24 return $( '#wpSave' );
25 }
26
27 get previewButton() {
28 return $( '#wpPreview' );
29 }
30
31 get tempUserSignUpButton() {
32 return $( '.mw-temp-user-banner-buttons > #pt-createaccount' );
33 }
34
35 async openForEditing( title ) {
36 await super.openTitle( title, { action: 'submit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
37 // Compatibility with CodeMirror extension (T324879)
38 await Util.waitForModuleState( 'mediawiki.base' );
39 const hasToolbar = await this.save.isExisting() && await browser.execute( () => mw.loader.getState( 'ext.wikiEditor' ) !== null );
40 if ( !hasToolbar ) {
41 return;
42 }
43 await $( '#wikiEditor-ui-toolbar' ).waitForDisplayed();
44 const cmButton = $( '.mw-editbutton-codemirror-active' );
45 if ( await cmButton.isExisting() ) {
46 await cmButton.click();
47 await browser.waitUntil( async () => !( await cmButton.getAttribute( 'class' ) ).includes( 'mw-editbutton-codemirror-active' ) );
48 }
49 }
50
51 async preview( name, content ) {
52 await this.openForEditing( name );
53 await this.content.setValue( content );
54 await this.previewButton.click();
55 }
56
57 async edit( name, content ) {
58 await this.openForEditing( name );
59 await this.content.setValue( content );
60 await this.save.click();
61 }
62
63 /**
64 * Navigate to Special:CreateAccount via the banner links if logged in as a temporary user.
65 *
66 * @return {Promise<void>}
67 */
68 async openCreateAccountPageAsTempUser() {
69 await this.tempUserSignUpButton.waitForDisplayed();
70 await this.tempUserSignUpButton.click();
71 }
72 }
73
74 module.exports = new EditPage();