releasesRequest.spec.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, waitFor} from 'sentry-test/reactTestingLibrary';
  3. import {HealthStatsPeriodOption} from 'sentry/types';
  4. import {ReleasesDisplayOption} from 'sentry/views/releases/list/releasesDisplayOptions';
  5. import ReleasesRequest from 'sentry/views/releases/list/releasesRequest';
  6. describe('ReleasesRequest', () => {
  7. const {organization, router} = initializeOrg();
  8. const projectId = 123;
  9. const selection = {
  10. projects: [projectId],
  11. environments: [],
  12. datetime: {
  13. period: '14d',
  14. start: null,
  15. end: null,
  16. utc: false,
  17. },
  18. };
  19. let requestForAutoHealthStatsPeriodSessionHistogram: jest.Mock;
  20. let requestForAutoTotalCountByProjectInPeriod: jest.Mock;
  21. let requestForAutoTotalCountByReleaseInPeriod: jest.Mock;
  22. beforeEach(() => {
  23. MockApiClient.addMockResponse({
  24. url: `/organizations/org-slug/sessions/`,
  25. body: TestStubs.SessionStatusCountByReleaseInPeriod(),
  26. match: [
  27. MockApiClient.matchQuery({
  28. query:
  29. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  30. interval: '1d',
  31. statsPeriod: '14d',
  32. project: [`${projectId}`],
  33. field: ['sum(session)'],
  34. groupBy: ['project', 'release', 'session.status'],
  35. }),
  36. ],
  37. });
  38. requestForAutoHealthStatsPeriodSessionHistogram = MockApiClient.addMockResponse({
  39. url: `/organizations/org-slug/sessions/`,
  40. body: TestStubs.SessionStatusCountByProjectInPeriod(),
  41. match: [
  42. MockApiClient.matchQuery({
  43. query: undefined,
  44. interval: '1d',
  45. statsPeriod: '14d',
  46. project: [`${projectId}`],
  47. field: ['sum(session)'],
  48. groupBy: ['project', 'session.status'],
  49. }),
  50. ],
  51. });
  52. requestForAutoTotalCountByProjectInPeriod = MockApiClient.addMockResponse({
  53. url: `/organizations/org-slug/sessions/`,
  54. body: TestStubs.SessionTotalCountByProjectIn24h(),
  55. match: [
  56. MockApiClient.matchQuery({
  57. query: undefined,
  58. interval: '1d',
  59. statsPeriod: '14d',
  60. project: [`${projectId}`],
  61. field: ['sum(session)'],
  62. groupBy: ['project'],
  63. }),
  64. ],
  65. });
  66. requestForAutoTotalCountByReleaseInPeriod = MockApiClient.addMockResponse({
  67. url: `/organizations/org-slug/sessions/`,
  68. body: TestStubs.SesssionTotalCountByReleaseIn24h(),
  69. match: [
  70. MockApiClient.matchQuery({
  71. query:
  72. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  73. interval: '1d',
  74. statsPeriod: '14d',
  75. project: [`${projectId}`],
  76. field: ['sum(session)'],
  77. groupBy: ['project', 'release'],
  78. }),
  79. ],
  80. });
  81. MockApiClient.addMockResponse({
  82. url: `/organizations/${organization.slug}/sessions/`,
  83. body: TestStubs.SesssionTotalCountByReleaseIn24h(),
  84. match: [
  85. MockApiClient.matchQuery({
  86. query:
  87. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  88. interval: '1h',
  89. statsPeriod: '24h',
  90. project: [`${projectId}`],
  91. field: ['sum(session)'],
  92. groupBy: ['project', 'release'],
  93. }),
  94. ],
  95. });
  96. MockApiClient.addMockResponse({
  97. url: `/organizations/org-slug/sessions/`,
  98. body: TestStubs.SessionTotalCountByProjectIn24h(),
  99. match: [
  100. MockApiClient.matchQuery({
  101. query: undefined,
  102. interval: '1h',
  103. statsPeriod: '24h',
  104. project: [`${projectId}`],
  105. field: ['sum(session)'],
  106. groupBy: ['project'],
  107. }),
  108. ],
  109. });
  110. MockApiClient.addMockResponse({
  111. url: `/organizations/org-slug/sessions/`,
  112. body: TestStubs.SessionUserStatusCountByReleaseInPeriod(),
  113. match: [
  114. MockApiClient.matchQuery({
  115. query:
  116. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  117. interval: '1d',
  118. statsPeriod: '14d',
  119. project: [`${projectId}`],
  120. field: ['count_unique(user)', 'sum(session)'],
  121. groupBy: ['project', 'release', 'session.status'],
  122. }),
  123. ],
  124. });
  125. MockApiClient.addMockResponse({
  126. url: `/organizations/${organization.slug}/sessions/`,
  127. body: TestStubs.UserTotalCountByReleaseIn24h(),
  128. match: [
  129. MockApiClient.matchQuery({
  130. query:
  131. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  132. interval: '1h',
  133. statsPeriod: '24h',
  134. project: [`${projectId}`],
  135. field: ['count_unique(user)'],
  136. groupBy: ['project', 'release'],
  137. }),
  138. ],
  139. });
  140. MockApiClient.addMockResponse({
  141. url: `/organizations/org-slug/sessions/`,
  142. body: TestStubs.UserTotalCountByProjectIn24h(),
  143. match: [
  144. MockApiClient.matchQuery({
  145. query: undefined,
  146. interval: '1h',
  147. statsPeriod: '24h',
  148. project: [`${projectId}`],
  149. field: ['count_unique(user)'],
  150. groupBy: ['project'],
  151. }),
  152. ],
  153. });
  154. });
  155. it('calculates correct session health data', async () => {
  156. let healthData;
  157. render(
  158. <ReleasesRequest
  159. releases={[
  160. '7a82c130be9143361f20bc77252df783cf91e4fc',
  161. 'e102abb2c46e7fe8686441091005c12aed90da99',
  162. ]}
  163. organization={organization}
  164. location={{
  165. ...router.location,
  166. query: {
  167. project: [`${projectId}`],
  168. },
  169. }}
  170. display={[ReleasesDisplayOption.SESSIONS]}
  171. selection={selection}
  172. >
  173. {({getHealthData}) => {
  174. healthData = getHealthData;
  175. return null;
  176. }}
  177. </ReleasesRequest>
  178. );
  179. await waitFor(() =>
  180. expect(
  181. healthData.getCrashCount(
  182. '7a82c130be9143361f20bc77252df783cf91e4fc',
  183. projectId,
  184. ReleasesDisplayOption.SESSIONS
  185. )
  186. ).toBe(492)
  187. );
  188. expect(
  189. healthData.getCrashFreeRate(
  190. '7a82c130be9143361f20bc77252df783cf91e4fc',
  191. projectId,
  192. ReleasesDisplayOption.SESSIONS
  193. )
  194. ).toBe(99.76);
  195. expect(
  196. healthData.get24hCountByRelease(
  197. '7a82c130be9143361f20bc77252df783cf91e4fc',
  198. projectId,
  199. ReleasesDisplayOption.SESSIONS
  200. )
  201. ).toBe(219826);
  202. expect(
  203. healthData.get24hCountByProject(projectId, ReleasesDisplayOption.SESSIONS)
  204. ).toBe(835965);
  205. expect(
  206. healthData.getTimeSeries(
  207. '7a82c130be9143361f20bc77252df783cf91e4fc',
  208. projectId,
  209. ReleasesDisplayOption.SESSIONS
  210. )
  211. ).toEqual([
  212. {
  213. data: [
  214. {name: 1615975200000, value: 0},
  215. {name: 1615978800000, value: 0},
  216. {name: 1615982400000, value: 0},
  217. {name: 1615986000000, value: 0},
  218. {name: 1615989600000, value: 0},
  219. {name: 1615993200000, value: 0},
  220. {name: 1615996800000, value: 0},
  221. {name: 1616000400000, value: 0},
  222. {name: 1616004000000, value: 0},
  223. {name: 1616007600000, value: 0},
  224. {name: 1616011200000, value: 0},
  225. {name: 1616014800000, value: 0},
  226. {name: 1616018400000, value: 0},
  227. {name: 1616022000000, value: 3444},
  228. {name: 1616025600000, value: 14912},
  229. {name: 1616029200000, value: 15649},
  230. {name: 1616032800000, value: 18019},
  231. {name: 1616036400000, value: 16726},
  232. {name: 1616040000000, value: 17540},
  233. {name: 1616043600000, value: 16970},
  234. {name: 1616047200000, value: 25015},
  235. {name: 1616050800000, value: 34686},
  236. {name: 1616054400000, value: 46434},
  237. {name: 1616058000000, value: 10431},
  238. ],
  239. seriesName: 'This Release',
  240. },
  241. {
  242. data: [
  243. {name: 1615975200000, value: 51284},
  244. {name: 1615978800000, value: 43820},
  245. {name: 1615982400000, value: 46981},
  246. {name: 1615986000000, value: 56929},
  247. {name: 1615989600000, value: 59999},
  248. {name: 1615993200000, value: 60476},
  249. {name: 1615996800000, value: 54145},
  250. {name: 1616000400000, value: 52642},
  251. {name: 1616004000000, value: 42917},
  252. {name: 1616007600000, value: 35787},
  253. {name: 1616011200000, value: 35036},
  254. {name: 1616014800000, value: 29287},
  255. {name: 1616018400000, value: 24815},
  256. {name: 1616022000000, value: 19815},
  257. {name: 1616025600000, value: 16334},
  258. {name: 1616029200000, value: 16415},
  259. {name: 1616032800000, value: 18961},
  260. {name: 1616036400000, value: 17512},
  261. {name: 1616040000000, value: 18149},
  262. {name: 1616043600000, value: 17585},
  263. {name: 1616047200000, value: 25725},
  264. {name: 1616050800000, value: 36365},
  265. {name: 1616054400000, value: 48104},
  266. {name: 1616058000000, value: 6882},
  267. ],
  268. seriesName: 'Total Project',
  269. z: 0,
  270. },
  271. ]);
  272. expect(
  273. healthData.getAdoption(
  274. '7a82c130be9143361f20bc77252df783cf91e4fc',
  275. projectId,
  276. ReleasesDisplayOption.SESSIONS
  277. )
  278. ).toBe(26.29607698886915);
  279. expect(
  280. healthData.getCrashCount(
  281. 'e102abb2c46e7fe8686441091005c12aed90da99',
  282. projectId,
  283. ReleasesDisplayOption.SESSIONS
  284. )
  285. ).toBe(5);
  286. expect(
  287. healthData.getCrashFreeRate(
  288. 'e102abb2c46e7fe8686441091005c12aed90da99',
  289. projectId,
  290. ReleasesDisplayOption.SESSIONS
  291. )
  292. ).toBe(99.921);
  293. expect(
  294. healthData.get24hCountByRelease(
  295. 'e102abb2c46e7fe8686441091005c12aed90da99',
  296. projectId,
  297. ReleasesDisplayOption.SESSIONS
  298. )
  299. ).toBe(6320);
  300. expect(
  301. healthData.get24hCountByProject(projectId, ReleasesDisplayOption.SESSIONS)
  302. ).toBe(835965);
  303. expect(
  304. healthData.getTimeSeries(
  305. 'e102abb2c46e7fe8686441091005c12aed90da99',
  306. projectId,
  307. ReleasesDisplayOption.SESSIONS
  308. )
  309. ).toEqual([
  310. {
  311. data: [
  312. {name: 1615975200000, value: 0},
  313. {name: 1615978800000, value: 0},
  314. {name: 1615982400000, value: 0},
  315. {name: 1615986000000, value: 0},
  316. {name: 1615989600000, value: 0},
  317. {name: 1615993200000, value: 0},
  318. {name: 1615996800000, value: 0},
  319. {name: 1616000400000, value: 0},
  320. {name: 1616004000000, value: 0},
  321. {name: 1616007600000, value: 0},
  322. {name: 1616011200000, value: 0},
  323. {name: 1616014800000, value: 0},
  324. {name: 1616018400000, value: 0},
  325. {name: 1616022000000, value: 5809},
  326. {name: 1616025600000, value: 400},
  327. {name: 1616029200000, value: 22},
  328. {name: 1616032800000, value: 26},
  329. {name: 1616036400000, value: 12},
  330. {name: 1616040000000, value: 19},
  331. {name: 1616043600000, value: 8},
  332. {name: 1616047200000, value: 0},
  333. {name: 1616050800000, value: 19},
  334. {name: 1616054400000, value: 5},
  335. {name: 1616058000000, value: 0},
  336. ],
  337. seriesName: 'This Release',
  338. },
  339. {
  340. data: [
  341. {name: 1615975200000, value: 51284},
  342. {name: 1615978800000, value: 43820},
  343. {name: 1615982400000, value: 46981},
  344. {name: 1615986000000, value: 56929},
  345. {name: 1615989600000, value: 59999},
  346. {name: 1615993200000, value: 60476},
  347. {name: 1615996800000, value: 54145},
  348. {name: 1616000400000, value: 52642},
  349. {name: 1616004000000, value: 42917},
  350. {name: 1616007600000, value: 35787},
  351. {name: 1616011200000, value: 35036},
  352. {name: 1616014800000, value: 29287},
  353. {name: 1616018400000, value: 24815},
  354. {name: 1616022000000, value: 19815},
  355. {name: 1616025600000, value: 16334},
  356. {name: 1616029200000, value: 16415},
  357. {name: 1616032800000, value: 18961},
  358. {name: 1616036400000, value: 17512},
  359. {name: 1616040000000, value: 18149},
  360. {name: 1616043600000, value: 17585},
  361. {name: 1616047200000, value: 25725},
  362. {name: 1616050800000, value: 36365},
  363. {name: 1616054400000, value: 48104},
  364. {name: 1616058000000, value: 6882},
  365. ],
  366. seriesName: 'Total Project',
  367. z: 0,
  368. },
  369. ]);
  370. expect(
  371. healthData.getAdoption(
  372. 'e102abb2c46e7fe8686441091005c12aed90da99',
  373. projectId,
  374. ReleasesDisplayOption.SESSIONS
  375. )
  376. ).toBe(0.7560125124855706);
  377. expect(requestForAutoHealthStatsPeriodSessionHistogram).toHaveBeenCalledTimes(0);
  378. });
  379. it('calculates correct user health data', async () => {
  380. let healthData;
  381. render(
  382. <ReleasesRequest
  383. releases={[
  384. '7a82c130be9143361f20bc77252df783cf91e4fc',
  385. 'e102abb2c46e7fe8686441091005c12aed90da99',
  386. ]}
  387. organization={organization}
  388. location={{
  389. ...router.location,
  390. query: {
  391. project: [`${projectId}`],
  392. },
  393. }}
  394. display={[ReleasesDisplayOption.USERS]}
  395. selection={selection}
  396. >
  397. {({getHealthData}) => {
  398. healthData = getHealthData;
  399. return null;
  400. }}
  401. </ReleasesRequest>
  402. );
  403. await waitFor(() =>
  404. expect(
  405. healthData.getCrashCount(
  406. '7a82c130be9143361f20bc77252df783cf91e4fc',
  407. projectId,
  408. ReleasesDisplayOption.SESSIONS
  409. )
  410. ).toBe(492)
  411. );
  412. expect(
  413. healthData.getCrashFreeRate(
  414. '7a82c130be9143361f20bc77252df783cf91e4fc',
  415. projectId,
  416. ReleasesDisplayOption.USERS
  417. )
  418. ).toBe(99.908);
  419. expect(
  420. healthData.get24hCountByRelease(
  421. '7a82c130be9143361f20bc77252df783cf91e4fc',
  422. projectId,
  423. ReleasesDisplayOption.USERS
  424. )
  425. ).toBe(56826);
  426. expect(healthData.get24hCountByProject(projectId, ReleasesDisplayOption.USERS)).toBe(
  427. 140965
  428. );
  429. expect(
  430. healthData.getTimeSeries(
  431. '7a82c130be9143361f20bc77252df783cf91e4fc',
  432. projectId,
  433. ReleasesDisplayOption.USERS
  434. )
  435. ).toEqual([
  436. {
  437. data: [
  438. {name: 1615975200000, value: 0},
  439. {name: 1615978800000, value: 0},
  440. {name: 1615982400000, value: 0},
  441. {name: 1615986000000, value: 0},
  442. {name: 1615989600000, value: 0},
  443. {name: 1615993200000, value: 0},
  444. {name: 1615996800000, value: 0},
  445. {name: 1616000400000, value: 0},
  446. {name: 1616004000000, value: 0},
  447. {name: 1616007600000, value: 0},
  448. {name: 1616011200000, value: 0},
  449. {name: 1616014800000, value: 0},
  450. {name: 1616018400000, value: 0},
  451. {name: 1616022000000, value: 444},
  452. {name: 1616025600000, value: 4912},
  453. {name: 1616029200000, value: 5649},
  454. {name: 1616032800000, value: 8019},
  455. {name: 1616036400000, value: 6726},
  456. {name: 1616040000000, value: 7540},
  457. {name: 1616043600000, value: 6970},
  458. {name: 1616047200000, value: 5015},
  459. {name: 1616050800000, value: 4686},
  460. {name: 1616054400000, value: 6434},
  461. {name: 1616058000000, value: 431},
  462. ],
  463. seriesName: 'This Release',
  464. },
  465. {
  466. data: [
  467. {name: 1615975200000, value: 1284},
  468. {name: 1615978800000, value: 3820},
  469. {name: 1615982400000, value: 6981},
  470. {name: 1615986000000, value: 6929},
  471. {name: 1615989600000, value: 9999},
  472. {name: 1615993200000, value: 1476},
  473. {name: 1615996800000, value: 4145},
  474. {name: 1616000400000, value: 2642},
  475. {name: 1616004000000, value: 2917},
  476. {name: 1616007600000, value: 5787},
  477. {name: 1616011200000, value: 5036},
  478. {name: 1616014800000, value: 9287},
  479. {name: 1616018400000, value: 4815},
  480. {name: 1616022000000, value: 9815},
  481. {name: 1616025600000, value: 6334},
  482. {name: 1616029200000, value: 6415},
  483. {name: 1616032800000, value: 8961},
  484. {name: 1616036400000, value: 7512},
  485. {name: 1616040000000, value: 8149},
  486. {name: 1616043600000, value: 7585},
  487. {name: 1616047200000, value: 5725},
  488. {name: 1616050800000, value: 6365},
  489. {name: 1616054400000, value: 8104},
  490. {name: 1616058000000, value: 882},
  491. ],
  492. seriesName: 'Total Project',
  493. z: 0,
  494. },
  495. ]);
  496. expect(
  497. healthData.getAdoption(
  498. '7a82c130be9143361f20bc77252df783cf91e4fc',
  499. projectId,
  500. ReleasesDisplayOption.USERS
  501. )
  502. ).toBe(40.31213421771362);
  503. expect(
  504. healthData.getCrashCount(
  505. 'e102abb2c46e7fe8686441091005c12aed90da99',
  506. projectId,
  507. ReleasesDisplayOption.SESSIONS
  508. )
  509. ).toBe(5);
  510. expect(
  511. healthData.getCrashFreeRate(
  512. 'e102abb2c46e7fe8686441091005c12aed90da99',
  513. projectId,
  514. ReleasesDisplayOption.USERS
  515. )
  516. ).toBe(99.87);
  517. expect(
  518. healthData.get24hCountByRelease(
  519. 'e102abb2c46e7fe8686441091005c12aed90da99',
  520. projectId,
  521. ReleasesDisplayOption.USERS
  522. )
  523. ).toBe(850);
  524. expect(healthData.get24hCountByProject(projectId, ReleasesDisplayOption.USERS)).toBe(
  525. 140965
  526. );
  527. expect(
  528. healthData.getTimeSeries(
  529. 'e102abb2c46e7fe8686441091005c12aed90da99',
  530. projectId,
  531. ReleasesDisplayOption.USERS
  532. )
  533. ).toEqual([
  534. {
  535. data: [
  536. {name: 1615975200000, value: 0},
  537. {name: 1615978800000, value: 0},
  538. {name: 1615982400000, value: 0},
  539. {name: 1615986000000, value: 0},
  540. {name: 1615989600000, value: 0},
  541. {name: 1615993200000, value: 0},
  542. {name: 1615996800000, value: 0},
  543. {name: 1616000400000, value: 0},
  544. {name: 1616004000000, value: 0},
  545. {name: 1616007600000, value: 0},
  546. {name: 1616011200000, value: 0},
  547. {name: 1616014800000, value: 0},
  548. {name: 1616018400000, value: 0},
  549. {name: 1616022000000, value: 809},
  550. {name: 1616025600000, value: 0},
  551. {name: 1616029200000, value: 2},
  552. {name: 1616032800000, value: 6},
  553. {name: 1616036400000, value: 2},
  554. {name: 1616040000000, value: 9},
  555. {name: 1616043600000, value: 8},
  556. {name: 1616047200000, value: 0},
  557. {name: 1616050800000, value: 9},
  558. {name: 1616054400000, value: 5},
  559. {name: 1616058000000, value: 0},
  560. ],
  561. seriesName: 'This Release',
  562. },
  563. {
  564. data: [
  565. {name: 1615975200000, value: 1284},
  566. {name: 1615978800000, value: 3820},
  567. {name: 1615982400000, value: 6981},
  568. {name: 1615986000000, value: 6929},
  569. {name: 1615989600000, value: 9999},
  570. {name: 1615993200000, value: 1476},
  571. {name: 1615996800000, value: 4145},
  572. {name: 1616000400000, value: 2642},
  573. {name: 1616004000000, value: 2917},
  574. {name: 1616007600000, value: 5787},
  575. {name: 1616011200000, value: 5036},
  576. {name: 1616014800000, value: 9287},
  577. {name: 1616018400000, value: 4815},
  578. {name: 1616022000000, value: 9815},
  579. {name: 1616025600000, value: 6334},
  580. {name: 1616029200000, value: 6415},
  581. {name: 1616032800000, value: 8961},
  582. {name: 1616036400000, value: 7512},
  583. {name: 1616040000000, value: 8149},
  584. {name: 1616043600000, value: 7585},
  585. {name: 1616047200000, value: 5725},
  586. {name: 1616050800000, value: 6365},
  587. {name: 1616054400000, value: 8104},
  588. {name: 1616058000000, value: 882},
  589. ],
  590. seriesName: 'Total Project',
  591. z: 0,
  592. },
  593. ]);
  594. expect(
  595. healthData.getAdoption(
  596. 'e102abb2c46e7fe8686441091005c12aed90da99',
  597. projectId,
  598. ReleasesDisplayOption.USERS
  599. )
  600. ).toBe(0.6029865569467598);
  601. });
  602. it('calculates correct session count histogram (auto period)', async () => {
  603. let healthData;
  604. render(
  605. <ReleasesRequest
  606. releases={[
  607. '7a82c130be9143361f20bc77252df783cf91e4fc',
  608. 'e102abb2c46e7fe8686441091005c12aed90da99',
  609. ]}
  610. organization={organization}
  611. location={{
  612. ...router.location,
  613. query: {
  614. project: [`${projectId}`],
  615. },
  616. }}
  617. display={[ReleasesDisplayOption.SESSIONS]}
  618. selection={selection}
  619. healthStatsPeriod={HealthStatsPeriodOption.AUTO}
  620. >
  621. {({getHealthData}) => {
  622. healthData = getHealthData;
  623. return null;
  624. }}
  625. </ReleasesRequest>
  626. );
  627. await waitFor(() =>
  628. expect(
  629. healthData.getAdoption(
  630. '7a82c130be9143361f20bc77252df783cf91e4fc',
  631. projectId,
  632. ReleasesDisplayOption.SESSIONS
  633. )
  634. ).toBe(26.29607698886915)
  635. );
  636. expect(
  637. healthData.getTimeSeries(
  638. '7a82c130be9143361f20bc77252df783cf91e4fc',
  639. projectId,
  640. ReleasesDisplayOption.SESSIONS
  641. )
  642. ).toEqual([
  643. {
  644. data: [
  645. {name: 1614902400000, value: 0},
  646. {name: 1614988800000, value: 0},
  647. {name: 1615075200000, value: 0},
  648. {name: 1615161600000, value: 0},
  649. {name: 1615248000000, value: 0},
  650. {name: 1615334400000, value: 0},
  651. {name: 1615420800000, value: 0},
  652. {name: 1615507200000, value: 0},
  653. {name: 1615593600000, value: 0},
  654. {name: 1615680000000, value: 0},
  655. {name: 1615766400000, value: 0},
  656. {name: 1615852800000, value: 0},
  657. {name: 1615939200000, value: 3446},
  658. {name: 1616025600000, value: 201136},
  659. ],
  660. seriesName: 'This Release',
  661. },
  662. {
  663. data: [
  664. {name: 1614902400000, value: 0},
  665. {name: 1614988800000, value: 0},
  666. {name: 1615075200000, value: 0},
  667. {name: 1615161600000, value: 0},
  668. {name: 1615248000000, value: 0},
  669. {name: 1615334400000, value: 0},
  670. {name: 1615420800000, value: 0},
  671. {name: 1615507200000, value: 0},
  672. {name: 1615593600000, value: 0},
  673. {name: 1615680000000, value: 0},
  674. {name: 1615766400000, value: 0},
  675. {name: 1615852800000, value: 0},
  676. {name: 1615939200000, value: 9268},
  677. {name: 1616025600000, value: 1083},
  678. ],
  679. seriesName: 'Total Project',
  680. z: 0,
  681. },
  682. ]);
  683. expect(requestForAutoHealthStatsPeriodSessionHistogram).toHaveBeenCalledTimes(1);
  684. expect(requestForAutoTotalCountByProjectInPeriod).toHaveBeenCalledTimes(1);
  685. expect(requestForAutoTotalCountByReleaseInPeriod).toHaveBeenCalledTimes(1);
  686. });
  687. });