-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Painless Lab] Add basic functional smoke tests for both serverless a…
…nd stateful (#172679)
- Loading branch information
1 parent
f5c78b9
commit 7ea0b23
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('.')], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
}); | ||
}); | ||
}); | ||
} |
14 changes: 14 additions & 0 deletions
14
x-pack/test_serverless/functional/test_suites/common/painless_lab/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
}); | ||
} |
58 changes: 58 additions & 0 deletions
58
x-pack/test_serverless/functional/test_suites/common/painless_lab/painless_lab.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters