utils.spec.tsx 2.8 KB

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