mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
Browser tests for CodeMirror (wikitext 2017 editor)
Bug: T270240 Change-Id: If1a2530e428122713277fbe87cd015cb729ab550 Depends-On: I2ba889e1a5dd03549d8d7cb00678a30882ff03fe
This commit is contained in:
parent
217c17257a
commit
27f964e240
|
@ -8,9 +8,12 @@ class EditPage extends Page {
|
|||
super.openTitle( title, { action: 'edit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
|
||||
}
|
||||
|
||||
get wikiEditorToolbar() { return $( '#wikiEditor-ui-toolbar' ); }
|
||||
get legacyTextInput() { return $( '#wpTextbox1' ); }
|
||||
clickText() {
|
||||
if ( this.legacyTextInput.isDisplayed() ) {
|
||||
if ( this.visualEditorSave.isDisplayed() ) {
|
||||
this.visualEditorSurface.click();
|
||||
} else if ( this.legacyTextInput.isDisplayed() ) {
|
||||
this.legacyTextInput.click();
|
||||
} else {
|
||||
// Click the container, if using WikiEditor etc.
|
||||
|
@ -18,6 +21,10 @@ class EditPage extends Page {
|
|||
}
|
||||
}
|
||||
|
||||
get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); }
|
||||
get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); }
|
||||
get visualEditorSurface() { return $( '.ve-ui-surface-source' ); }
|
||||
|
||||
cursorToPosition( index ) {
|
||||
this.clickText();
|
||||
|
||||
|
|
23
tests/selenium/specs/highlighting-disabled.js
Normal file
23
tests/selenium/specs/highlighting-disabled.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require( 'assert' ),
|
||||
EditPage = require( '../pageobjects/edit.page' ),
|
||||
FixtureContent = require( '../fixturecontent' ),
|
||||
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
||||
UserPreferences = require( '../userpreferences' );
|
||||
|
||||
describe( 'CodeMirror bracket match default', function () {
|
||||
before( function () {
|
||||
LoginPage.loginAdmin();
|
||||
UserPreferences.enableWikitext2010EditorWithCodeMirror();
|
||||
this.title = FixtureContent.createFixturePage();
|
||||
} );
|
||||
|
||||
it( 'disables highlighting', function () {
|
||||
EditPage.openForEditing( this.title );
|
||||
EditPage.clickText();
|
||||
|
||||
EditPage.cursorToPosition( 0 );
|
||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '' );
|
||||
} );
|
||||
} );
|
|
@ -7,27 +7,6 @@ const assert = require( 'assert' ),
|
|||
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
||||
UserPreferences = require( '../userpreferences' );
|
||||
|
||||
describe( 'CodeMirror bracket match default', function () {
|
||||
before( function () {
|
||||
LoginPage.loginAdmin();
|
||||
this.title = FixtureContent.createFixturePage();
|
||||
UserPreferences.enableWikitext2010EditorWithCodeMirror();
|
||||
// FIXME: Unknown conflict between this test and the FeatureFlag.enable cases.
|
||||
} );
|
||||
|
||||
it( 'is disabled by default', function () {
|
||||
EditPage.openForEditing( this.title );
|
||||
EditPage.clickText();
|
||||
|
||||
EditPage.cursorToPosition( 0 );
|
||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '' );
|
||||
} );
|
||||
|
||||
after( function () {
|
||||
browser.reloadSession();
|
||||
} );
|
||||
} );
|
||||
|
||||
describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor', function () {
|
||||
before( function () {
|
||||
LoginPage.loginAdmin();
|
||||
|
@ -38,15 +17,16 @@ describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor',
|
|||
|
||||
beforeEach( function () {
|
||||
EditPage.openForEditing( this.title );
|
||||
EditPage.wikiEditorToolbar.waitForDisplayed();
|
||||
EditPage.clickText();
|
||||
} );
|
||||
|
||||
it( 'highlighted on initial load', function () {
|
||||
it( 'highlights matching bracket', function () {
|
||||
EditPage.cursorToPosition( 0 );
|
||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
|
||||
} );
|
||||
|
||||
it( 'bracket match highlighting moves along with the cursor', function () {
|
||||
it( 'matches according to cursor movement', function () {
|
||||
EditPage.cursorToPosition( 3 );
|
||||
// FIXME: wait for hook to fire
|
||||
browser.pause( 100 );
|
||||
|
|
36
tests/selenium/specs/highlighting-wikitext2017.js
Normal file
36
tests/selenium/specs/highlighting-wikitext2017.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require( 'assert' ),
|
||||
EditPage = require( '../pageobjects/edit.page' ),
|
||||
FeatureFlag = require( '../highlightingfeatureflag' ),
|
||||
FixtureContent = require( '../fixturecontent' ),
|
||||
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
||||
UserPreferences = require( '../userpreferences' );
|
||||
|
||||
describe( 'CodeMirror bracket match highlighting for the wikitext 2017 editor', function () {
|
||||
before( function () {
|
||||
LoginPage.loginAdmin();
|
||||
this.title = FixtureContent.createFixturePage();
|
||||
UserPreferences.enableWikitext2017EditorWithCodeMirror();
|
||||
FeatureFlag.enable();
|
||||
} );
|
||||
|
||||
beforeEach( function () {
|
||||
EditPage.openForEditing( this.title );
|
||||
EditPage.visualEditorSave.waitForDisplayed();
|
||||
assert( !EditPage.wikiEditorToolbar.isDisplayed() );
|
||||
EditPage.clickText();
|
||||
} );
|
||||
|
||||
it( 'highlights matching bracket', function () {
|
||||
EditPage.cursorToPosition( 0 );
|
||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
|
||||
} );
|
||||
|
||||
it( 'matches according to cursor movement', function () {
|
||||
EditPage.cursorToPosition( 3 );
|
||||
// FIXME: wait for hook to fire
|
||||
browser.pause( 100 );
|
||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '{}' );
|
||||
} );
|
||||
} );
|
|
@ -26,6 +26,7 @@ class UserPreferences {
|
|||
|
||||
enableWikitext2017EditorWithCodeMirror() {
|
||||
this.setPreferences( {
|
||||
usebetatoolbar: null,
|
||||
usecodemirror: '1',
|
||||
'visualeditor-enable': '1',
|
||||
'visualeditor-newwikitext': '1'
|
||||
|
|
Loading…
Reference in a new issue