Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Jun 28, 2021
1 parent 819fc93 commit e3bbbe3
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ describe('Lens Attribute', () => {
});

it('should return main y axis', function () {
expect(lnsAttr.getMainYAxis(layerConfig)).toEqual({
expect(lnsAttr.getMainYAxis(layerConfig, 'layer0', '')).toEqual({
dataType: 'number',
isBucketed: false,
label: 'Pages loaded',
operationType: 'count',
operationType: 'formula',
params: {
format: {
id: 'percent',
params: {
decimals: 0,
},
},
formula: 'count() / overall_sum(count())',
isFormulaBroken: false,
},
references: ['y-axis-column-layer0X4'],
scale: 'ratio',
sourceField: 'Records',
});
});

Expand Down Expand Up @@ -203,7 +213,15 @@ describe('Lens Attribute', () => {
it('should return first layer', function () {
expect(lnsAttr.getLayers()).toEqual({
layer0: {
columnOrder: ['x-axis-column-layer0', 'y-axis-column-layer0'],
columnOrder: [
'x-axis-column-layer0',
'y-axis-column-layer0',
'y-axis-column-layer0X0',
'y-axis-column-layer0X1',
'y-axis-column-layer0X2',
'y-axis-column-layer0X3',
'y-axis-column-layer0X4',
],
columns: {
'x-axis-column-layer0': {
dataType: 'number',
Expand All @@ -226,16 +244,98 @@ describe('Lens Attribute', () => {
},
'y-axis-column-layer0': {
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Pages loaded',
operationType: 'formula',
params: {
format: {
id: 'percent',
params: {
decimals: 0,
},
},
formula:
"count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))",
isFormulaBroken: false,
},
references: ['y-axis-column-layer0X4'],
scale: 'ratio',
},
'y-axis-column-layer0X0': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'count',
scale: 'ratio',
sourceField: 'Records',
},
'y-axis-column-layer0X1': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'count',
scale: 'ratio',
sourceField: 'Records',
},
'y-axis-column-layer0X2': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'math',
params: {
tinymathAst: 'y-axis-column-layer0X1',
},
references: ['y-axis-column-layer0X1'],
scale: 'ratio',
},
'y-axis-column-layer0X3': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'overall_sum',
references: ['y-axis-column-layer0X2'],
scale: 'ratio',
},
'y-axis-column-layer0X4': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'math',
params: {
tinymathAst: {
args: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'],
location: {
max: 30,
min: 0,
},
name: 'divide',
text:
"count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))",
type: 'function',
},
},
references: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'],
scale: 'ratio',
},
},
incompleteColumns: {},
Expand Down Expand Up @@ -299,7 +399,16 @@ describe('Lens Attribute', () => {
]);

expect(lnsAttr.layers.layer0).toEqual({
columnOrder: ['x-axis-column-layer0', 'breakdown-column-layer0', 'y-axis-column-layer0'],
columnOrder: [
'x-axis-column-layer0',
'breakdown-column-layer0',
'y-axis-column-layer0',
'y-axis-column-layer0X0',
'y-axis-column-layer0X1',
'y-axis-column-layer0X2',
'y-axis-column-layer0X3',
'y-axis-column-layer0X4',
],
columns: {
'breakdown-column-layer0': {
dataType: 'string',
Expand All @@ -326,24 +435,112 @@ describe('Lens Attribute', () => {
operationType: 'range',
params: {
maxBars: 'auto',
ranges: [{ from: 0, label: '', to: 1000 }],
ranges: [
{
from: 0,
label: '',
to: 1000,
},
],
type: 'histogram',
},
scale: 'interval',
sourceField: 'transaction.marks.agent.largestContentfulPaint',
},
'y-axis-column-layer0': {
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Pages loaded',
operationType: 'formula',
params: {
format: {
id: 'percent',
params: {
decimals: 0,
},
},
formula:
"count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))",
isFormulaBroken: false,
},
references: ['y-axis-column-layer0X4'],
scale: 'ratio',
},
'y-axis-column-layer0X0': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'count',
scale: 'ratio',
sourceField: 'Records',
},
'y-axis-column-layer0X1': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
query:
'transaction.type: page-load and processor.event: transaction and transaction.type : *',
},
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'count',
scale: 'ratio',
sourceField: 'Records',
},
'y-axis-column-layer0X2': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'math',
params: {
tinymathAst: 'y-axis-column-layer0X1',
},
references: ['y-axis-column-layer0X1'],
scale: 'ratio',
},
'y-axis-column-layer0X3': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'overall_sum',
references: ['y-axis-column-layer0X2'],
scale: 'ratio',
},
'y-axis-column-layer0X4': {
customLabel: true,
dataType: 'number',
isBucketed: false,
label: 'Part of count() / overall_sum(count())',
operationType: 'math',
params: {
tinymathAst: {
args: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'],
location: {
max: 30,
min: 0,
},
name: 'divide',
text:
"count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))",
type: 'function',
},
},
references: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'],
scale: 'ratio',
},
},
incompleteColumns: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ConfigProps, SeriesConfig } from '../../types';
import { FieldLabels, RECORDS_FIELD } from '../constants';
import { FieldLabels, RECORDS_PERCENTAGE_FIELD } from '../constants';
import { buildExistsFilter } from '../utils';
import { MONITORS_DURATION_LABEL, PINGS_LABEL } from '../constants/labels';

Expand All @@ -23,7 +23,7 @@ export function getSyntheticsDistributionConfig({
},
yAxisColumns: [
{
sourceField: RECORDS_FIELD,
sourceField: RECORDS_PERCENTAGE_FIELD,
label: PINGS_LABEL,
},
],
Expand Down
Loading

0 comments on commit e3bbbe3

Please sign in to comment.