import { generateReleaseWidgetFieldOptions, SESSIONS_FIELDS, } from 'sentry/views/dashboardsV2/widgetBuilder/releaseWidget/fields'; describe('generateReleaseWidgetFieldOptions', function () { const fields = Object.values(SESSIONS_FIELDS); const tagKeys = ['release', 'environment']; it('generates correct field options', function () { expect(generateReleaseWidgetFieldOptions(fields, tagKeys)).toEqual({ 'field:session': { label: 'session', value: { kind: 'metric', meta: { dataType: 'integer', name: 'session', }, }, }, 'field:session.duration': { label: 'session.duration', value: { kind: 'metric', meta: { dataType: 'duration', name: 'session.duration', }, }, }, 'field:user': { label: 'user', value: { kind: 'metric', meta: { dataType: 'string', name: 'user', }, }, }, 'function:avg': { label: 'avg(…)', value: { kind: 'function', meta: { name: 'avg', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:count_abnormal': { label: 'count_abnormal(…)', value: { kind: 'function', meta: { name: 'count_abnormal', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:count_crashed': { label: 'count_crashed(…)', value: { kind: 'function', meta: { name: 'count_crashed', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:count_errored': { label: 'count_errored(…)', value: { kind: 'function', meta: { name: 'count_errored', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:count_healthy': { label: 'count_healthy(…)', value: { kind: 'function', meta: { name: 'count_healthy', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:count_unique': { label: 'count_unique(…)', value: { kind: 'function', meta: { name: 'count_unique', parameters: [ { columnTypes: ['string'], defaultValue: 'user', kind: 'column', required: true, }, ], }, }, }, 'function:crash_free_rate': { label: 'crash_free_rate(…)', value: { kind: 'function', meta: { name: 'crash_free_rate', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:crash_rate': { label: 'crash_rate(…)', value: { kind: 'function', meta: { name: 'crash_rate', parameters: [ { columnTypes: ['integer', 'string'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'function:max': { label: 'max(…)', value: { kind: 'function', meta: { name: 'max', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:p50': { label: 'p50(…)', value: { kind: 'function', meta: { name: 'p50', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:p75': { label: 'p75(…)', value: { kind: 'function', meta: { name: 'p75', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:p95': { label: 'p95(…)', value: { kind: 'function', meta: { name: 'p95', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:p99': { label: 'p99(…)', value: { kind: 'function', meta: { name: 'p99', parameters: [ { columnTypes: ['duration'], defaultValue: 'session.duration', kind: 'column', required: true, }, ], }, }, }, 'function:sum': { label: 'sum(…)', value: { kind: 'function', meta: { name: 'sum', parameters: [ { columnTypes: ['integer'], defaultValue: 'session', kind: 'column', required: true, }, ], }, }, }, 'field:environment': { label: 'environment', value: { kind: 'field', meta: { dataType: 'string', name: 'environment', }, }, }, 'field:release': { label: 'release', value: { kind: 'field', meta: { dataType: 'string', name: 'release', }, }, }, }); }); });