overview.spec.tsx 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. import merge from 'lodash/merge';
  2. import {GroupFixture} from 'sentry-fixture/group';
  3. import {GroupStatsFixture} from 'sentry-fixture/groupStats';
  4. import {LocationFixture} from 'sentry-fixture/locationFixture';
  5. import {MemberFixture} from 'sentry-fixture/member';
  6. import {OrganizationFixture} from 'sentry-fixture/organization';
  7. import {ProjectFixture} from 'sentry-fixture/project';
  8. import {SearchFixture} from 'sentry-fixture/search';
  9. import {TagsFixture} from 'sentry-fixture/tags';
  10. import {initializeOrg} from 'sentry-test/initializeOrg';
  11. import {
  12. act,
  13. render,
  14. screen,
  15. userEvent,
  16. waitFor,
  17. waitForElementToBeRemoved,
  18. } from 'sentry-test/reactTestingLibrary';
  19. import {textWithMarkupMatcher} from 'sentry-test/utils';
  20. import StreamGroup from 'sentry/components/stream/group';
  21. import ProjectsStore from 'sentry/stores/projectsStore';
  22. import TagStore from 'sentry/stores/tagStore';
  23. import {SavedSearchVisibility} from 'sentry/types';
  24. import {browserHistory} from 'sentry/utils/browserHistory';
  25. import localStorageWrapper from 'sentry/utils/localStorage';
  26. import * as parseLinkHeader from 'sentry/utils/parseLinkHeader';
  27. import IssueListWithStores, {IssueListOverview} from 'sentry/views/issueList/overview';
  28. // Mock <IssueListActions>
  29. jest.mock('sentry/views/issueList/actions', () => jest.fn(() => null));
  30. jest.mock('sentry/components/stream/group', () => jest.fn(() => null));
  31. const DEFAULT_LINKS_HEADER =
  32. '<http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443575731:0:1>; rel="previous"; results="false"; cursor="1443575731:0:1", ' +
  33. '<http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443575000:0:0>; rel="next"; results="true"; cursor="1443575000:0:0"';
  34. const project = ProjectFixture({
  35. id: '3559',
  36. name: 'Foo Project',
  37. slug: 'project-slug',
  38. firstEvent: new Date().toISOString(),
  39. });
  40. const {organization, router, routerContext} = initializeOrg({
  41. organization: {
  42. id: '1337',
  43. slug: 'org-slug',
  44. features: ['global-views'],
  45. access: [],
  46. },
  47. router: {
  48. location: {query: {}, search: ''},
  49. params: {},
  50. },
  51. project,
  52. });
  53. const routerProps = {
  54. params: router.params,
  55. location: router.location,
  56. };
  57. describe('IssueList', function () {
  58. let props;
  59. const tags = TagsFixture();
  60. const group = GroupFixture({project});
  61. const groupStats = GroupStatsFixture();
  62. const savedSearch = SearchFixture({
  63. id: '789',
  64. query: 'is:unresolved TypeError',
  65. sort: 'date',
  66. name: 'Unresolved TypeErrors',
  67. });
  68. let fetchTagsRequest: jest.Mock;
  69. let fetchMembersRequest: jest.Mock;
  70. const api = new MockApiClient();
  71. const parseLinkHeaderSpy = jest.spyOn(parseLinkHeader, 'default');
  72. beforeEach(function () {
  73. // The tests fail because we have a "component update was not wrapped in act" error.
  74. // It should be safe to ignore this error, but we should remove the mock once we move to react testing library
  75. // eslint-disable-next-line no-console
  76. jest.spyOn(console, 'error').mockImplementation(jest.fn());
  77. MockApiClient.addMockResponse({
  78. url: '/organizations/org-slug/issues/',
  79. body: [group],
  80. headers: {
  81. Link: DEFAULT_LINKS_HEADER,
  82. },
  83. });
  84. MockApiClient.addMockResponse({
  85. url: '/organizations/org-slug/issues-stats/',
  86. body: [groupStats],
  87. });
  88. MockApiClient.addMockResponse({
  89. url: '/organizations/org-slug/searches/',
  90. body: [savedSearch],
  91. });
  92. MockApiClient.addMockResponse({
  93. url: '/organizations/org-slug/recent-searches/',
  94. body: [],
  95. });
  96. MockApiClient.addMockResponse({
  97. url: '/organizations/org-slug/recent-searches/',
  98. method: 'POST',
  99. body: [],
  100. });
  101. MockApiClient.addMockResponse({
  102. url: '/organizations/org-slug/issues-count/',
  103. method: 'GET',
  104. body: [{}],
  105. });
  106. MockApiClient.addMockResponse({
  107. url: '/organizations/org-slug/processingissues/',
  108. method: 'GET',
  109. body: [
  110. {
  111. project: 'test-project',
  112. numIssues: 1,
  113. hasIssues: true,
  114. lastSeen: '2019-01-16T15:39:11.081Z',
  115. },
  116. ],
  117. });
  118. fetchTagsRequest = MockApiClient.addMockResponse({
  119. url: '/organizations/org-slug/tags/',
  120. method: 'GET',
  121. body: tags,
  122. });
  123. fetchMembersRequest = MockApiClient.addMockResponse({
  124. url: '/organizations/org-slug/users/',
  125. method: 'GET',
  126. body: [MemberFixture({projects: [project.slug]})],
  127. });
  128. MockApiClient.addMockResponse({
  129. url: '/organizations/org-slug/sent-first-event/',
  130. body: {sentFirstEvent: true},
  131. });
  132. MockApiClient.addMockResponse({
  133. url: '/organizations/org-slug/projects/',
  134. body: [project],
  135. });
  136. TagStore.init?.();
  137. props = {
  138. api,
  139. savedSearchLoading: false,
  140. savedSearches: [savedSearch],
  141. useOrgSavedSearches: true,
  142. projects: [parseInt(organization.projects[0].id, 10)],
  143. selection: {
  144. projects: [parseInt(organization.projects[0].id, 10)],
  145. environments: [],
  146. datetime: {period: '14d'},
  147. },
  148. location: {query: {query: 'is:unresolved'}, search: 'query=is:unresolved'},
  149. params: {},
  150. organization,
  151. tags: tags.reduce((acc, tag) => {
  152. acc[tag.key] = tag;
  153. return acc;
  154. }),
  155. };
  156. });
  157. afterEach(function () {
  158. jest.clearAllMocks();
  159. MockApiClient.clearMockResponses();
  160. localStorageWrapper.clear();
  161. });
  162. describe('withStores and feature flags', function () {
  163. let savedSearchesRequest: jest.Mock;
  164. let recentSearchesRequest: jest.Mock;
  165. let issuesRequest: jest.Mock;
  166. beforeEach(function () {
  167. jest.mocked(StreamGroup).mockClear();
  168. recentSearchesRequest = MockApiClient.addMockResponse({
  169. url: '/organizations/org-slug/recent-searches/',
  170. method: 'GET',
  171. body: [],
  172. });
  173. savedSearchesRequest = MockApiClient.addMockResponse({
  174. url: '/organizations/org-slug/searches/',
  175. body: [savedSearch],
  176. });
  177. issuesRequest = MockApiClient.addMockResponse({
  178. url: '/organizations/org-slug/issues/',
  179. body: [group],
  180. headers: {
  181. Link: DEFAULT_LINKS_HEADER,
  182. },
  183. });
  184. });
  185. it('loads group rows with default query (no pinned queries, async and no query in URL)', async function () {
  186. render(<IssueListWithStores {...routerProps} />, {
  187. context: routerContext,
  188. });
  189. // Loading saved searches
  190. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  191. expect(savedSearchesRequest).toHaveBeenCalledTimes(1);
  192. await userEvent.click(await screen.findByDisplayValue('is:unresolved'));
  193. // auxillary requests being made
  194. expect(recentSearchesRequest).toHaveBeenCalledTimes(1);
  195. expect(fetchTagsRequest).toHaveBeenCalledTimes(1);
  196. expect(fetchMembersRequest).toHaveBeenCalledTimes(1);
  197. // primary /issues/ request
  198. expect(issuesRequest).toHaveBeenCalledWith(
  199. expect.anything(),
  200. expect.objectContaining({
  201. // Should be called with default query
  202. data: expect.stringContaining('is%3Aunresolved'),
  203. })
  204. );
  205. expect(screen.getByDisplayValue('is:unresolved')).toBeInTheDocument();
  206. expect(screen.getByRole('button', {name: /custom search/i})).toBeInTheDocument();
  207. });
  208. it('loads with query in URL and pinned queries', async function () {
  209. savedSearchesRequest = MockApiClient.addMockResponse({
  210. url: '/organizations/org-slug/searches/',
  211. body: [
  212. savedSearch,
  213. SearchFixture({
  214. id: '123',
  215. name: 'My Pinned Search',
  216. isPinned: true,
  217. query: 'is:resolved',
  218. }),
  219. ],
  220. });
  221. const location = LocationFixture({query: {query: 'level:foo'}});
  222. render(<IssueListWithStores {...merge({}, routerProps, {location})} />, {
  223. context: routerContext,
  224. router: {location},
  225. });
  226. await waitFor(() => {
  227. // Main /issues/ request
  228. expect(issuesRequest).toHaveBeenCalledWith(
  229. expect.anything(),
  230. expect.objectContaining({
  231. // Should be called with default query
  232. data: expect.stringContaining('level%3Afoo'),
  233. })
  234. );
  235. });
  236. expect(screen.getByDisplayValue('level:foo')).toBeInTheDocument();
  237. // Tab shows "custom search"
  238. expect(screen.getByRole('button', {name: 'Custom Search'})).toBeInTheDocument();
  239. });
  240. it('loads with a pinned custom query', async function () {
  241. savedSearchesRequest = MockApiClient.addMockResponse({
  242. url: '/organizations/org-slug/searches/',
  243. body: [
  244. savedSearch,
  245. SearchFixture({
  246. id: '123',
  247. name: 'My Pinned Search',
  248. isPinned: true,
  249. isGlobal: false,
  250. query: 'is:resolved',
  251. }),
  252. ],
  253. });
  254. render(<IssueListWithStores {...routerProps} />, {
  255. context: routerContext,
  256. });
  257. await waitFor(() => {
  258. expect(issuesRequest).toHaveBeenCalledWith(
  259. expect.anything(),
  260. expect.objectContaining({
  261. // Should be called with default query
  262. data: expect.stringContaining('is%3Aresolved'),
  263. })
  264. );
  265. });
  266. expect(screen.getByDisplayValue('is:resolved')).toBeInTheDocument();
  267. // Organization saved search selector should have default saved search selected
  268. expect(screen.getByRole('button', {name: 'My Default Search'})).toBeInTheDocument();
  269. });
  270. it('shows archived tab', async function () {
  271. render(<IssueListWithStores {...routerProps} organization={{...organization}} />, {
  272. context: routerContext,
  273. });
  274. await waitFor(() => {
  275. expect(issuesRequest).toHaveBeenCalled();
  276. });
  277. expect(screen.getByDisplayValue('is:unresolved')).toBeInTheDocument();
  278. // TODO(workflow): remove this test when we remove the feature flag
  279. expect(screen.getByRole('tab', {name: 'Archived'})).toBeInTheDocument();
  280. });
  281. it('loads with a saved query', async function () {
  282. savedSearchesRequest = MockApiClient.addMockResponse({
  283. url: '/organizations/org-slug/searches/',
  284. body: [
  285. SearchFixture({
  286. id: '123',
  287. name: 'Assigned to Me',
  288. isPinned: false,
  289. isGlobal: true,
  290. query: 'assigned:me',
  291. sort: 'trends',
  292. type: 0,
  293. }),
  294. ],
  295. });
  296. const localRouter = {params: {searchId: '123'}};
  297. render(<IssueListWithStores {...merge({}, routerProps, localRouter)} />, {
  298. context: routerContext,
  299. router: localRouter,
  300. });
  301. await waitFor(() => {
  302. expect(issuesRequest).toHaveBeenCalledWith(
  303. expect.anything(),
  304. expect.objectContaining({
  305. // Should be called with default query
  306. data:
  307. expect.stringContaining('assigned%3Ame') &&
  308. expect.stringContaining('sort=trends'),
  309. })
  310. );
  311. });
  312. expect(screen.getByDisplayValue('assigned:me')).toBeInTheDocument();
  313. // Organization saved search selector should have default saved search selected
  314. expect(screen.getByRole('button', {name: 'Assigned to Me'})).toBeInTheDocument();
  315. });
  316. it('loads with a query in URL', async function () {
  317. savedSearchesRequest = MockApiClient.addMockResponse({
  318. url: '/organizations/org-slug/searches/',
  319. body: [
  320. SearchFixture({
  321. id: '123',
  322. name: 'Assigned to Me',
  323. isPinned: false,
  324. isGlobal: true,
  325. query: 'assigned:me',
  326. type: 0,
  327. }),
  328. ],
  329. });
  330. const localRouter = {location: {query: {query: 'level:error'}}};
  331. render(<IssueListWithStores {...merge({}, routerProps, localRouter)} />, {
  332. context: routerContext,
  333. });
  334. await waitFor(() => {
  335. expect(issuesRequest).toHaveBeenCalledWith(
  336. expect.anything(),
  337. expect.objectContaining({
  338. // Should be called with default query
  339. data: expect.stringContaining('level%3Aerror'),
  340. })
  341. );
  342. });
  343. expect(screen.getByDisplayValue('level:error')).toBeInTheDocument();
  344. // Organization saved search selector should have default saved search selected
  345. expect(screen.getByRole('button', {name: 'Custom Search'})).toBeInTheDocument();
  346. });
  347. it('loads with an empty query in URL', async function () {
  348. savedSearchesRequest = MockApiClient.addMockResponse({
  349. url: '/organizations/org-slug/searches/',
  350. body: [
  351. SearchFixture({
  352. id: '123',
  353. name: 'My Pinned Search',
  354. isPinned: true,
  355. isGlobal: false,
  356. query: 'is:resolved',
  357. }),
  358. ],
  359. });
  360. render(
  361. <IssueListWithStores
  362. {...merge({}, routerProps, {location: {query: {query: undefined}}})}
  363. />,
  364. {context: routerContext}
  365. );
  366. await waitFor(() => {
  367. expect(issuesRequest).toHaveBeenCalledWith(
  368. expect.anything(),
  369. expect.objectContaining({
  370. // Should be called with empty query
  371. data: expect.stringContaining(''),
  372. })
  373. );
  374. });
  375. expect(screen.getByDisplayValue('is:resolved')).toBeInTheDocument();
  376. // Organization saved search selector should have default saved search selected
  377. expect(screen.getByRole('button', {name: 'My Default Search'})).toBeInTheDocument();
  378. });
  379. it('caches the search results', async function () {
  380. issuesRequest = MockApiClient.addMockResponse({
  381. url: '/organizations/org-slug/issues/',
  382. body: [...new Array(25)].map((_, i) => ({id: i})),
  383. headers: {
  384. Link: DEFAULT_LINKS_HEADER,
  385. 'X-Hits': '500',
  386. 'X-Max-Hits': '1000',
  387. },
  388. });
  389. const defaultProps = {
  390. ...props,
  391. ...routerProps,
  392. useOrgSavedSearches: true,
  393. selection: {
  394. projects: [],
  395. environments: [],
  396. datetime: {period: '14d'},
  397. },
  398. organization: OrganizationFixture({
  399. features: ['issue-stream-performance'],
  400. projects: [],
  401. }),
  402. };
  403. const {unmount} = render(<IssueListWithStores {...defaultProps} />, {
  404. context: routerContext,
  405. organization: defaultProps.organization,
  406. });
  407. expect(
  408. await screen.findByText(textWithMarkupMatcher('1-25 of 500'))
  409. ).toBeInTheDocument();
  410. expect(issuesRequest).toHaveBeenCalledTimes(1);
  411. unmount();
  412. // Mount component again, getting from cache
  413. render(<IssueListWithStores {...defaultProps} />, {
  414. context: routerContext,
  415. organization: defaultProps.organization,
  416. });
  417. expect(
  418. await screen.findByText(textWithMarkupMatcher('1-25 of 500'))
  419. ).toBeInTheDocument();
  420. expect(issuesRequest).toHaveBeenCalledTimes(1);
  421. });
  422. it('1 search', async function () {
  423. const localSavedSearch = {...savedSearch, projectId: null};
  424. savedSearchesRequest = MockApiClient.addMockResponse({
  425. url: '/organizations/org-slug/searches/',
  426. body: [localSavedSearch],
  427. });
  428. render(<IssueListWithStores {...routerProps} />, {
  429. context: routerContext,
  430. });
  431. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  432. await userEvent.click(screen.getByRole('button', {name: /custom search/i}));
  433. await userEvent.click(screen.getByRole('button', {name: localSavedSearch.name}));
  434. expect(browserHistory.push).toHaveBeenLastCalledWith(
  435. expect.objectContaining({
  436. pathname: '/organizations/org-slug/issues/searches/789/',
  437. })
  438. );
  439. });
  440. it('clears a saved search when a custom one is entered', async function () {
  441. savedSearchesRequest = MockApiClient.addMockResponse({
  442. url: '/organizations/org-slug/searches/',
  443. body: [
  444. savedSearch,
  445. SearchFixture({
  446. id: '123',
  447. name: 'Pinned search',
  448. isPinned: true,
  449. isGlobal: false,
  450. query: 'is:resolved',
  451. }),
  452. ],
  453. });
  454. render(<IssueListWithStores {...routerProps} />, {
  455. context: routerContext,
  456. });
  457. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  458. const queryInput = screen.getByDisplayValue('is:resolved');
  459. await userEvent.clear(queryInput);
  460. await userEvent.type(queryInput, 'dogs{enter}');
  461. expect(browserHistory.push).toHaveBeenLastCalledWith(
  462. expect.objectContaining({
  463. pathname: '/organizations/org-slug/issues/',
  464. query: {
  465. environment: [],
  466. project: [],
  467. referrer: 'issue-list',
  468. sort: '',
  469. query: 'dogs',
  470. statsPeriod: '14d',
  471. },
  472. })
  473. );
  474. });
  475. it('pins a custom query', async function () {
  476. const pinnedSearch = {
  477. id: '666',
  478. name: 'My Pinned Search',
  479. query: 'assigned:me level:fatal',
  480. sort: 'date',
  481. isPinned: true,
  482. visibility: SavedSearchVisibility.ORGANIZATION,
  483. };
  484. savedSearchesRequest = MockApiClient.addMockResponse({
  485. url: '/organizations/org-slug/searches/',
  486. body: [savedSearch],
  487. });
  488. const {rerender} = render(<IssueListWithStores {...routerProps} />, {
  489. context: routerContext,
  490. });
  491. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  492. const queryInput = screen.getByDisplayValue('is:unresolved');
  493. await userEvent.clear(queryInput);
  494. await userEvent.type(queryInput, 'assigned:me level:fatal{enter}');
  495. expect((browserHistory.push as jest.Mock).mock.calls[0][0]).toEqual(
  496. expect.objectContaining({
  497. query: expect.objectContaining({
  498. query: 'assigned:me level:fatal',
  499. }),
  500. })
  501. );
  502. await tick();
  503. const routerWithQuery = {location: {query: {query: 'assigned:me level:fatal'}}};
  504. rerender(<IssueListWithStores {...merge({}, routerProps, routerWithQuery)} />);
  505. expect(screen.getByRole('button', {name: 'Custom Search'})).toBeInTheDocument();
  506. MockApiClient.clearMockResponses();
  507. const createPin = MockApiClient.addMockResponse({
  508. url: '/organizations/org-slug/pinned-searches/',
  509. method: 'PUT',
  510. body: pinnedSearch,
  511. });
  512. MockApiClient.addMockResponse({
  513. url: '/organizations/org-slug/searches/',
  514. body: [savedSearch, pinnedSearch],
  515. });
  516. await userEvent.click(screen.getByLabelText(/Set as Default/i));
  517. await waitFor(() => {
  518. expect(createPin).toHaveBeenCalled();
  519. expect(browserHistory.replace).toHaveBeenLastCalledWith(
  520. expect.objectContaining({
  521. pathname: '/organizations/org-slug/issues/searches/666/',
  522. query: {
  523. referrer: 'search-bar',
  524. },
  525. search: '',
  526. })
  527. );
  528. });
  529. });
  530. it('unpins a custom query', async function () {
  531. const pinnedSearch = SearchFixture({
  532. id: '666',
  533. name: 'My Pinned Search',
  534. query: 'assigned:me level:fatal',
  535. sort: 'date',
  536. isPinned: true,
  537. visibility: SavedSearchVisibility.ORGANIZATION,
  538. });
  539. savedSearchesRequest = MockApiClient.addMockResponse({
  540. url: '/organizations/org-slug/searches/',
  541. body: [pinnedSearch],
  542. });
  543. const deletePin = MockApiClient.addMockResponse({
  544. url: '/organizations/org-slug/pinned-searches/',
  545. method: 'DELETE',
  546. });
  547. const routerWithSavedSearch = {
  548. params: {searchId: pinnedSearch.id},
  549. };
  550. render(<IssueListWithStores {...merge({}, routerProps, routerWithSavedSearch)} />, {
  551. context: routerContext,
  552. router: routerWithSavedSearch,
  553. });
  554. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  555. expect(screen.getByRole('button', {name: 'My Default Search'})).toBeInTheDocument();
  556. await userEvent.click(screen.getByLabelText(/Remove Default/i));
  557. await waitFor(() => {
  558. expect(deletePin).toHaveBeenCalled();
  559. });
  560. await waitFor(() => {
  561. expect(browserHistory.replace).toHaveBeenLastCalledWith(
  562. expect.objectContaining({
  563. pathname: '/organizations/org-slug/issues/',
  564. })
  565. );
  566. });
  567. });
  568. it('pins a saved query', async function () {
  569. const assignedToMe = SearchFixture({
  570. id: '234',
  571. name: 'Assigned to Me',
  572. isPinned: false,
  573. isGlobal: true,
  574. query: 'assigned:me',
  575. sort: 'date',
  576. type: 0,
  577. });
  578. savedSearchesRequest = MockApiClient.addMockResponse({
  579. url: '/organizations/org-slug/searches/',
  580. body: [savedSearch, assignedToMe],
  581. });
  582. const createPin = MockApiClient.addMockResponse({
  583. url: '/organizations/org-slug/pinned-searches/',
  584. method: 'PUT',
  585. body: {
  586. ...savedSearch,
  587. isPinned: true,
  588. },
  589. });
  590. const routerWithSavedSearch = {params: {searchId: '789'}};
  591. render(<IssueListWithStores {...merge({}, routerProps, routerWithSavedSearch)} />, {
  592. context: routerContext,
  593. router: routerWithSavedSearch,
  594. });
  595. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  596. expect(screen.getByRole('button', {name: savedSearch.name})).toBeInTheDocument();
  597. await userEvent.click(screen.getByLabelText(/set as default/i));
  598. await waitFor(() => {
  599. expect(createPin).toHaveBeenCalled();
  600. expect(browserHistory.replace).toHaveBeenLastCalledWith(
  601. expect.objectContaining({
  602. pathname: '/organizations/org-slug/issues/searches/789/',
  603. })
  604. );
  605. });
  606. });
  607. it('pinning search should keep project selected', async function () {
  608. savedSearchesRequest = MockApiClient.addMockResponse({
  609. url: '/organizations/org-slug/searches/',
  610. body: [savedSearch],
  611. });
  612. const {routerContext: newRouterContext, router: newRouter} = initializeOrg({
  613. router: {
  614. location: {
  615. query: {
  616. project: ['123'],
  617. environment: ['prod'],
  618. query: 'assigned:me level:fatal',
  619. },
  620. },
  621. },
  622. });
  623. render(
  624. <IssueListWithStores
  625. {...newRouter}
  626. selection={{
  627. projects: [123],
  628. environments: ['prod'],
  629. datetime: {
  630. end: null,
  631. period: null,
  632. start: null,
  633. utc: null,
  634. },
  635. }}
  636. />,
  637. {context: newRouterContext}
  638. );
  639. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  640. const createPin = MockApiClient.addMockResponse({
  641. url: '/organizations/org-slug/pinned-searches/',
  642. method: 'PUT',
  643. body: {
  644. ...savedSearch,
  645. id: '666',
  646. name: 'My Pinned Search',
  647. query: 'assigned:me level:fatal',
  648. sort: 'date',
  649. isPinned: true,
  650. },
  651. });
  652. await userEvent.click(screen.getByLabelText(/set as default/i));
  653. await waitFor(() => {
  654. expect(createPin).toHaveBeenCalled();
  655. expect(browserHistory.replace).toHaveBeenLastCalledWith(
  656. expect.objectContaining({
  657. pathname: '/organizations/org-slug/issues/searches/666/',
  658. query: expect.objectContaining({
  659. project: ['123'],
  660. environment: ['prod'],
  661. query: 'assigned:me level:fatal',
  662. referrer: 'search-bar',
  663. }),
  664. })
  665. );
  666. });
  667. });
  668. it('unpinning search should keep project selected', async function () {
  669. const localSavedSearch = {
  670. ...savedSearch,
  671. id: '666',
  672. isPinned: true,
  673. query: 'assigned:me level:fatal',
  674. };
  675. savedSearchesRequest = MockApiClient.addMockResponse({
  676. url: '/organizations/org-slug/searches/',
  677. body: [localSavedSearch],
  678. });
  679. const deletePin = MockApiClient.addMockResponse({
  680. url: '/organizations/org-slug/pinned-searches/',
  681. method: 'DELETE',
  682. });
  683. const {routerContext: newRouterContext, router: newRouter} = initializeOrg(
  684. merge({}, router, {
  685. router: {
  686. location: {
  687. query: {
  688. project: ['123'],
  689. environment: ['prod'],
  690. query: 'assigned:me level:fatal',
  691. },
  692. },
  693. params: {searchId: '666'},
  694. },
  695. })
  696. );
  697. render(
  698. <IssueListWithStores
  699. {...newRouter}
  700. selection={{
  701. projects: [123],
  702. environments: ['prod'],
  703. datetime: {
  704. end: null,
  705. period: null,
  706. start: null,
  707. utc: null,
  708. },
  709. }}
  710. savedSearch={localSavedSearch}
  711. />,
  712. {context: newRouterContext}
  713. );
  714. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  715. await userEvent.click(screen.getByLabelText(/Remove Default/i));
  716. await waitFor(() => {
  717. expect(deletePin).toHaveBeenCalled();
  718. expect(browserHistory.replace).toHaveBeenLastCalledWith(
  719. expect.objectContaining({
  720. pathname: '/organizations/org-slug/issues/',
  721. query: expect.objectContaining({
  722. project: ['123'],
  723. environment: ['prod'],
  724. query: 'assigned:me level:fatal',
  725. referrer: 'search-bar',
  726. }),
  727. })
  728. );
  729. });
  730. });
  731. it('does not allow pagination to "previous" while on first page and resets cursors when navigating back to initial page', async function () {
  732. const {rerender} = render(<IssueListWithStores {...routerProps} />, {
  733. context: routerContext,
  734. });
  735. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  736. expect(screen.getByRole('button', {name: 'Previous'})).toBeDisabled();
  737. issuesRequest = MockApiClient.addMockResponse({
  738. url: '/organizations/org-slug/issues/',
  739. body: [group],
  740. headers: {
  741. Link: '<http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443575000:0:0>; rel="previous"; results="true"; cursor="1443575000:0:1", <http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443574000:0:0>; rel="next"; results="true"; cursor="1443574000:0:0"',
  742. },
  743. });
  744. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  745. let pushArgs = {
  746. pathname: '/organizations/org-slug/issues/',
  747. query: {
  748. cursor: '1443575000:0:0',
  749. page: 1,
  750. environment: [],
  751. project: [],
  752. query: 'is:unresolved',
  753. statsPeriod: '14d',
  754. referrer: 'issue-list',
  755. },
  756. };
  757. await waitFor(() => {
  758. expect(browserHistory.push).toHaveBeenLastCalledWith(pushArgs);
  759. });
  760. rerender(<IssueListWithStores {...merge({}, routerProps, {location: pushArgs})} />);
  761. expect(screen.getByRole('button', {name: 'Previous'})).toBeEnabled();
  762. // Click next again
  763. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  764. pushArgs = {
  765. pathname: '/organizations/org-slug/issues/',
  766. query: {
  767. cursor: '1443574000:0:0',
  768. page: 2,
  769. environment: [],
  770. project: [],
  771. query: 'is:unresolved',
  772. statsPeriod: '14d',
  773. referrer: 'issue-list',
  774. },
  775. };
  776. await waitFor(() => {
  777. expect(browserHistory.push).toHaveBeenLastCalledWith(pushArgs);
  778. });
  779. rerender(<IssueListWithStores {...merge({}, routerProps, {location: pushArgs})} />);
  780. // Click previous
  781. await userEvent.click(screen.getByRole('button', {name: 'Previous'}));
  782. pushArgs = {
  783. pathname: '/organizations/org-slug/issues/',
  784. query: {
  785. cursor: '1443575000:0:1',
  786. page: 1,
  787. environment: [],
  788. project: [],
  789. query: 'is:unresolved',
  790. statsPeriod: '14d',
  791. referrer: 'issue-list',
  792. },
  793. };
  794. await waitFor(() => {
  795. expect(browserHistory.push).toHaveBeenLastCalledWith(pushArgs);
  796. });
  797. rerender(<IssueListWithStores {...merge({}, routerProps, {location: pushArgs})} />);
  798. // Click previous back to initial page
  799. await userEvent.click(screen.getByRole('button', {name: 'Previous'}));
  800. await waitFor(() => {
  801. // cursor is undefined because "prev" cursor is === initial "next" cursor
  802. expect(browserHistory.push).toHaveBeenLastCalledWith({
  803. pathname: '/organizations/org-slug/issues/',
  804. query: {
  805. cursor: undefined,
  806. environment: [],
  807. page: undefined,
  808. project: [],
  809. query: 'is:unresolved',
  810. statsPeriod: '14d',
  811. referrer: 'issue-list',
  812. },
  813. });
  814. });
  815. });
  816. });
  817. describe('transitionTo', function () {
  818. it('pushes to history when query is updated', async function () {
  819. MockApiClient.addMockResponse({
  820. url: '/organizations/org-slug/issues/',
  821. body: [],
  822. headers: {
  823. Link: DEFAULT_LINKS_HEADER,
  824. },
  825. });
  826. render(<IssueListOverview {...props} />, {
  827. context: routerContext,
  828. });
  829. const queryInput = screen.getByDisplayValue('is:unresolved');
  830. await userEvent.clear(queryInput);
  831. await userEvent.type(queryInput, 'is:ignored{enter}');
  832. expect(browserHistory.push).toHaveBeenCalledWith({
  833. pathname: '/organizations/org-slug/issues/',
  834. query: {
  835. environment: [],
  836. project: [parseInt(project.id, 10)],
  837. query: 'is:ignored',
  838. statsPeriod: '14d',
  839. referrer: 'issue-list',
  840. },
  841. });
  842. });
  843. });
  844. it('fetches tags and members', async function () {
  845. render(<IssueListOverview {...routerProps} {...props} />, {context: routerContext});
  846. await waitFor(() => {
  847. expect(fetchTagsRequest).toHaveBeenCalled();
  848. expect(fetchMembersRequest).toHaveBeenCalled();
  849. });
  850. });
  851. describe('componentDidUpdate fetching groups', function () {
  852. let fetchDataMock;
  853. beforeEach(function () {
  854. fetchDataMock = MockApiClient.addMockResponse({
  855. url: '/organizations/org-slug/issues/',
  856. body: [group],
  857. headers: {
  858. Link: DEFAULT_LINKS_HEADER,
  859. },
  860. });
  861. fetchDataMock.mockReset();
  862. });
  863. it('fetches data on selection change', function () {
  864. const {rerender} = render(<IssueListOverview {...routerProps} {...props} />, {
  865. context: routerContext,
  866. });
  867. rerender(
  868. <IssueListOverview
  869. {...routerProps}
  870. {...props}
  871. selection={{projects: [99], environments: [], datetime: {period: '24h'}}}
  872. />
  873. );
  874. expect(fetchDataMock).toHaveBeenCalled();
  875. });
  876. it('fetches data on savedSearch change', function () {
  877. const {rerender} = render(<IssueListOverview {...routerProps} {...props} />, {
  878. context: routerContext,
  879. });
  880. rerender(
  881. <IssueListOverview
  882. {...routerProps}
  883. {...props}
  884. savedSearch={{id: '1', query: 'is:resolved'}}
  885. />
  886. );
  887. expect(fetchDataMock).toHaveBeenCalled();
  888. });
  889. it('uses correct statsPeriod when fetching issues list and no datetime given', function () {
  890. const {rerender} = render(<IssueListOverview {...routerProps} {...props} />, {
  891. context: routerContext,
  892. });
  893. const selection = {projects: [99], environments: [], datetime: {}};
  894. rerender(<IssueListOverview {...routerProps} {...props} selection={selection} />);
  895. expect(fetchDataMock).toHaveBeenLastCalledWith(
  896. '/organizations/org-slug/issues/',
  897. expect.objectContaining({
  898. data: 'collapse=stats&collapse=unhandled&expand=owners&expand=inbox&limit=25&project=99&query=is%3Aunresolved&savedSearch=1&shortIdLookup=1&statsPeriod=14d',
  899. })
  900. );
  901. });
  902. });
  903. describe('componentDidUpdate fetching members', function () {
  904. it('fetches memberlist and tags list on project change', function () {
  905. const {rerender} = render(<IssueListOverview {...routerProps} {...props} />, {
  906. context: routerContext,
  907. });
  908. // Called during componentDidMount
  909. expect(fetchMembersRequest).toHaveBeenCalledTimes(1);
  910. expect(fetchTagsRequest).toHaveBeenCalledTimes(1);
  911. const selection = {
  912. projects: [99],
  913. environments: [],
  914. datetime: {period: '24h'},
  915. };
  916. rerender(<IssueListOverview {...routerProps} {...props} selection={selection} />);
  917. expect(fetchMembersRequest).toHaveBeenCalledTimes(2);
  918. expect(fetchTagsRequest).toHaveBeenCalledTimes(2);
  919. });
  920. });
  921. describe('render states', function () {
  922. it('displays the loading icon when saved searches are loading', function () {
  923. render(<IssueListOverview {...routerProps} {...props} savedSearchLoading />, {
  924. context: routerContext,
  925. });
  926. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  927. });
  928. it('displays an error when issues fail to load', async function () {
  929. MockApiClient.addMockResponse({
  930. url: '/organizations/org-slug/issues/',
  931. status: 500,
  932. statusCode: 500,
  933. });
  934. render(<IssueListOverview {...routerProps} {...props} />, {
  935. context: routerContext,
  936. });
  937. expect(await screen.findByTestId('loading-error')).toBeInTheDocument();
  938. });
  939. it('displays congrats robots animation with only is:unresolved query', async function () {
  940. MockApiClient.addMockResponse({
  941. url: '/organizations/org-slug/issues/',
  942. body: [],
  943. headers: {
  944. Link: DEFAULT_LINKS_HEADER,
  945. },
  946. });
  947. render(<IssueListOverview {...routerProps} {...props} />, {context: routerContext});
  948. expect(
  949. await screen.findByText(/We couldn't find any issues that matched your filters/i)
  950. ).toBeInTheDocument();
  951. });
  952. it('displays an empty resultset with a non-default query', async function () {
  953. MockApiClient.addMockResponse({
  954. url: '/organizations/org-slug/issues/',
  955. body: [],
  956. headers: {
  957. Link: DEFAULT_LINKS_HEADER,
  958. },
  959. });
  960. render(<IssueListOverview {...routerProps} {...props} />, {context: routerContext});
  961. await userEvent.type(
  962. screen.getByDisplayValue('is:unresolved'),
  963. ' level:error{enter}'
  964. );
  965. expect(
  966. await screen.findByText(/We couldn't find any issues that matched your filters/i)
  967. ).toBeInTheDocument();
  968. });
  969. });
  970. describe('Error Robot', function () {
  971. const createWrapper = async moreProps => {
  972. MockApiClient.addMockResponse({
  973. url: '/organizations/org-slug/issues/',
  974. body: [],
  975. headers: {
  976. Link: DEFAULT_LINKS_HEADER,
  977. },
  978. });
  979. const defaultProps = {
  980. ...props,
  981. useOrgSavedSearches: true,
  982. selection: {
  983. projects: [],
  984. environments: [],
  985. datetime: {period: '14d'},
  986. },
  987. ...merge({}, routerProps, {
  988. params: {},
  989. location: {query: {query: 'is:unresolved'}, search: 'query=is:unresolved'},
  990. }),
  991. organization: OrganizationFixture({
  992. projects: [],
  993. }),
  994. ...moreProps,
  995. };
  996. render(<IssueListOverview {...defaultProps} />, {
  997. context: routerContext,
  998. });
  999. await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  1000. };
  1001. it('displays when no projects selected and all projects user is member of, async does not have first event', async function () {
  1002. const projects = [
  1003. ProjectFixture({
  1004. id: '1',
  1005. slug: 'foo',
  1006. isMember: true,
  1007. firstEvent: null,
  1008. }),
  1009. ProjectFixture({
  1010. id: '2',
  1011. slug: 'bar',
  1012. isMember: true,
  1013. firstEvent: null,
  1014. }),
  1015. ProjectFixture({
  1016. id: '3',
  1017. slug: 'baz',
  1018. isMember: true,
  1019. firstEvent: null,
  1020. }),
  1021. ];
  1022. MockApiClient.addMockResponse({
  1023. url: '/organizations/org-slug/sent-first-event/',
  1024. query: {
  1025. is_member: true,
  1026. },
  1027. body: {sentFirstEvent: false},
  1028. });
  1029. MockApiClient.addMockResponse({
  1030. url: '/organizations/org-slug/projects/',
  1031. body: projects,
  1032. });
  1033. MockApiClient.addMockResponse({
  1034. url: '/projects/org-slug/foo/issues/',
  1035. body: [],
  1036. });
  1037. await createWrapper({
  1038. organization: OrganizationFixture({
  1039. projects,
  1040. }),
  1041. });
  1042. expect(await screen.findByTestId('awaiting-events')).toBeInTheDocument();
  1043. });
  1044. it('does not display when no projects selected and any projects have a first event', async function () {
  1045. const projects = [
  1046. ProjectFixture({
  1047. id: '1',
  1048. slug: 'foo',
  1049. isMember: true,
  1050. firstEvent: null,
  1051. }),
  1052. ProjectFixture({
  1053. id: '2',
  1054. slug: 'bar',
  1055. isMember: true,
  1056. firstEvent: new Date().toISOString(),
  1057. }),
  1058. ProjectFixture({
  1059. id: '3',
  1060. slug: 'baz',
  1061. isMember: true,
  1062. firstEvent: null,
  1063. }),
  1064. ];
  1065. MockApiClient.addMockResponse({
  1066. url: '/organizations/org-slug/sent-first-event/',
  1067. query: {
  1068. is_member: true,
  1069. },
  1070. body: {sentFirstEvent: true},
  1071. });
  1072. MockApiClient.addMockResponse({
  1073. url: '/organizations/org-slug/projects/',
  1074. body: projects,
  1075. });
  1076. await createWrapper({
  1077. organization: OrganizationFixture({
  1078. projects,
  1079. }),
  1080. });
  1081. expect(screen.queryByTestId('awaiting-events')).not.toBeInTheDocument();
  1082. });
  1083. it('displays when all selected projects do not have first event', async function () {
  1084. const projects = [
  1085. ProjectFixture({
  1086. id: '1',
  1087. slug: 'foo',
  1088. isMember: true,
  1089. firstEvent: null,
  1090. }),
  1091. ProjectFixture({
  1092. id: '2',
  1093. slug: 'bar',
  1094. isMember: true,
  1095. firstEvent: null,
  1096. }),
  1097. ProjectFixture({
  1098. id: '3',
  1099. slug: 'baz',
  1100. isMember: true,
  1101. firstEvent: null,
  1102. }),
  1103. ];
  1104. MockApiClient.addMockResponse({
  1105. url: '/organizations/org-slug/sent-first-event/',
  1106. query: {
  1107. project: [1, 2],
  1108. },
  1109. body: {sentFirstEvent: false},
  1110. });
  1111. MockApiClient.addMockResponse({
  1112. url: '/organizations/org-slug/projects/',
  1113. body: projects,
  1114. });
  1115. MockApiClient.addMockResponse({
  1116. url: '/projects/org-slug/foo/issues/',
  1117. body: [],
  1118. });
  1119. await createWrapper({
  1120. selection: {
  1121. projects: [1, 2],
  1122. environments: [],
  1123. datetime: {period: '14d'},
  1124. },
  1125. organization: OrganizationFixture({
  1126. projects,
  1127. }),
  1128. });
  1129. expect(await screen.findByTestId('awaiting-events')).toBeInTheDocument();
  1130. });
  1131. it('does not display when any selected projects have first event', async function () {
  1132. const projects = [
  1133. ProjectFixture({
  1134. id: '1',
  1135. slug: 'foo',
  1136. isMember: true,
  1137. firstEvent: null,
  1138. }),
  1139. ProjectFixture({
  1140. id: '2',
  1141. slug: 'bar',
  1142. isMember: true,
  1143. firstEvent: new Date().toISOString(),
  1144. }),
  1145. ProjectFixture({
  1146. id: '3',
  1147. slug: 'baz',
  1148. isMember: true,
  1149. firstEvent: new Date().toISOString(),
  1150. }),
  1151. ];
  1152. MockApiClient.addMockResponse({
  1153. url: '/organizations/org-slug/sent-first-event/',
  1154. query: {
  1155. project: [1, 2],
  1156. },
  1157. body: {sentFirstEvent: true},
  1158. });
  1159. MockApiClient.addMockResponse({
  1160. url: '/organizations/org-slug/projects/',
  1161. body: projects,
  1162. });
  1163. await createWrapper({
  1164. selection: {
  1165. projects: [1, 2],
  1166. environments: [],
  1167. datetime: {period: '14d'},
  1168. },
  1169. organization: OrganizationFixture({
  1170. projects,
  1171. }),
  1172. });
  1173. expect(screen.queryByTestId('awaiting-events')).not.toBeInTheDocument();
  1174. });
  1175. });
  1176. it('displays a count that represents the current page', function () {
  1177. MockApiClient.addMockResponse({
  1178. url: '/organizations/org-slug/issues/',
  1179. body: [...new Array(25)].map((_, i) => ({id: i})),
  1180. headers: {
  1181. Link: DEFAULT_LINKS_HEADER,
  1182. 'X-Hits': '500',
  1183. 'X-Max-Hits': '1000',
  1184. },
  1185. });
  1186. parseLinkHeaderSpy.mockReturnValue({
  1187. next: {
  1188. results: true,
  1189. cursor: '',
  1190. href: '',
  1191. },
  1192. previous: {
  1193. results: false,
  1194. cursor: '',
  1195. href: '',
  1196. },
  1197. });
  1198. props = {
  1199. ...props,
  1200. location: {
  1201. query: {
  1202. cursor: 'some cursor',
  1203. page: 1,
  1204. },
  1205. },
  1206. };
  1207. const {routerContext: newRouterContext} = initializeOrg();
  1208. const {rerender} = render(<IssueListOverview {...props} />, {
  1209. context: newRouterContext,
  1210. });
  1211. expect(screen.getByText(textWithMarkupMatcher('1-25 of 500'))).toBeInTheDocument();
  1212. parseLinkHeaderSpy.mockReturnValue({
  1213. next: {
  1214. results: true,
  1215. cursor: '',
  1216. href: '',
  1217. },
  1218. previous: {
  1219. results: true,
  1220. cursor: '',
  1221. href: '',
  1222. },
  1223. });
  1224. rerender(<IssueListOverview {...props} />);
  1225. expect(screen.getByText(textWithMarkupMatcher('26-50 of 500'))).toBeInTheDocument();
  1226. });
  1227. describe('project low trends queue alert', function () {
  1228. const {routerContext: newRouterContext} = initializeOrg();
  1229. beforeEach(function () {
  1230. act(() => ProjectsStore.reset());
  1231. });
  1232. it('does not render event processing alert', function () {
  1233. act(() => ProjectsStore.loadInitialData([project]));
  1234. render(<IssueListOverview {...props} />, {
  1235. context: newRouterContext,
  1236. });
  1237. expect(screen.queryByText(/event processing/i)).not.toBeInTheDocument();
  1238. });
  1239. describe('renders alert', function () {
  1240. it('for one project', function () {
  1241. act(() =>
  1242. ProjectsStore.loadInitialData([
  1243. {...project, eventProcessing: {symbolicationDegraded: true}},
  1244. ])
  1245. );
  1246. render(<IssueListOverview {...props} />, {
  1247. context: routerContext,
  1248. });
  1249. expect(
  1250. screen.getByText(/Event Processing for this project is currently degraded/i)
  1251. ).toBeInTheDocument();
  1252. });
  1253. it('for multiple projects', function () {
  1254. const projectBar = ProjectFixture({
  1255. id: '3560',
  1256. name: 'Bar Project',
  1257. slug: 'project-slug-bar',
  1258. });
  1259. act(() =>
  1260. ProjectsStore.loadInitialData([
  1261. {
  1262. ...project,
  1263. slug: 'project-slug',
  1264. eventProcessing: {symbolicationDegraded: true},
  1265. },
  1266. {
  1267. ...projectBar,
  1268. slug: 'project-slug-bar',
  1269. eventProcessing: {symbolicationDegraded: true},
  1270. },
  1271. ])
  1272. );
  1273. render(
  1274. <IssueListOverview
  1275. {...props}
  1276. selection={{
  1277. ...props.selection,
  1278. projects: [Number(project.id), Number(projectBar.id)],
  1279. }}
  1280. />,
  1281. {
  1282. context: newRouterContext,
  1283. }
  1284. );
  1285. expect(
  1286. screen.getByText(
  1287. textWithMarkupMatcher(
  1288. 'Event Processing for the project-slug, project-slug-bar projects is currently degraded.'
  1289. )
  1290. )
  1291. ).toBeInTheDocument();
  1292. });
  1293. });
  1294. });
  1295. });