fields.spec.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import {
  2. generateReleaseWidgetFieldOptions,
  3. SESSIONS_FIELDS,
  4. } from 'sentry/views/dashboards/widgetBuilder/releaseWidget/fields';
  5. describe('generateReleaseWidgetFieldOptions', function () {
  6. const fields = Object.values(SESSIONS_FIELDS);
  7. const tagKeys = ['release', 'environment'];
  8. it('generates correct field options', function () {
  9. expect(generateReleaseWidgetFieldOptions(fields, tagKeys)).toEqual({
  10. 'field:session': {
  11. label: 'session',
  12. value: {
  13. kind: 'metric',
  14. meta: {
  15. dataType: 'integer',
  16. name: 'session',
  17. },
  18. },
  19. },
  20. 'field:session.duration': {
  21. label: 'session.duration',
  22. value: {
  23. kind: 'metric',
  24. meta: {
  25. dataType: 'duration',
  26. name: 'session.duration',
  27. },
  28. },
  29. },
  30. 'field:user': {
  31. label: 'user',
  32. value: {
  33. kind: 'metric',
  34. meta: {
  35. dataType: 'string',
  36. name: 'user',
  37. },
  38. },
  39. },
  40. 'function:anr_rate': {
  41. label: 'anr_rate(…)',
  42. value: {
  43. kind: 'function',
  44. meta: {
  45. name: 'anr_rate',
  46. parameters: [],
  47. },
  48. },
  49. },
  50. 'function:count_abnormal': {
  51. label: 'count_abnormal(…)',
  52. value: {
  53. kind: 'function',
  54. meta: {
  55. name: 'count_abnormal',
  56. parameters: [
  57. {
  58. columnTypes: ['integer', 'string'],
  59. defaultValue: 'session',
  60. kind: 'column',
  61. required: true,
  62. },
  63. ],
  64. },
  65. },
  66. },
  67. 'function:count_crashed': {
  68. label: 'count_crashed(…)',
  69. value: {
  70. kind: 'function',
  71. meta: {
  72. name: 'count_crashed',
  73. parameters: [
  74. {
  75. columnTypes: ['integer', 'string'],
  76. defaultValue: 'session',
  77. kind: 'column',
  78. required: true,
  79. },
  80. ],
  81. },
  82. },
  83. },
  84. 'function:count_errored': {
  85. label: 'count_errored(…)',
  86. value: {
  87. kind: 'function',
  88. meta: {
  89. name: 'count_errored',
  90. parameters: [
  91. {
  92. columnTypes: ['integer', 'string'],
  93. defaultValue: 'session',
  94. kind: 'column',
  95. required: true,
  96. },
  97. ],
  98. },
  99. },
  100. },
  101. 'function:count_healthy': {
  102. label: 'count_healthy(…)',
  103. value: {
  104. kind: 'function',
  105. meta: {
  106. name: 'count_healthy',
  107. parameters: [
  108. {
  109. columnTypes: ['integer', 'string'],
  110. defaultValue: 'session',
  111. kind: 'column',
  112. required: true,
  113. },
  114. ],
  115. },
  116. },
  117. },
  118. 'function:count_unique': {
  119. label: 'count_unique(…)',
  120. value: {
  121. kind: 'function',
  122. meta: {
  123. name: 'count_unique',
  124. parameters: [
  125. {
  126. columnTypes: ['string'],
  127. defaultValue: 'user',
  128. kind: 'column',
  129. required: true,
  130. },
  131. ],
  132. },
  133. },
  134. },
  135. 'function:crash_free_rate': {
  136. label: 'crash_free_rate(…)',
  137. value: {
  138. kind: 'function',
  139. meta: {
  140. name: 'crash_free_rate',
  141. parameters: [
  142. {
  143. columnTypes: ['integer', 'string'],
  144. defaultValue: 'session',
  145. kind: 'column',
  146. required: true,
  147. },
  148. ],
  149. },
  150. },
  151. },
  152. 'function:crash_rate': {
  153. label: 'crash_rate(…)',
  154. value: {
  155. kind: 'function',
  156. meta: {
  157. name: 'crash_rate',
  158. parameters: [
  159. {
  160. columnTypes: ['integer', 'string'],
  161. defaultValue: 'session',
  162. kind: 'column',
  163. required: true,
  164. },
  165. ],
  166. },
  167. },
  168. },
  169. 'function:foreground_anr_rate': {
  170. label: 'foreground_anr_rate(…)',
  171. value: {
  172. kind: 'function',
  173. meta: {
  174. name: 'foreground_anr_rate',
  175. parameters: [],
  176. },
  177. },
  178. },
  179. 'function:sum': {
  180. label: 'sum(…)',
  181. value: {
  182. kind: 'function',
  183. meta: {
  184. name: 'sum',
  185. parameters: [
  186. {
  187. columnTypes: ['integer'],
  188. defaultValue: 'session',
  189. kind: 'column',
  190. required: true,
  191. },
  192. ],
  193. },
  194. },
  195. },
  196. 'field:environment': {
  197. label: 'environment',
  198. value: {
  199. kind: 'field',
  200. meta: {
  201. dataType: 'string',
  202. name: 'environment',
  203. },
  204. },
  205. },
  206. 'field:release': {
  207. label: 'release',
  208. value: {
  209. kind: 'field',
  210. meta: {
  211. dataType: 'string',
  212. name: 'release',
  213. },
  214. },
  215. },
  216. });
  217. });
  218. });