releasesRequest.spec.tsx 23 KB

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