import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export default function ( { getPageObjects , getService } ) { const PageObjects = getPageObjects ( [ 'common' ] ) ; const testSubjects = getService ( 'testSubjects' ) ; const aceEditor = getService ( 'aceEditor' ) ; const retry = getService ( 'retry' ) ; const security = getService ( 'security' ) ; const editorTestSubjectSelector = 'searchProfilerEditor' ; describe ( 'Search Profiler Editor' , ( ) => { before ( async ( ) => { await security . testUser . setRoles ( [ 'global_devtools_read' ] ) ; await PageObjects . common . navigateToApp ( 'searchProfiler' ) ; expect ( await testSubjects . exists ( 'searchProfilerEditor' ) ) . to . be ( true ) ; } ) ; after ( async ( ) => { await security . testUser . restoreDefaults ( ) ; } ) ; it ( 'correctly parses triple quotes in JSON' , async ( ) => { const okInput = [ `{
"query": {
"match_all": {}` , `{
"query": {
"match_all": {
"test": """{ "more": "json" }"""` , ] ; const notOkInput = [ `{
"query": {
"match_all": {
"test": """{ "more": "json" }""` , `{
"query": {
"match_all": {
"test": """{ "more": "json" }""'` , ] ; const expectHasParseErrorsToBe = ( expectation ) => async ( inputs ) => { for ( const input of inputs ) { await aceEditor . setValue ( editorTestSubjectSelector , input ) ; await retry . waitFor ( `parser errors to match expectation: HAS ${ expectation ? 'ERRORS' : 'NO ERRORS' }` , async ( ) => { const actual = await aceEditor . hasParseErrors ( editorTestSubjectSelector ) ; return expectation === actual ; } ) ; } } ; await expectHasParseErrorsToBe ( false ) ( okInput ) ; await expectHasParseErrorsToBe ( true ) ( notOkInput ) ; } ) ; } ) ; }