utils.spec.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {ReleaseFixture} from 'sentry-fixture/release';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {lightTheme} from 'sentry/utils/theme';
  4. import {
  5. generateReleaseMarkLines,
  6. releaseMarkLinesLabels,
  7. } from 'sentry/views/releases/detail/utils';
  8. describe('releases/detail/utils', () => {
  9. describe('generateReleaseMarkLines', () => {
  10. const {created, adopted, unadopted} = releaseMarkLinesLabels;
  11. const {router} = initializeOrg();
  12. const release = ReleaseFixture();
  13. const project = release.projects[0];
  14. it('generates "Created" markline', () => {
  15. const marklines = generateReleaseMarkLines(
  16. release,
  17. project,
  18. lightTheme,
  19. router.location
  20. );
  21. expect(marklines.map(markline => markline.seriesName)).toEqual([created]);
  22. });
  23. it('generates also Adoption marklines if exactly one env is selected', () => {
  24. const marklines = generateReleaseMarkLines(release, project, lightTheme, {
  25. ...router.location,
  26. query: {environment: 'prod'},
  27. });
  28. expect(marklines).toEqual([
  29. expect.objectContaining({
  30. seriesName: created,
  31. data: [
  32. {
  33. name: 1584925320000,
  34. value: null,
  35. },
  36. ],
  37. }),
  38. expect.objectContaining({
  39. seriesName: adopted,
  40. data: [
  41. {
  42. name: 1585011750000,
  43. value: null,
  44. },
  45. ],
  46. }),
  47. expect.objectContaining({
  48. seriesName: unadopted,
  49. data: [
  50. {
  51. name: 1585015350000,
  52. value: null,
  53. },
  54. ],
  55. }),
  56. ]);
  57. });
  58. it('does not generate Adoption marklines for non-mobile projects', () => {
  59. const marklines = generateReleaseMarkLines(
  60. {...release, projects: [{...release.projects[0], platform: 'javascript'}]},
  61. {...project, platform: 'javascript'},
  62. lightTheme,
  63. {
  64. ...router.location,
  65. query: {environment: 'prod'},
  66. }
  67. );
  68. expect(marklines.map(markline => markline.seriesName)).toEqual([created]);
  69. });
  70. it('shows only marklines that are in current time window', () => {
  71. const marklines = generateReleaseMarkLines(release, project, lightTheme, {
  72. ...router.location,
  73. query: {
  74. environment: 'prod',
  75. pageStart: '2020-03-24T01:00:30Z',
  76. pageEnd: '2020-03-24T01:03:30Z',
  77. },
  78. });
  79. expect(marklines.map(markline => markline.seriesName)).toEqual([adopted]);
  80. });
  81. it('does not generate out-of-bounds marklines on ancient/clamped releases', () => {
  82. const marklines = generateReleaseMarkLines(
  83. {...release, dateCreated: '2010-03-24T01:00:30Z'},
  84. project,
  85. lightTheme,
  86. router.location
  87. );
  88. expect(marklines).toEqual([]);
  89. });
  90. });
  91. });