[Painless Lab] Add basic functional smoke tests for both serverless and stateful (#172679)

This commit is contained in:
Ignacio Rivas 2023-12-07 08:15:40 +01:00 committed by GitHub
parent f5c78b966b
commit 7ea0b232ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 159 additions and 0 deletions

View file

@ -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

View file

@ -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('.')],
};
}

View file

@ -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'));
});
};

View file

@ -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());
});
});
});
}

View file

@ -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'));
});
}

View file

@ -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());
});
});
});
}

View file

@ -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',

View file

@ -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',