utils.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import type {TagValue} from 'sentry/types/group';
  2. import {mergeAndSortTagValues} from 'sentry/views/issueDetails/utils';
  3. import {getTabs} from './utils';
  4. describe('getTabs', () => {
  5. it('displays the correct list of tabs', () => {
  6. expect(getTabs().filter(tab => !tab[1].hidden)).toEqual([
  7. [
  8. 'is:unresolved issue.priority:[high, medium]',
  9. expect.objectContaining({name: 'Prioritized'}),
  10. ],
  11. [
  12. 'is:unresolved is:for_review assigned_or_suggested:[me, my_teams, none]',
  13. expect.objectContaining({name: 'For Review'}),
  14. ],
  15. ['is:regressed', expect.objectContaining({name: 'Regressed'})],
  16. ['is:escalating', expect.objectContaining({name: 'Escalating'})],
  17. ['is:archived', expect.objectContaining({name: 'Archived'})],
  18. ['is:reprocessing', expect.objectContaining({name: 'Reprocessing'})],
  19. ]);
  20. });
  21. it('merges and sorts tagValues by count correctly', () => {
  22. const defaultTagValueFields = {
  23. email: '',
  24. id: '',
  25. name: '',
  26. username: '',
  27. ip_address: '',
  28. };
  29. const tagValues1: TagValue[] = [
  30. {
  31. value: 'a',
  32. count: 1,
  33. lastSeen: '2021-01-01T00:00:00',
  34. firstSeen: '2021-01-01T00:00:00',
  35. ...defaultTagValueFields,
  36. },
  37. {
  38. value: 'b',
  39. count: 1,
  40. lastSeen: '2021-01-02T00:00:00',
  41. firstSeen: '2021-01-02T00:00:00',
  42. ...defaultTagValueFields,
  43. },
  44. ];
  45. const tagValues2: TagValue[] = [
  46. {
  47. value: 'a',
  48. count: 1,
  49. lastSeen: '2021-01-01T00:00:00',
  50. firstSeen: '2021-01-01T00:00:00',
  51. ...defaultTagValueFields,
  52. },
  53. {
  54. value: 'c',
  55. count: 3,
  56. lastSeen: '2021-01-03T00:00:00',
  57. firstSeen: '2021-01-03T00:00:00',
  58. ...defaultTagValueFields,
  59. },
  60. ];
  61. const sortByCount = mergeAndSortTagValues(tagValues1, tagValues2, 'count');
  62. expect(sortByCount).toEqual([
  63. {
  64. value: 'c',
  65. count: 3,
  66. lastSeen: '2021-01-03T00:00:00',
  67. firstSeen: '2021-01-03T00:00:00',
  68. ...defaultTagValueFields,
  69. },
  70. {
  71. value: 'a',
  72. count: 2,
  73. lastSeen: '2021-01-01T00:00:00',
  74. firstSeen: '2021-01-01T00:00:00',
  75. ...defaultTagValueFields,
  76. },
  77. {
  78. value: 'b',
  79. count: 1,
  80. lastSeen: '2021-01-02T00:00:00',
  81. firstSeen: '2021-01-02T00:00:00',
  82. ...defaultTagValueFields,
  83. },
  84. ]);
  85. });
  86. it('merges and sorts tagValues by lastSeen correctly', () => {
  87. const defaultTagValueFields = {
  88. email: '',
  89. id: '',
  90. name: '',
  91. username: '',
  92. ip_address: '',
  93. };
  94. const tagValues1: TagValue[] = [
  95. {
  96. value: 'a',
  97. count: 1,
  98. lastSeen: '2021-01-01T00:00:00',
  99. firstSeen: '2021-01-01T00:00:00',
  100. ...defaultTagValueFields,
  101. },
  102. {
  103. value: 'b',
  104. count: 1,
  105. lastSeen: '2021-01-02T00:00:00',
  106. firstSeen: '2021-01-02T00:00:00',
  107. ...defaultTagValueFields,
  108. },
  109. ];
  110. const tagValues2: TagValue[] = [
  111. {
  112. value: 'a',
  113. count: 1,
  114. lastSeen: '2021-01-01T00:00:00',
  115. firstSeen: '2021-01-01T00:00:00',
  116. ...defaultTagValueFields,
  117. },
  118. {
  119. value: 'c',
  120. count: 3,
  121. lastSeen: '2021-01-03T00:00:00',
  122. firstSeen: '2021-01-03T00:00:00',
  123. ...defaultTagValueFields,
  124. },
  125. ];
  126. const sortByLastSeen = mergeAndSortTagValues(tagValues1, tagValues2, 'lastSeen');
  127. expect(sortByLastSeen).toEqual([
  128. {
  129. value: 'c',
  130. count: 3,
  131. lastSeen: '2021-01-03T00:00:00',
  132. firstSeen: '2021-01-03T00:00:00',
  133. ...defaultTagValueFields,
  134. },
  135. {
  136. value: 'b',
  137. count: 1,
  138. lastSeen: '2021-01-02T00:00:00',
  139. firstSeen: '2021-01-02T00:00:00',
  140. ...defaultTagValueFields,
  141. },
  142. {
  143. value: 'a',
  144. count: 2,
  145. lastSeen: '2021-01-01T00:00:00',
  146. firstSeen: '2021-01-01T00:00:00',
  147. ...defaultTagValueFields,
  148. },
  149. ]);
  150. });
  151. });