diff --git a/.buildkite/ftr_configs.yml b/.buildkite/ftr_configs.yml index 662ebbe522ebd..788bbc2df8d4e 100644 --- a/.buildkite/ftr_configs.yml +++ b/.buildkite/ftr_configs.yml @@ -307,6 +307,7 @@ enabled: - x-pack/test/functional/apps/ml/stack_management_jobs/config.ts - x-pack/test/functional/apps/monitoring/config.ts - x-pack/test/functional/apps/observability_log_explorer/config.ts + - x-pack/test/functional/apps/painless_lab/config.ts - x-pack/test/functional/apps/remote_clusters/config.ts - x-pack/test/functional/apps/reporting_management/config.ts - x-pack/test/functional/apps/rollup_job/config.ts diff --git a/x-pack/test/functional/apps/painless_lab/config.ts b/x-pack/test/functional/apps/painless_lab/config.ts new file mode 100644 index 0000000000000..d0d07ff200281 --- /dev/null +++ b/x-pack/test/functional/apps/painless_lab/config.ts @@ -0,0 +1,17 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrConfigProviderContext } from '@kbn/test'; + +export default async function ({ readConfigFile }: FtrConfigProviderContext) { + const functionalConfig = await readConfigFile(require.resolve('../../config.base.js')); + + return { + ...functionalConfig.getAll(), + testFiles: [require.resolve('.')], + }; +} diff --git a/x-pack/test/functional/apps/painless_lab/index.ts b/x-pack/test/functional/apps/painless_lab/index.ts new file mode 100644 index 0000000000000..70aca9309243e --- /dev/null +++ b/x-pack/test/functional/apps/painless_lab/index.ts @@ -0,0 +1,14 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default ({ loadTestFile }: FtrProviderContext) => { + describe('Painless lab app', function () { + loadTestFile(require.resolve('./painless_lab')); + }); +}; diff --git a/x-pack/test/functional/apps/painless_lab/painless_lab.ts b/x-pack/test/functional/apps/painless_lab/painless_lab.ts new file mode 100644 index 0000000000000..015263d6edec5 --- /dev/null +++ b/x-pack/test/functional/apps/painless_lab/painless_lab.ts @@ -0,0 +1,53 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +const TEST_SCRIPT_RESULT = 45; +const TEST_SCRIPT = ` +int total = 0; + +for (int i = 0; i < 10; ++i) { + total += i; +} + +return total; +`.trim(); + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const retry = getService('retry'); + const PageObjects = getPageObjects(['common', 'console', 'header']); + const testSubjects = getService('testSubjects'); + const monacoEditor = getService('monacoEditor'); + + describe('Painless lab', function describeIndexTests() { + before(async () => { + await PageObjects.common.navigateToApp('dev_tools', { hash: '/painless_lab' }); + await retry.waitFor('Wait for editor to be visible', async () => { + return testSubjects.isDisplayed('painless_lab'); + }); + }); + + it('should show the editor and preview panels', async () => { + const editor = await testSubjects.find('kibanaCodeEditor'); + const preview = await testSubjects.find('painlessTabs'); + + expect(await editor.isDisplayed()).to.be(true); + expect(await preview.isDisplayed()).to.be(true); + }); + + it('executes the script and shows the right result', async () => { + await monacoEditor.setCodeEditorValue(TEST_SCRIPT); + + await retry.try(async () => { + const result = await testSubjects.find('painlessTabs'); + expect(await result.getVisibleText()).to.contain(TEST_SCRIPT_RESULT.toString()); + }); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/common/painless_lab/index.ts b/x-pack/test_serverless/functional/test_suites/common/painless_lab/index.ts new file mode 100644 index 0000000000000..0a0b9c0ab022d --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/painless_lab/index.ts @@ -0,0 +1,14 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('Serverless Common UI - Painless lab', function () { + loadTestFile(require.resolve('./painless_lab')); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/common/painless_lab/painless_lab.ts b/x-pack/test_serverless/functional/test_suites/common/painless_lab/painless_lab.ts new file mode 100644 index 0000000000000..e781808189100 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/painless_lab/painless_lab.ts @@ -0,0 +1,58 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +const TEST_SCRIPT_RESULT = 45; +const TEST_SCRIPT = ` +int total = 0; + +for (int i = 0; i < 10; ++i) { + total += i; +} + +return total; +`.trim(); + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const retry = getService('retry'); + const PageObjects = getPageObjects(['common', 'console', 'header', 'svlCommonPage']); + const testSubjects = getService('testSubjects'); + const monacoEditor = getService('monacoEditor'); + + describe('Painless lab', function describeIndexTests() { + before(async () => { + await PageObjects.svlCommonPage.login(); + await PageObjects.common.navigateToApp('dev_tools', { hash: '/painless_lab' }); + await retry.waitFor('Wait for editor to be visible', async () => { + return testSubjects.isDisplayed('painless_lab'); + }); + }); + + after(async () => { + await PageObjects.svlCommonPage.forceLogout(); + }); + + it('should show the editor and preview panels', async () => { + const editor = await testSubjects.find('kibanaCodeEditor'); + const preview = await testSubjects.find('painlessTabs'); + + expect(await editor.isDisplayed()).to.be(true); + expect(await preview.isDisplayed()).to.be(true); + }); + + it('executes the script and shows the right result', async () => { + await monacoEditor.setCodeEditorValue(TEST_SCRIPT); + + await retry.try(async () => { + const result = await testSubjects.find('painlessTabs'); + expect(await result.getVisibleText()).to.contain(TEST_SCRIPT_RESULT.toString()); + }); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts b/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts index 7207a857f692f..79ace54bdc6ac 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts @@ -19,6 +19,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/reporting'), require.resolve('../../common/grok_debugger'), require.resolve('../../common/console'), + require.resolve('../../common/painless_lab'), ], junit: { reportName: 'Serverless Observability Functional Tests - Common Group 1', diff --git a/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts b/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts index 9f96ca3b0c263..c7771a0bf9c2d 100644 --- a/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts +++ b/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts @@ -19,6 +19,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/reporting'), require.resolve('../../common/grok_debugger'), require.resolve('../../common/console'), + require.resolve('../../common/painless_lab'), ], junit: { reportName: 'Serverless Security Functional Tests - Common Group 1',