Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d662d6f
add preview for creating scripted fields
nreese Jul 12, 2018
7597d1b
Move previewed results into flyout. (#25)
cjcenizal Jul 13, 2018
0a4082b
Merge branch 'master' of https://github.com/elastic/kibana into scrip…
nreese Jul 13, 2018
063aa58
add functional test for preview
nreese Jul 13, 2018
8b64303
move executeScript functionallity into lib so it can be used to valid…
nreese Jul 14, 2018
4e4191a
validate script on save
nreese Jul 14, 2018
78a724b
add functional test for script validation during save
nreese Jul 14, 2018
e02a0f9
Merge branch 'master' of https://github.com/elastic/kibana into scrip…
nreese Jul 16, 2018
222bcd5
fix jest tests
nreese Jul 16, 2018
cd383e2
fix jest tests
nreese Jul 16, 2018
4f08de9
Merge branch 'master' of https://github.com/elastic/kibana into scrip…
nreese Jul 17, 2018
0e4d2c7
only validate script when field is scripted
nreese Jul 17, 2018
083ce26
Merge branch 'master' of https://github.com/elastic/kibana into scrip…
nreese Jul 17, 2018
24219cf
only add script callouts and help flyout to DOM for scripted fields
nreese Jul 18, 2018
5da925a
Merge branch 'master' of https://github.com/elastic/kibana into scrip…
nreese Jul 18, 2018
c71bfce
move scripting stuff to its own render method
nreese Jul 18, 2018
c3af10c
right justify delete button to have same style as delete button for u…
nreese Jul 18, 2018
5639215
use data-test-subj key to find invalid script error msg in functional…
nreese Jul 18, 2018
568f2a6
move help flyout link out of formRow help text and into its own row
nreese Jul 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
601 changes: 387 additions & 214 deletions src/ui/public/field_editor/__snapshots__/field_editor.test.js.snap

Large diffs are not rendered by default.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,26 @@
import { PureComponent } from 'react';
import PropTypes from 'prop-types';

import {
convertSampleInput
} from '../../../../lib';
export const convertSampleInput = (converter, inputs) => {
let error = null;
let samples = [];

try {
samples = inputs.map(input => {
return {
input,
output: converter(input),
};
});
} catch(e) {
error = `An error occurred while trying to use this format configuration: ${e.message}`;
}

return {
error,
samples,
};
};

export class DefaultFormatEditor extends PureComponent {
static propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { DefaultFormatEditor } from './default';
import { DefaultFormatEditor, convertSampleInput } from './default';

const fieldType = 'number';
const format = {
Expand All @@ -31,6 +31,39 @@ const onChange = jest.fn();
const onError = jest.fn();

describe('DefaultFormatEditor', () => {

describe('convertSampleInput', () => {
const converter = (input) => {
if(isNaN(input)) {
throw {
message: 'Input is not a number'
};
} else {
return input * 2;
}
};

it('should convert a set of inputs', () => {
const inputs = [1, 10, 15];
const output = convertSampleInput(converter, inputs);

expect(output.error).toEqual(null);
expect(JSON.stringify(output.samples)).toEqual(JSON.stringify([
{ input: 1, output: 2 },
{ input: 10, output: 20 },
{ input: 15, output: 30 },
]));
});

it('should return error if converter throws one', () => {
const inputs = [1, 10, 15, 'invalid'];
const output = convertSampleInput(converter, inputs);

expect(output.error).toEqual('An error occurred while trying to use this format configuration: Input is not a number');
expect(JSON.stringify(output.samples)).toEqual(JSON.stringify([]));
});
});

it('should render nothing', async () => {
const component = shallow(
<DefaultFormatEditor
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@

export { ScriptingDisabledCallOut } from './disabled_call_out';
export { ScriptingWarningCallOut } from './warning_call_out';
export { ScriptingHelpFlyout } from './help_flyout';
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ScriptingHelpFlyout should render normally 1`] = `
<EuiFlyout
data-test-subj="scriptedFieldsHelpFlyout"
hideCloseButton={false}
onClose={[Function]}
ownFocus={false}
size="m"
>
<EuiFlyoutBody>
<EuiTabbedContent
initialSelectedTab={
Object {
"content": <Unknown />,
"data-test-subj": "syntaxTab",
"id": "syntax",
"name": "Syntax",
}
}
tabs={
Array [
Object {
"content": <Unknown />,
"data-test-subj": "syntaxTab",
"id": "syntax",
"name": "Syntax",
},
Object {
"content": <TestScript
executeScript={[Function]}
indexPattern={Object {}}
lang="painless"
name="myScriptedField"
script={undefined}
/>,
"data-test-subj": "testTab",
"id": "test",
"name": "Preview results",
},
]
}
/>
</EuiFlyoutBody>
</EuiFlyout>
`;

exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = `""`;
Loading