Add browser test for preview functionality to MediaWiki core
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Thu, 29 Nov 2018 18:04:31 +0000 (19:04 +0100)
committerWMDE-Fisch <christoph.jauera@wikimedia.de>
Fri, 7 Dec 2018 15:27:45 +0000 (16:27 +0100)
The basic functionality of being able to preview an edit is currently
not covered by a test, as far as I can see.

The assertion for a wpTextbox2 that should *not* be there is a result of
the issue documented at T209012, where the EditPage::isConflict flag was
accidentially set. This assertion makes sure accidential conflicts can't
happen again, no matter which extension might cause it.

Bug: T210758
Change-Id: Iae723430b3a88079ad3499429e65c29817eca67e

tests/selenium/pageobjects/edit.page.js
tests/selenium/specs/page.js

index 8bc7dc6..f04f217 100644 (file)
@@ -3,14 +3,22 @@ const Page = require( 'wdio-mediawiki/Page' ),
 
 class EditPage extends Page {
        get content() { return browser.element( '#wpTextbox1' ); }
-       get displayedContent() { return browser.element( '#mw-content-text' ); }
+       get conflictingContent() { return browser.element( '#wpTextbox2' ); }
+       get displayedContent() { return browser.element( '#mw-content-text .mw-parser-output' ); }
        get heading() { return browser.element( '#firstHeading' ); }
        get save() { return browser.element( '#wpSave' ); }
+       get previewButton() { return browser.element( '#wpPreview' ); }
 
        openForEditing( title ) {
                super.openTitle( title, { action: 'edit' } );
        }
 
+       preview( name, content ) {
+               this.openForEditing( name );
+               this.content.setValue( content );
+               this.previewButton.click();
+       }
+
        edit( name, content ) {
                this.openForEditing( name );
                this.content.setValue( content );
index 124279c..3b24298 100644 (file)
@@ -24,6 +24,20 @@ describe( 'Page', function () {
                name = Util.getTestString( 'BeforeEach-name-' );
        } );
 
+       it( 'should be previewable', function () {
+               EditPage.preview( name, content );
+
+               assert.strictEqual( EditPage.heading.getText(), 'Creating ' + name );
+               assert.strictEqual( EditPage.displayedContent.getText(), content );
+               assert( EditPage.content.isVisible(), 'editor is still present' );
+               assert( !EditPage.conflictingContent.isVisible(), 'no edit conflict happened' );
+               // provoke and dismiss reload warning due to unsaved content
+               browser.url( 'data:text/html,Done' );
+               try {
+                       browser.alertAccept();
+               } catch ( e ) {}
+       } );
+
        it( 'should be creatable', function () {
                // create
                EditPage.edit( name, content );