fields.spec.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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:count_abnormal': {
  41. label: 'count_abnormal(…)',
  42. value: {
  43. kind: 'function',
  44. meta: {
  45. name: 'count_abnormal',
  46. parameters: [
  47. {
  48. columnTypes: ['integer', 'string'],
  49. defaultValue: 'session',
  50. kind: 'column',
  51. required: true,
  52. },
  53. ],
  54. },
  55. },
  56. },
  57. 'function:count_crashed': {
  58. label: 'count_crashed(…)',
  59. value: {
  60. kind: 'function',
  61. meta: {
  62. name: 'count_crashed',
  63. parameters: [
  64. {
  65. columnTypes: ['integer', 'string'],
  66. defaultValue: 'session',
  67. kind: 'column',
  68. required: true,
  69. },
  70. ],
  71. },
  72. },
  73. },
  74. 'function:count_errored': {
  75. label: 'count_errored(…)',
  76. value: {
  77. kind: 'function',
  78. meta: {
  79. name: 'count_errored',
  80. parameters: [
  81. {
  82. columnTypes: ['integer', 'string'],
  83. defaultValue: 'session',
  84. kind: 'column',
  85. required: true,
  86. },
  87. ],
  88. },
  89. },
  90. },
  91. 'function:count_healthy': {
  92. label: 'count_healthy(…)',
  93. value: {
  94. kind: 'function',
  95. meta: {
  96. name: 'count_healthy',
  97. parameters: [
  98. {
  99. columnTypes: ['integer', 'string'],
  100. defaultValue: 'session',
  101. kind: 'column',
  102. required: true,
  103. },
  104. ],
  105. },
  106. },
  107. },
  108. 'function:count_unique': {
  109. label: 'count_unique(…)',
  110. value: {
  111. kind: 'function',
  112. meta: {
  113. name: 'count_unique',
  114. parameters: [
  115. {
  116. columnTypes: ['string'],
  117. defaultValue: 'user',
  118. kind: 'column',
  119. required: true,
  120. },
  121. ],
  122. },
  123. },
  124. },
  125. 'function:crash_free_rate': {
  126. label: 'crash_free_rate(…)',
  127. value: {
  128. kind: 'function',
  129. meta: {
  130. name: 'crash_free_rate',
  131. parameters: [
  132. {
  133. columnTypes: ['integer', 'string'],
  134. defaultValue: 'session',
  135. kind: 'column',
  136. required: true,
  137. },
  138. ],
  139. },
  140. },
  141. },
  142. 'function:crash_rate': {
  143. label: 'crash_rate(…)',
  144. value: {
  145. kind: 'function',
  146. meta: {
  147. name: 'crash_rate',
  148. parameters: [
  149. {
  150. columnTypes: ['integer', 'string'],
  151. defaultValue: 'session',
  152. kind: 'column',
  153. required: true,
  154. },
  155. ],
  156. },
  157. },
  158. },
  159. 'function:sum': {
  160. label: 'sum(…)',
  161. value: {
  162. kind: 'function',
  163. meta: {
  164. name: 'sum',
  165. parameters: [
  166. {
  167. columnTypes: ['integer'],
  168. defaultValue: 'session',
  169. kind: 'column',
  170. required: true,
  171. },
  172. ],
  173. },
  174. },
  175. },
  176. 'field:environment': {
  177. label: 'environment',
  178. value: {
  179. kind: 'field',
  180. meta: {
  181. dataType: 'string',
  182. name: 'environment',
  183. },
  184. },
  185. },
  186. 'field:release': {
  187. label: 'release',
  188. value: {
  189. kind: 'field',
  190. meta: {
  191. dataType: 'string',
  192. name: 'release',
  193. },
  194. },
  195. },
  196. });
  197. });
  198. });