From 3b03ea9bdc8bc1b44258ae2a0a07bb4a9565c29a Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Thu, 29 Nov 2018 19:04:31 +0100 Subject: [PATCH] Add browser test for preview functionality to MediaWiki core 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 | 10 +++++++++- tests/selenium/specs/page.js | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/selenium/pageobjects/edit.page.js b/tests/selenium/pageobjects/edit.page.js index 8bc7dc635a..f04f217c72 100644 --- a/tests/selenium/pageobjects/edit.page.js +++ b/tests/selenium/pageobjects/edit.page.js @@ -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 ); diff --git a/tests/selenium/specs/page.js b/tests/selenium/specs/page.js index 124279c4b0..3b2429808f 100644 --- a/tests/selenium/specs/page.js +++ b/tests/selenium/specs/page.js @@ -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 ); -- 2.20.1