mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Add functional tests for painless lab flyout
This commit is contained in:
parent
c70757ce86
commit
e41b38b634
3 changed files with 51 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
import { type monaco } from '@kbn/monaco';
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrService } from '../ftr_provider_context';
|
||||
|
||||
export class MonacoEditorService extends FtrService {
|
||||
|
@ -62,6 +63,11 @@ export class MonacoEditorService extends FtrService {
|
|||
value
|
||||
);
|
||||
});
|
||||
const newCodeEditorValue = await this.getCodeEditorValue(nthIndex);
|
||||
expect(newCodeEditorValue).equal(
|
||||
value,
|
||||
`Expected value was: ${value}, but got: ${newCodeEditorValue}`
|
||||
);
|
||||
}
|
||||
|
||||
public async getCurrentMarkers(testSubjId: string) {
|
||||
|
|
|
@ -74,7 +74,12 @@ export const RequestFlyout: FunctionComponent<Props> = ({
|
|||
id: 'request',
|
||||
name: 'Request',
|
||||
content: (
|
||||
<EuiCodeBlock language="json" paddingSize="s" isCopyable>
|
||||
<EuiCodeBlock
|
||||
language="json"
|
||||
paddingSize="s"
|
||||
data-test-subj="painlessLabFlyoutRequest"
|
||||
isCopyable
|
||||
>
|
||||
{'POST _scripts/painless/_execute\n'}
|
||||
{requestBody}
|
||||
</EuiCodeBlock>
|
||||
|
@ -84,7 +89,12 @@ export const RequestFlyout: FunctionComponent<Props> = ({
|
|||
id: 'response',
|
||||
name: 'Response',
|
||||
content: (
|
||||
<EuiCodeBlock language="json" paddingSize="s" isCopyable>
|
||||
<EuiCodeBlock
|
||||
language="json"
|
||||
paddingSize="s"
|
||||
data-test-subj="painlessLabFlyoutResponse"
|
||||
isCopyable
|
||||
>
|
||||
{response}
|
||||
</EuiCodeBlock>
|
||||
),
|
||||
|
|
|
@ -5,12 +5,29 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
const TEST_SCRIPT = `return 1;`;
|
||||
const TEST_SCRIPT_REQUEST = `POST _scripts/painless/_execute
|
||||
{
|
||||
"script": {
|
||||
"source": """${TEST_SCRIPT}""",
|
||||
"params": {
|
||||
"string_parameter": "string value",
|
||||
"number_parameter": 1.5,
|
||||
"boolean_parameter": true
|
||||
}
|
||||
}
|
||||
}`;
|
||||
const TEST_SCRIPT_RESPONSE = `"1"`;
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const retry = getService('retry');
|
||||
const PageObjects = getPageObjects(['common', 'console', 'header']);
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
const monacoEditor = getService('monacoEditor');
|
||||
|
||||
describe('Painless lab', function describeIndexTests() {
|
||||
before(async () => {
|
||||
|
@ -18,12 +35,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await retry.waitFor('Wait for editor to be visible', async () => {
|
||||
return testSubjects.isDisplayed('painless_lab');
|
||||
});
|
||||
// replace the default script with a simpler one
|
||||
await monacoEditor.setCodeEditorValue(TEST_SCRIPT);
|
||||
});
|
||||
|
||||
it('click show API request button and flyout should appear in page', async () => {
|
||||
await testSubjects.click('btnViewRequest');
|
||||
|
||||
await testSubjects.existOrFail('painlessLabRequestFlyoutHeader', { timeout: 10 * 1000 });
|
||||
});
|
||||
|
||||
it('validate request body is the expected', async () => {
|
||||
const requestText = await testSubjects.getVisibleText('painlessLabFlyoutRequest');
|
||||
expect(requestText).equal(TEST_SCRIPT_REQUEST);
|
||||
});
|
||||
|
||||
it('validate response body is the expected', async () => {
|
||||
await find.clickByCssSelector('#response');
|
||||
await retry.waitFor('Wait for response to change', async () => {
|
||||
return (
|
||||
(await testSubjects.getVisibleText('painlessLabFlyoutResponse')) === TEST_SCRIPT_RESPONSE
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue