mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Console] Fix syntax highlighting for triple quotes (#136719)
* [Console] Fix syntax highlighting for triple quotes * Add tests Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
This commit is contained in:
parent
0069fd7168
commit
4ad72fc876
4 changed files with 55 additions and 14 deletions
|
@ -1950,8 +1950,8 @@ ace.define(
|
|||
uffff;
|
||||
|
||||
if (ch === '"') {
|
||||
let c = '""';
|
||||
if (text.substring(at, c.length) === c) {
|
||||
// If the current and the next characters are equal to "", empty string or start of triple quoted strings
|
||||
if (peek(0) === '"' && peek(1) === '"') {
|
||||
// literal
|
||||
next('"');
|
||||
next('"');
|
||||
|
|
50
test/functional/apps/console/_xjson.ts
Normal file
50
test/functional/apps/console/_xjson.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default ({ getService, getPageObjects }: FtrProviderContext) => {
|
||||
const retry = getService('retry');
|
||||
const log = getService('log');
|
||||
const PageObjects = getPageObjects(['common', 'console', 'header']);
|
||||
|
||||
describe("Console's XJSON features", function testXjson() {
|
||||
this.tags('includeFirefox');
|
||||
before(async () => {
|
||||
log.debug('navigateTo console');
|
||||
await PageObjects.common.navigateToApp('console');
|
||||
await retry.try(async () => {
|
||||
await PageObjects.console.collapseHelp();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await PageObjects.console.clearTextArea();
|
||||
});
|
||||
|
||||
describe('with triple quoted strings', () => {
|
||||
it('should allow escaping quotation mark by wrapping it in triple quotes', async () => {
|
||||
await PageObjects.console.enterRequest(
|
||||
'\nPOST test/_doc/1 \n{\n "foo": """look "escaped" quotes"""'
|
||||
);
|
||||
await PageObjects.console.clickPlay();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await PageObjects.console.hasErrorMarker()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with invalid syntax', () => {
|
||||
it('should trigger validation errors', async () => {
|
||||
await PageObjects.console.enterRequest('\nGET test/doc/1 \n{\n "foo": \'\'');
|
||||
expect(await PageObjects.console.hasInvalidSyntax()).to.be(true);
|
||||
expect(await PageObjects.console.hasErrorMarker()).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
|
@ -22,6 +22,7 @@ export default function ({ getService, loadTestFile }) {
|
|||
loadTestFile(require.resolve('./_vector_tile'));
|
||||
loadTestFile(require.resolve('./_comments'));
|
||||
loadTestFile(require.resolve('./_variables'));
|
||||
loadTestFile(require.resolve('./_xjson'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -238,21 +238,11 @@ export class ConsolePageObject extends FtrService {
|
|||
}
|
||||
|
||||
public async hasInvalidSyntax() {
|
||||
try {
|
||||
const requestEditor = await this.getRequestEditor();
|
||||
return Boolean(await requestEditor.findByCssSelector('.ace_invalid'));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return await this.find.existsByCssSelector('.ace_invalid');
|
||||
}
|
||||
|
||||
public async hasErrorMarker() {
|
||||
try {
|
||||
const requestEditor = await this.getRequestEditor();
|
||||
return Boolean(await requestEditor.findByCssSelector('.ace_error'));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return await this.find.existsByCssSelector('.ace_error');
|
||||
}
|
||||
|
||||
public async clickFoldWidget() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue