11import { GroupFixture } from 'sentry-fixture/group' ;
22import { OrganizationFixture } from 'sentry-fixture/organization' ;
33
4- import { render , screen , userEvent } from 'sentry-test/reactTestingLibrary' ;
4+ import { render , screen } from 'sentry-test/reactTestingLibrary' ;
55
66import { SupergroupSection } from 'sentry/views/issueDetails/streamline/sidebar/supergroupSection' ;
77
8- const organization = OrganizationFixture ( { features : [ 'top-issues-ui' ] } ) ;
9-
108describe ( 'SupergroupSection' , ( ) => {
11- beforeEach ( ( ) => {
12- MockApiClient . clearMockResponses ( ) ;
13- } ) ;
14-
15- it ( 'renders supergroup card when issue belongs to a supergroup' , async ( ) => {
9+ it ( 'renders supergroup info when issue belongs to one' , async ( ) => {
10+ const organization = OrganizationFixture ( { features : [ 'top-issues-ui' ] } ) ;
1611 const group = GroupFixture ( { id : '1' } ) ;
1712 MockApiClient . addMockResponse ( {
1813 url : `/organizations/${ organization . slug } /seer/supergroups/by-group/` ,
@@ -23,7 +18,7 @@ describe('SupergroupSection', () => {
2318 title : 'Null pointer in auth flow' ,
2419 error_type : 'TypeError' ,
2520 code_area : 'auth/login' ,
26- summary : 'Root cause summary ' ,
21+ summary : '' ,
2722 group_ids : [ 1 , 2 , 3 ] ,
2823 created_at : '2024-01-01T00:00:00Z' ,
2924 updated_at : '2024-01-01T00:00:00Z' ,
@@ -34,68 +29,8 @@ describe('SupergroupSection', () => {
3429
3530 render ( < SupergroupSection group = { group } /> , { organization} ) ;
3631
37- expect ( await screen . findByText ( 'Supergroup' ) ) . toBeInTheDocument ( ) ;
38- expect ( screen . getByText ( 'TypeError' ) ) . toBeInTheDocument ( ) ;
32+ expect ( await screen . findByText ( 'TypeError' ) ) . toBeInTheDocument ( ) ;
3933 expect ( screen . getByText ( 'Null pointer in auth flow' ) ) . toBeInTheDocument ( ) ;
40- expect ( screen . getByText ( 'auth/login' ) ) . toBeInTheDocument ( ) ;
4134 expect ( screen . getByText ( '3 issues' ) ) . toBeInTheDocument ( ) ;
4235 } ) ;
43-
44- it ( 'does not render when issue is not in a supergroup' , async ( ) => {
45- const group = GroupFixture ( { id : '1' } ) ;
46- MockApiClient . addMockResponse ( {
47- url : `/organizations/${ organization . slug } /seer/supergroups/by-group/` ,
48- body : { data : [ ] } ,
49- } ) ;
50-
51- const { container} = render ( < SupergroupSection group = { group } /> , { organization} ) ;
52-
53- // Wait for the request to resolve, then check it's still empty
54- await screen . findByText ( ( ) => false ) . catch ( ( ) => { } ) ;
55- expect ( container ) . toBeEmptyDOMElement ( ) ;
56- } ) ;
57-
58- it ( 'does not render without the feature flag' , ( ) => {
59- const group = GroupFixture ( { id : '1' } ) ;
60- const orgWithoutFlag = OrganizationFixture ( { features : [ ] } ) ;
61-
62- const { container} = render ( < SupergroupSection group = { group } /> , {
63- organization : orgWithoutFlag ,
64- } ) ;
65-
66- expect ( container ) . toBeEmptyDOMElement ( ) ;
67- } ) ;
68-
69- it ( 'opens the supergroup drawer on click' , async ( ) => {
70- const group = GroupFixture ( { id : '1' } ) ;
71- MockApiClient . addMockResponse ( {
72- url : `/organizations/${ organization . slug } /seer/supergroups/by-group/` ,
73- body : {
74- data : [
75- {
76- id : 10 ,
77- title : 'Null pointer in auth flow' ,
78- error_type : 'TypeError' ,
79- code_area : 'auth/login' ,
80- summary : '' ,
81- group_ids : [ 1 , 2 ] ,
82- created_at : '2024-01-01T00:00:00Z' ,
83- updated_at : '2024-01-01T00:00:00Z' ,
84- } ,
85- ] ,
86- } ,
87- } ) ;
88- // The drawer's issue list fetches group details
89- MockApiClient . addMockResponse ( {
90- url : `/organizations/${ organization . slug } /issues/` ,
91- body : [ ] ,
92- } ) ;
93-
94- render ( < SupergroupSection group = { group } /> , { organization} ) ;
95-
96- const card = await screen . findByRole ( 'button' , { name : 'Supergroup details' } ) ;
97- await userEvent . click ( card ) ;
98-
99- expect ( await screen . findByText ( 'Supergroups' ) ) . toBeInTheDocument ( ) ;
100- } ) ;
10136} ) ;
0 commit comments