releases.spec.tsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import {transformSessionsResponseToTable} from 'sentry/views/dashboards/datasetConfig/releases';
  2. describe('transformSessionsResponseToTable', function () {
  3. const widgetQuery = {
  4. name: '',
  5. fields: ['count_unique(user)', 'sum(session)', 'release', 'session.status'],
  6. columns: ['release', 'session.status'],
  7. aggregates: ['count_unique(user)', 'sum(session)'],
  8. conditions: '',
  9. orderby: '',
  10. };
  11. it('transforms sessions into table', () => {
  12. expect(
  13. transformSessionsResponseToTable(
  14. TestStubs.SessionUserCountByStatusByRelease(),
  15. widgetQuery
  16. )
  17. ).toEqual({
  18. data: [
  19. {
  20. 'count_unique(user)': 1,
  21. id: '0',
  22. release: '1',
  23. 'session.status': 'crashed',
  24. 'sum(session)': 34,
  25. },
  26. {
  27. 'count_unique(user)': 1,
  28. id: '1',
  29. release: '1',
  30. 'session.status': 'abnormal',
  31. 'sum(session)': 1,
  32. },
  33. {
  34. 'count_unique(user)': 2,
  35. id: '2',
  36. release: '1',
  37. 'session.status': 'errored',
  38. 'sum(session)': 451,
  39. },
  40. {
  41. 'count_unique(user)': 3,
  42. id: '3',
  43. release: '1',
  44. 'session.status': 'healthy',
  45. 'sum(session)': 5058,
  46. },
  47. {
  48. 'count_unique(user)': 2,
  49. id: '4',
  50. release: '2',
  51. 'session.status': 'crashed',
  52. 'sum(session)': 35,
  53. },
  54. {
  55. 'count_unique(user)': 1,
  56. id: '5',
  57. release: '2',
  58. 'session.status': 'abnormal',
  59. 'sum(session)': 1,
  60. },
  61. {
  62. 'count_unique(user)': 1,
  63. id: '6',
  64. release: '2',
  65. 'session.status': 'errored',
  66. 'sum(session)': 452,
  67. },
  68. {
  69. 'count_unique(user)': 10,
  70. id: '7',
  71. release: '2',
  72. 'session.status': 'healthy',
  73. 'sum(session)': 5059,
  74. },
  75. ],
  76. meta: {
  77. 'count_unique(user)': 'integer',
  78. release: 'string',
  79. 'session.status': 'string',
  80. 'sum(session)': 'integer',
  81. },
  82. });
  83. });
  84. it('adds derived metric fields', () => {
  85. expect(
  86. transformSessionsResponseToTable(TestStubs.SessionUserCountByStatusByRelease(), {
  87. ...widgetQuery,
  88. aggregates: ['count_unique(user)', 'sum(session)', 'count_crashed(session)'],
  89. })
  90. ).toEqual({
  91. data: [
  92. {
  93. 'count_crashed(session)': 34,
  94. 'count_unique(user)': 1,
  95. id: '0',
  96. release: '1',
  97. 'session.status': 'crashed',
  98. 'sum(session)': 34,
  99. },
  100. {
  101. 'count_crashed(session)': 0,
  102. 'count_unique(user)': 1,
  103. id: '1',
  104. release: '1',
  105. 'session.status': 'abnormal',
  106. 'sum(session)': 1,
  107. },
  108. {
  109. 'count_crashed(session)': 0,
  110. 'count_unique(user)': 2,
  111. id: '2',
  112. release: '1',
  113. 'session.status': 'errored',
  114. 'sum(session)': 451,
  115. },
  116. {
  117. 'count_crashed(session)': 0,
  118. 'count_unique(user)': 3,
  119. id: '3',
  120. release: '1',
  121. 'session.status': 'healthy',
  122. 'sum(session)': 5058,
  123. },
  124. {
  125. 'count_crashed(session)': 35,
  126. 'count_unique(user)': 2,
  127. id: '4',
  128. release: '2',
  129. 'session.status': 'crashed',
  130. 'sum(session)': 35,
  131. },
  132. {
  133. 'count_crashed(session)': 0,
  134. 'count_unique(user)': 1,
  135. id: '5',
  136. release: '2',
  137. 'session.status': 'abnormal',
  138. 'sum(session)': 1,
  139. },
  140. {
  141. 'count_crashed(session)': 0,
  142. 'count_unique(user)': 1,
  143. id: '6',
  144. release: '2',
  145. 'session.status': 'errored',
  146. 'sum(session)': 452,
  147. },
  148. {
  149. 'count_crashed(session)': 0,
  150. 'count_unique(user)': 10,
  151. id: '7',
  152. release: '2',
  153. 'session.status': 'healthy',
  154. 'sum(session)': 5059,
  155. },
  156. ],
  157. meta: {
  158. 'count_crashed(session)': 'integer',
  159. 'count_unique(user)': 'integer',
  160. release: 'string',
  161. 'session.status': 'string',
  162. 'sum(session)': 'integer',
  163. },
  164. });
  165. });
  166. it('strips away injected fields', () => {
  167. expect(
  168. transformSessionsResponseToTable(TestStubs.SessionUserCountByStatusByRelease(), {
  169. ...widgetQuery,
  170. aggregates: ['count_unique(user)', 'count_crashed(session)'],
  171. })
  172. ).toEqual({
  173. data: [
  174. {
  175. 'count_crashed(session)': 34,
  176. 'count_unique(user)': 1,
  177. id: '0',
  178. release: '1',
  179. 'session.status': 'crashed',
  180. },
  181. {
  182. 'count_crashed(session)': 0,
  183. 'count_unique(user)': 1,
  184. id: '1',
  185. release: '1',
  186. 'session.status': 'abnormal',
  187. },
  188. {
  189. 'count_crashed(session)': 0,
  190. 'count_unique(user)': 2,
  191. id: '2',
  192. release: '1',
  193. 'session.status': 'errored',
  194. },
  195. {
  196. 'count_crashed(session)': 0,
  197. 'count_unique(user)': 3,
  198. id: '3',
  199. release: '1',
  200. 'session.status': 'healthy',
  201. },
  202. {
  203. 'count_crashed(session)': 35,
  204. 'count_unique(user)': 2,
  205. id: '4',
  206. release: '2',
  207. 'session.status': 'crashed',
  208. },
  209. {
  210. 'count_crashed(session)': 0,
  211. 'count_unique(user)': 1,
  212. id: '5',
  213. release: '2',
  214. 'session.status': 'abnormal',
  215. },
  216. {
  217. 'count_crashed(session)': 0,
  218. 'count_unique(user)': 1,
  219. id: '6',
  220. release: '2',
  221. 'session.status': 'errored',
  222. },
  223. {
  224. 'count_crashed(session)': 0,
  225. 'count_unique(user)': 10,
  226. id: '7',
  227. release: '2',
  228. 'session.status': 'healthy',
  229. },
  230. ],
  231. meta: {
  232. 'count_crashed(session)': 'integer',
  233. 'count_unique(user)': 'integer',
  234. release: 'string',
  235. 'session.status': 'string',
  236. },
  237. });
  238. });
  239. });