Skip to content

Commit

Permalink
[Exploratory view] Update types names (#103214)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Jun 28, 2021
1 parent 2ff2a6f commit 4f45535
Show file tree
Hide file tree
Showing 41 changed files with 543 additions and 700 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ export const USE_BREAK_DOWN_COLUMN = 'USE_BREAK_DOWN_COLUMN';
export const FILTER_RECORDS = 'FILTER_RECORDS';
export const TERMS_COLUMN = 'TERMS_COLUMN';
export const OPERATION_COLUMN = 'operation';

export const REPORT_METRIC_FIELD = 'REPORT_METRIC_FIELD';
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export enum URL_KEYS {
BREAK_DOWN = 'bd',
FILTERS = 'ft',
REPORT_DEFINITIONS = 'rdf',
SELECTED_METRIC = 'mt',
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { LayerConfig, LensAttributes } from './lens_attributes';
import { mockAppIndexPattern, mockIndexPattern } from '../rtl_helpers';
import { getDefaultConfigs } from './default_configs';
import { sampleAttribute } from './test_data/sample_attribute';
import { LCP_FIELD, USER_AGENT_NAME } from './constants/elasticsearch_fieldnames';
import {
LCP_FIELD,
TRANSACTION_DURATION,
USER_AGENT_NAME,
} from './constants/elasticsearch_fieldnames';
import { buildExistsFilter, buildPhrasesFilter } from './utils';
import { sampleAttributeKpi } from './test_data/sample_attribute_kpi';
import { REPORT_METRIC_FIELD } from './constants';

describe('Lens Attribute', () => {
mockAppIndexPattern();
Expand All @@ -21,12 +27,12 @@ describe('Lens Attribute', () => {
indexPattern: mockIndexPattern,
});

reportViewConfig.filters?.push(...buildExistsFilter('transaction.type', mockIndexPattern));
reportViewConfig.baseFilters?.push(...buildExistsFilter('transaction.type', mockIndexPattern));

let lnsAttr: LensAttributes;

const layerConfig: LayerConfig = {
reportConfig: reportViewConfig,
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
Expand All @@ -42,6 +48,27 @@ describe('Lens Attribute', () => {
expect(lnsAttr.getJSON()).toEqual(sampleAttribute);
});

it('should return expected json for kpi report type', function () {
const seriesConfigKpi = getDefaultConfigs({
reportType: 'kpi-over-time',
dataType: 'ux',
indexPattern: mockIndexPattern,
});

const lnsAttrKpi = new LensAttributes([
{
seriesConfig: seriesConfigKpi,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
reportDefinitions: { 'service.name': ['elastic-co'] },
time: { from: 'now-15m', to: 'now' },
},
]);

expect(lnsAttrKpi.getJSON()).toEqual(sampleAttributeKpi);
});

it('should return main y axis', function () {
expect(lnsAttr.getMainYAxis(layerConfig)).toEqual({
dataType: 'number',
Expand Down Expand Up @@ -72,7 +99,7 @@ describe('Lens Attribute', () => {
});

it('should return expected field type for custom field with default value', function () {
expect(JSON.stringify(lnsAttr.getFieldMeta('performance.metric', layerConfig))).toEqual(
expect(JSON.stringify(lnsAttr.getFieldMeta(REPORT_METRIC_FIELD, layerConfig))).toEqual(
JSON.stringify({
fieldMeta: {
count: 0,
Expand All @@ -92,7 +119,7 @@ describe('Lens Attribute', () => {

it('should return expected field type for custom field with passed value', function () {
const layerConfig1: LayerConfig = {
reportConfig: reportViewConfig,
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
Expand All @@ -102,20 +129,20 @@ describe('Lens Attribute', () => {

lnsAttr = new LensAttributes([layerConfig1]);

expect(JSON.stringify(lnsAttr.getFieldMeta('performance.metric', layerConfig1))).toEqual(
expect(JSON.stringify(lnsAttr.getFieldMeta(REPORT_METRIC_FIELD, layerConfig1))).toEqual(
JSON.stringify({
fieldMeta: {
count: 0,
name: LCP_FIELD,
name: TRANSACTION_DURATION,
type: 'number',
esTypes: ['scaled_float'],
esTypes: ['long'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
},
fieldName: LCP_FIELD,
columnLabel: 'Largest contentful paint',
fieldName: TRANSACTION_DURATION,
columnLabel: 'Page load time',
})
);
});
Expand Down Expand Up @@ -269,7 +296,7 @@ describe('Lens Attribute', () => {
describe('Layer breakdowns', function () {
it('should return breakdown column', function () {
const layerConfig1: LayerConfig = {
reportConfig: reportViewConfig,
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
Expand Down Expand Up @@ -322,15 +349,15 @@ describe('Lens Attribute', () => {
'x-axis-column-layer0': {
dataType: 'number',
isBucketed: true,
label: 'Largest contentful paint',
label: 'Page load time',
operationType: 'range',
params: {
maxBars: 'auto',
ranges: [{ from: 0, label: '', to: 1000 }],
type: 'histogram',
},
scale: 'interval',
sourceField: 'transaction.marks.agent.largestContentfulPaint',
sourceField: 'transaction.duration.us',
},
'y-axis-column-layer0': {
dataType: 'number',
Expand All @@ -353,12 +380,12 @@ describe('Lens Attribute', () => {

describe('Layer Filters', function () {
it('should return expected filters', function () {
reportViewConfig.filters?.push(
reportViewConfig.baseFilters?.push(
...buildPhrasesFilter('service.name', ['elastic', 'kibana'], mockIndexPattern)
);

const layerConfig1: LayerConfig = {
reportConfig: reportViewConfig,
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
Expand Down
Loading

0 comments on commit 4f45535

Please sign in to comment.