mediawiki-extensions-CodeMi.../tests/selenium/specs/highlighting-wikitext2017.js
James D. Forrester 9e9a38d6fc Refactor CodeMirror WebdriverIO tests from sync to async mode
Bug: T300205
Change-Id: Idfcfc984833ca6ca6c09500cd4715a4e5504f84e
2023-06-06 10:49:22 +02:00

37 lines
1.2 KiB
JavaScript

'use strict';
const assert = require( 'assert' ),
EditPage = require( '../pageobjects/edit.page' ),
FixtureContent = require( '../fixturecontent' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
UserPreferences = require( '../userpreferences' ),
Util = require( 'wdio-mediawiki/Util' );
describe( 'CodeMirror bracket match highlighting for the wikitext 2017 editor', function () {
let title;
before( async function () {
title = Util.getTestString( 'CodeMirror-fixture1-' );
await LoginPage.loginAdmin();
await FixtureContent.createFixturePage( title );
await UserPreferences.enableWikitext2017EditorWithCodeMirror();
} );
beforeEach( async function () {
await EditPage.openForEditing( title );
await EditPage.visualEditorSave.waitForDisplayed();
assert( !( await EditPage.wikiEditorToolbar.isDisplayed() ) );
await EditPage.clickText();
} );
it( 'highlights matching bracket', async function () {
await EditPage.cursorToPosition( 0 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '[]' );
} );
it( 'matches according to cursor movement', async function () {
await EditPage.cursorToPosition( 3 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '{}' );
} );
} );