releasesRequest.spec.tsx 23 KB

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