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