overview.spec.tsx 43 KB

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