Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FieldFormats] Add editors tests #107770

Merged
merged 6 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
return (
<EuiFieldText
value={value}
data-test-subj={`colorEditorKeyPattern ${item.index}`}
onChange={(e) => {
this.onColorChange(
{
Expand All @@ -120,6 +121,7 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
return (
<EuiFieldText
value={value}
data-test-subj={`colorEditorKeyRange ${item.index}`}
onChange={(e) => {
this.onColorChange(
{
Expand All @@ -144,6 +146,7 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
return (
<EuiColorPicker
color={color}
data-test-subj={`colorEditorColorPicker ${item.index}`}
onChange={(newColor) => {
this.onColorChange(
{
Expand All @@ -168,6 +171,7 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
return (
<EuiColorPicker
color={color}
data-test-subj={`colorEditorBackgroundPicker ${item.index}`}
onChange={(newColor) => {
this.onColorChange(
{
Expand Down Expand Up @@ -220,6 +224,7 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
icon: 'trash',
color: 'danger',
available: () => items.length > 1,
'data-test-subj': 'colorEditorRemoveColor',
},
],
},
Expand All @@ -229,7 +234,12 @@ export class ColorFormatEditor extends DefaultFormatEditor<ColorFormatEditorForm
<Fragment>
<EuiBasicTable items={items} columns={columns} />
<EuiSpacer size="m" />
<EuiButton iconType="plusInCircle" size="s" onClick={this.addColor}>
<EuiButton
iconType="plusInCircle"
size="s"
onClick={this.addColor}
data-test-subj={'colorEditorAddColor'}
>
<FormattedMessage
id="indexPatternFieldEditor.color.addColorButton"
defaultMessage="Add color"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class DurationFormatEditor extends DefaultFormatEditor<
error={hasDecimalError ? null : error}
>
<EuiSelect
data-test-subj={'durationEditorInputFormat'}
value={formatParams.inputFormat}
options={format.type.inputFormats.map((fmt: InputFormat) => {
return {
Expand All @@ -126,6 +127,7 @@ export class DurationFormatEditor extends DefaultFormatEditor<
isInvalid={!!error}
>
<EuiSelect
data-test-subj={'durationEditorOutputFormat'}
value={formatParams.outputFormat}
options={format.type.outputFormats.map((fmt: OutputFormat) => {
return {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class NumberFormatEditor extends DefaultFormatEditor<NumberFormatEditorPa
error={error}
>
<EuiFieldText
data-test-subj={'numberEditorFormatPattern'}
value={formatParams.pattern}
placeholder={defaultPattern}
onChange={(e) => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor<StaticLookupFo
return (
<EuiFieldText
value={value || ''}
data-test-subj={`staticLookupEditorKey ${item.index}`}
onChange={(e) => {
this.onLookupChange(
{
Expand All @@ -105,6 +106,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor<StaticLookupFo
return (
<EuiFieldText
value={value || ''}
data-test-subj={`staticLookupEditorValue ${item.index}`}
onChange={(e) => {
this.onLookupChange(
{
Expand Down Expand Up @@ -136,6 +138,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor<StaticLookupFo
type: 'icon',
icon: 'trash',
color: 'danger',
'data-test-subj': 'staticLookupEditorRemoveEntry',
available: () => items.length > 1,
},
],
Expand All @@ -147,7 +150,12 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor<StaticLookupFo
<Fragment>
<EuiBasicTable items={items} columns={columns} style={{ maxWidth: '400px' }} />
<EuiSpacer size="m" />
<EuiButton iconType="plusInCircle" size="s" onClick={this.addLookup}>
<EuiButton
iconType="plusInCircle"
size="s"
onClick={this.addLookup}
data-test-subj={'staticLookupEditorAddEntry'}
>
<FormattedMessage
id="indexPatternFieldEditor.staticLookup.addEntryButton"
defaultMessage="Add entry"
Expand All @@ -164,6 +172,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor<StaticLookupFo
>
<EuiFieldText
value={formatParams.unknownKeyValue || ''}
data-test-subj={'staticLookupEditorUnknownValue'}
placeholder={i18n.translate(
'indexPatternFieldEditor.staticLookup.leaveBlankPlaceholder',
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class TruncateFormatEditor extends DefaultFormatEditor<TruncateFormatEdit
<EuiFieldNumber
defaultValue={formatParams.fieldLength}
min={1}
data-test-subj={'truncateEditorLength'}
onChange={(e) => {
if (e.target.checkValidity()) {
this.onChange({
Expand Down
2 changes: 2 additions & 0 deletions test/common/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { RandomnessService } from './randomness';
import { SecurityServiceProvider } from './security';
import { EsDeleteAllIndicesProvider } from './es_delete_all_indices';
import { SavedObjectInfoService } from './saved_object_info';
import { IndexPatternsService } from './index_patterns';

export const services = {
deployment: DeploymentService,
Expand All @@ -26,4 +27,5 @@ export const services = {
security: SecurityServiceProvider,
esDeleteAllIndices: EsDeleteAllIndicesProvider,
savedObjectInfo: SavedObjectInfoService,
indexPatterns: IndexPatternsService,
};
35 changes: 35 additions & 0 deletions test/common/services/index_patterns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { FtrService } from '../ftr_provider_context';
import { IndexPatternSpec } from '../../../src/plugins/data/common';

export class IndexPatternsService extends FtrService {
private readonly kibanaServer = this.ctx.getService('kibanaServer');

/**
* Create a new index pattern
*/
async create(
indexPattern: { title: string },
{ override = false }: { override: boolean } = { override: false }
): Promise<IndexPatternSpec> {
const response = await this.kibanaServer.request<{
index_pattern: IndexPatternSpec;
}>({
path: '/api/index_patterns/index_pattern',
method: 'POST',
body: {
override,
index_pattern: indexPattern,
},
});

return response.data.index_pattern;
}
}
Loading