11import { OrganizationFixture } from 'sentry-fixture/organization' ;
22import { ProjectFixture } from 'sentry-fixture/project' ;
33
4- import { render , screen , userEvent , waitFor } from 'sentry-test/reactTestingLibrary' ;
4+ import { render , screen , waitFor } from 'sentry-test/reactTestingLibrary' ;
55
66import PageFiltersStore from 'sentry/stores/pageFiltersStore' ;
77import ProjectsStore from 'sentry/stores/projectsStore' ;
@@ -14,8 +14,6 @@ describe('PageOverviewSidebar', () => {
1414 const organization = OrganizationFixture ( {
1515 features : [ 'performance-web-vitals-seer-suggestions' , 'gen-ai-features' ] ,
1616 } ) ;
17- let userIssueMock : jest . Mock ;
18- let eventsMock : jest . Mock ;
1917 let seerSetupCheckMock : jest . Mock ;
2018 let seerPreferencesMock : jest . Mock ;
2119
@@ -53,13 +51,6 @@ describe('PageOverviewSidebar', () => {
5351 } ,
5452 } ) ;
5553
56- eventsMock = MockApiClient . addMockResponse ( {
57- url : `/organizations/${ organization . slug } /events/` ,
58- body : {
59- data : [ { trace : '123' , timestamp : '2025-01-01T00:00:00Z' } ] ,
60- } ,
61- } ) ;
62-
6354 MockApiClient . addMockResponse ( {
6455 url : `/organizations/${ organization . slug } /issues/` ,
6556 body : [
@@ -89,12 +80,6 @@ describe('PageOverviewSidebar', () => {
8980 } ,
9081 } ,
9182 } ) ;
92-
93- userIssueMock = MockApiClient . addMockResponse ( {
94- url : `/projects/${ organization . slug } /${ project . slug } /user-issue/` ,
95- body : { event_id : '123' } ,
96- method : 'POST' ,
97- } ) ;
9883 } ) ;
9984
10085 afterEach ( ( ) => {
@@ -218,110 +203,5 @@ describe('PageOverviewSidebar', () => {
218203 ) . toBeInTheDocument ( ) ;
219204 expect ( screen . getByText ( 'View Suggestion' ) ) . toBeInTheDocument ( ) ;
220205 } ) ;
221-
222- it ( 'should create issues when run seer analysis button is clicked' , async ( ) => {
223- MockApiClient . addMockResponse ( {
224- url : `/organizations/${ organization . slug } /issues/` ,
225- body : [ ] ,
226- } ) ;
227- render (
228- < PageOverviewSidebar
229- transaction = { TRANSACTION_NAME }
230- projectScore = { { lcpScore : 80 } }
231- projectData = { [
232- {
233- 'p75(measurements.lcp)' : 1000 ,
234- 'p75(measurements.cls)' : 0.1 ,
235- 'p75(measurements.fcp)' : 1800 ,
236- 'p75(measurements.ttfb)' : 600 ,
237- 'p75(measurements.inp)' : 200 ,
238- } ,
239- ] }
240- /> ,
241- { organization}
242- ) ;
243- const runSeerAnalysisButton = await screen . findByText ( 'Run Seer Analysis' ) ;
244- expect ( runSeerAnalysisButton ) . toBeInTheDocument ( ) ;
245- await userEvent . click ( runSeerAnalysisButton ) ;
246- expect ( userIssueMock ) . toHaveBeenCalledWith (
247- '/projects/org-slug/project-slug/user-issue/' ,
248- expect . objectContaining ( {
249- method : 'POST' ,
250- data : expect . objectContaining ( {
251- issueType : 'web_vitals' ,
252- vital : 'lcp' ,
253- score : 80 ,
254- value : 1000 ,
255- transaction : TRANSACTION_NAME ,
256- } ) ,
257- } )
258- ) ;
259- expect ( screen . queryByText ( 'Run Seer Analysis' ) ) . not . toBeInTheDocument ( ) ;
260- } ) ;
261-
262- it ( 'should create multiple issues with trace ids when run seer analysis button is clicked' , async ( ) => {
263- MockApiClient . addMockResponse ( {
264- url : `/organizations/${ organization . slug } /issues/` ,
265- body : [ ] ,
266- } ) ;
267- render (
268- < PageOverviewSidebar
269- transaction = { TRANSACTION_NAME }
270- projectScore = { {
271- lcpScore : 80 ,
272- clsScore : 80 ,
273- fcpScore : 80 ,
274- ttfbScore : 100 ,
275- inpScore : 80 ,
276- } }
277- projectData = { [
278- {
279- 'p75(measurements.lcp)' : 2500 ,
280- 'p75(measurements.cls)' : 0.1 ,
281- 'p75(measurements.fcp)' : 1800 ,
282- 'p75(measurements.ttfb)' : 600 ,
283- 'p75(measurements.inp)' : 200 ,
284- } ,
285- ] }
286- /> ,
287- { organization}
288- ) ;
289-
290- const runSeerAnalysisButton = await screen . findByText ( 'Run Seer Analysis' ) ;
291- expect ( runSeerAnalysisButton ) . toBeInTheDocument ( ) ;
292- expect ( eventsMock ) . toHaveBeenCalledTimes ( 5 ) ;
293- await userEvent . click ( runSeerAnalysisButton ) ;
294- [ 'lcp' , 'cls' , 'fcp' , 'inp' ] . forEach ( vital => {
295- expect ( userIssueMock ) . toHaveBeenCalledWith (
296- '/projects/org-slug/project-slug/user-issue/' ,
297- expect . objectContaining ( {
298- method : 'POST' ,
299- data : expect . objectContaining ( {
300- issueType : 'web_vitals' ,
301- vital,
302- score : 80 ,
303- transaction : TRANSACTION_NAME ,
304- traceId : '123' ,
305- } ) ,
306- } )
307- ) ;
308- } ) ;
309- // TTFB has a score over 90, so it should not be created as an issue
310- expect ( userIssueMock ) . not . toHaveBeenCalledWith (
311- '/projects/org-slug/project-slug/user-issue/' ,
312- expect . objectContaining ( {
313- method : 'POST' ,
314- data : expect . objectContaining ( {
315- issueType : 'web_vitals' ,
316- vital : 'ttfb' ,
317- score : 100 ,
318- transaction : TRANSACTION_NAME ,
319- traceId : '123' ,
320- timestamp : '2025-01-01T00:00:00Z' ,
321- } ) ,
322- } )
323- ) ;
324- expect ( screen . queryByText ( 'Run Seer Analysis' ) ) . not . toBeInTheDocument ( ) ;
325- } ) ;
326206 } ) ;
327207} ) ;
0 commit comments