123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- import {SessionUserCountByStatusByRelease} from 'sentry-fixture/sessions';
- import {transformSessionsResponseToTable} from 'sentry/views/dashboards/widgetCard/transformSessionsResponseToTable';
- describe('transformSessionsResponseToTable', function () {
- it('transforms sessions into table', () => {
- expect(
- transformSessionsResponseToTable(SessionUserCountByStatusByRelease(), [], [])
- ).toEqual({
- data: [
- {
- 'count_unique(user)': 1,
- id: '0',
- release: '1',
- 'session.status': 'crashed',
- 'sum(session)': 34,
- },
- {
- 'count_unique(user)': 1,
- id: '1',
- release: '1',
- 'session.status': 'abnormal',
- 'sum(session)': 1,
- },
- {
- 'count_unique(user)': 2,
- id: '2',
- release: '1',
- 'session.status': 'errored',
- 'sum(session)': 451,
- },
- {
- 'count_unique(user)': 3,
- id: '3',
- release: '1',
- 'session.status': 'healthy',
- 'sum(session)': 5058,
- },
- {
- 'count_unique(user)': 2,
- id: '4',
- release: '2',
- 'session.status': 'crashed',
- 'sum(session)': 35,
- },
- {
- 'count_unique(user)': 1,
- id: '5',
- release: '2',
- 'session.status': 'abnormal',
- 'sum(session)': 1,
- },
- {
- 'count_unique(user)': 1,
- id: '6',
- release: '2',
- 'session.status': 'errored',
- 'sum(session)': 452,
- },
- {
- 'count_unique(user)': 10,
- id: '7',
- release: '2',
- 'session.status': 'healthy',
- 'sum(session)': 5059,
- },
- ],
- meta: {
- 'count_unique(user)': 'integer',
- release: 'string',
- 'session.status': 'string',
- 'sum(session)': 'integer',
- },
- });
- });
- it('adds derived metric fields', () => {
- expect(
- transformSessionsResponseToTable(
- SessionUserCountByStatusByRelease(),
- ['count_crashed(session)'],
- []
- )
- ).toEqual({
- data: [
- {
- 'count_crashed(session)': 34,
- 'count_unique(user)': 1,
- id: '0',
- release: '1',
- 'session.status': 'crashed',
- 'sum(session)': 34,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '1',
- release: '1',
- 'session.status': 'abnormal',
- 'sum(session)': 1,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 2,
- id: '2',
- release: '1',
- 'session.status': 'errored',
- 'sum(session)': 451,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 3,
- id: '3',
- release: '1',
- 'session.status': 'healthy',
- 'sum(session)': 5058,
- },
- {
- 'count_crashed(session)': 35,
- 'count_unique(user)': 2,
- id: '4',
- release: '2',
- 'session.status': 'crashed',
- 'sum(session)': 35,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '5',
- release: '2',
- 'session.status': 'abnormal',
- 'sum(session)': 1,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '6',
- release: '2',
- 'session.status': 'errored',
- 'sum(session)': 452,
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 10,
- id: '7',
- release: '2',
- 'session.status': 'healthy',
- 'sum(session)': 5059,
- },
- ],
- meta: {
- 'count_crashed(session)': 'integer',
- 'count_unique(user)': 'integer',
- release: 'string',
- 'session.status': 'string',
- 'sum(session)': 'integer',
- },
- });
- });
- it('strips away injected fields', () => {
- expect(
- transformSessionsResponseToTable(
- SessionUserCountByStatusByRelease(),
- ['count_crashed(session)'],
- ['sum(session)']
- )
- ).toEqual({
- data: [
- {
- 'count_crashed(session)': 34,
- 'count_unique(user)': 1,
- id: '0',
- release: '1',
- 'session.status': 'crashed',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '1',
- release: '1',
- 'session.status': 'abnormal',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 2,
- id: '2',
- release: '1',
- 'session.status': 'errored',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 3,
- id: '3',
- release: '1',
- 'session.status': 'healthy',
- },
- {
- 'count_crashed(session)': 35,
- 'count_unique(user)': 2,
- id: '4',
- release: '2',
- 'session.status': 'crashed',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '5',
- release: '2',
- 'session.status': 'abnormal',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 1,
- id: '6',
- release: '2',
- 'session.status': 'errored',
- },
- {
- 'count_crashed(session)': 0,
- 'count_unique(user)': 10,
- id: '7',
- release: '2',
- 'session.status': 'healthy',
- },
- ],
- meta: {
- 'count_crashed(session)': 'integer',
- 'count_unique(user)': 'integer',
- release: 'string',
- 'session.status': 'string',
- },
- });
- });
- });
|