fields.spec.tsx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import {
  2. generateReleaseWidgetFieldOptions,
  3. SESSIONS_FIELDS,
  4. } from 'sentry/views/dashboardsV2/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:avg': {
  41. label: 'avg(…)',
  42. value: {
  43. kind: 'function',
  44. meta: {
  45. name: 'avg',
  46. parameters: [
  47. {
  48. columnTypes: ['duration'],
  49. defaultValue: 'session.duration',
  50. kind: 'column',
  51. required: true,
  52. },
  53. ],
  54. },
  55. },
  56. },
  57. 'function:count_abnormal': {
  58. label: 'count_abnormal(…)',
  59. value: {
  60. kind: 'function',
  61. meta: {
  62. name: 'count_abnormal',
  63. parameters: [
  64. {
  65. columnTypes: ['integer', 'string'],
  66. defaultValue: 'session',
  67. kind: 'column',
  68. required: true,
  69. },
  70. ],
  71. },
  72. },
  73. },
  74. 'function:count_crashed': {
  75. label: 'count_crashed(…)',
  76. value: {
  77. kind: 'function',
  78. meta: {
  79. name: 'count_crashed',
  80. parameters: [
  81. {
  82. columnTypes: ['integer', 'string'],
  83. defaultValue: 'session',
  84. kind: 'column',
  85. required: true,
  86. },
  87. ],
  88. },
  89. },
  90. },
  91. 'function:count_errored': {
  92. label: 'count_errored(…)',
  93. value: {
  94. kind: 'function',
  95. meta: {
  96. name: 'count_errored',
  97. parameters: [
  98. {
  99. columnTypes: ['integer', 'string'],
  100. defaultValue: 'session',
  101. kind: 'column',
  102. required: true,
  103. },
  104. ],
  105. },
  106. },
  107. },
  108. 'function:count_healthy': {
  109. label: 'count_healthy(…)',
  110. value: {
  111. kind: 'function',
  112. meta: {
  113. name: 'count_healthy',
  114. parameters: [
  115. {
  116. columnTypes: ['integer', 'string'],
  117. defaultValue: 'session',
  118. kind: 'column',
  119. required: true,
  120. },
  121. ],
  122. },
  123. },
  124. },
  125. 'function:count_unique': {
  126. label: 'count_unique(…)',
  127. value: {
  128. kind: 'function',
  129. meta: {
  130. name: 'count_unique',
  131. parameters: [
  132. {
  133. columnTypes: ['string'],
  134. defaultValue: 'user',
  135. kind: 'column',
  136. required: true,
  137. },
  138. ],
  139. },
  140. },
  141. },
  142. 'function:crash_free_rate': {
  143. label: 'crash_free_rate(…)',
  144. value: {
  145. kind: 'function',
  146. meta: {
  147. name: 'crash_free_rate',
  148. parameters: [
  149. {
  150. columnTypes: ['integer', 'string'],
  151. defaultValue: 'session',
  152. kind: 'column',
  153. required: true,
  154. },
  155. ],
  156. },
  157. },
  158. },
  159. 'function:crash_rate': {
  160. label: 'crash_rate(…)',
  161. value: {
  162. kind: 'function',
  163. meta: {
  164. name: 'crash_rate',
  165. parameters: [
  166. {
  167. columnTypes: ['integer', 'string'],
  168. defaultValue: 'session',
  169. kind: 'column',
  170. required: true,
  171. },
  172. ],
  173. },
  174. },
  175. },
  176. 'function:max': {
  177. label: 'max(…)',
  178. value: {
  179. kind: 'function',
  180. meta: {
  181. name: 'max',
  182. parameters: [
  183. {
  184. columnTypes: ['duration'],
  185. defaultValue: 'session.duration',
  186. kind: 'column',
  187. required: true,
  188. },
  189. ],
  190. },
  191. },
  192. },
  193. 'function:p50': {
  194. label: 'p50(…)',
  195. value: {
  196. kind: 'function',
  197. meta: {
  198. name: 'p50',
  199. parameters: [
  200. {
  201. columnTypes: ['duration'],
  202. defaultValue: 'session.duration',
  203. kind: 'column',
  204. required: true,
  205. },
  206. ],
  207. },
  208. },
  209. },
  210. 'function:p75': {
  211. label: 'p75(…)',
  212. value: {
  213. kind: 'function',
  214. meta: {
  215. name: 'p75',
  216. parameters: [
  217. {
  218. columnTypes: ['duration'],
  219. defaultValue: 'session.duration',
  220. kind: 'column',
  221. required: true,
  222. },
  223. ],
  224. },
  225. },
  226. },
  227. 'function:p95': {
  228. label: 'p95(…)',
  229. value: {
  230. kind: 'function',
  231. meta: {
  232. name: 'p95',
  233. parameters: [
  234. {
  235. columnTypes: ['duration'],
  236. defaultValue: 'session.duration',
  237. kind: 'column',
  238. required: true,
  239. },
  240. ],
  241. },
  242. },
  243. },
  244. 'function:p99': {
  245. label: 'p99(…)',
  246. value: {
  247. kind: 'function',
  248. meta: {
  249. name: 'p99',
  250. parameters: [
  251. {
  252. columnTypes: ['duration'],
  253. defaultValue: 'session.duration',
  254. kind: 'column',
  255. required: true,
  256. },
  257. ],
  258. },
  259. },
  260. },
  261. 'function:sum': {
  262. label: 'sum(…)',
  263. value: {
  264. kind: 'function',
  265. meta: {
  266. name: 'sum',
  267. parameters: [
  268. {
  269. columnTypes: ['integer'],
  270. defaultValue: 'session',
  271. kind: 'column',
  272. required: true,
  273. },
  274. ],
  275. },
  276. },
  277. },
  278. 'field:environment': {
  279. label: 'environment',
  280. value: {
  281. kind: 'field',
  282. meta: {
  283. dataType: 'string',
  284. name: 'environment',
  285. },
  286. },
  287. },
  288. 'field:release': {
  289. label: 'release',
  290. value: {
  291. kind: 'field',
  292. meta: {
  293. dataType: 'string',
  294. name: 'release',
  295. },
  296. },
  297. },
  298. });
  299. });
  300. });