File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,7 +63,10 @@ describe('useIsIAMEnabled', () => {
6363
6464 await waitFor ( ( ) => {
6565 expect ( result . current . isIAMBeta ) . toBe ( false ) ;
66+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
6667 expect ( result . current . isIAMEnabled ) . toBe ( true ) ;
68+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
69+ expect ( queryMocks . useAccountPermissions ) . toHaveBeenCalledWith ( true ) ;
6770 } ) ;
6871 } ) ;
6972
@@ -87,7 +90,10 @@ describe('useIsIAMEnabled', () => {
8790
8891 await waitFor ( ( ) => {
8992 expect ( result . current . isIAMBeta ) . toBe ( false ) ;
93+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
9094 expect ( result . current . isIAMEnabled ) . toBe ( false ) ;
95+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
96+ expect ( queryMocks . useAccountPermissions ) . toHaveBeenCalledWith ( false ) ;
9197 } ) ;
9298 } ) ;
9399
@@ -110,7 +116,10 @@ describe('useIsIAMEnabled', () => {
110116
111117 await waitFor ( ( ) => {
112118 expect ( result . current . isIAMBeta ) . toBe ( true ) ;
119+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
113120 expect ( result . current . isIAMEnabled ) . toBe ( false ) ;
121+ // eslint-disable-next-line testing-library/no-wait-for-multiple-assertions
122+ expect ( queryMocks . useAccountPermissions ) . toHaveBeenCalledWith ( true ) ;
114123 } ) ;
115124 } ) ;
116125} ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { useAccountPermissions } from 'src/queries/iam/iam';
88 */
99export const useIsIAMEnabled = ( ) => {
1010 const flags = useFlags ( ) ;
11- const { data : rolePermissions } = useAccountPermissions ( ) ;
11+ const { data : rolePermissions } = useAccountPermissions ( flags . iam ?. enabled ) ;
1212
1313 const hasAccountAccess = rolePermissions ?. account_access ?. length ;
1414 const hasEntityAccess = rolePermissions ?. entity_access ?. length ;
Original file line number Diff line number Diff line change @@ -17,11 +17,12 @@ export const useAccountUserPermissions = (username?: string) => {
1717 } ) ;
1818} ;
1919
20- export const useAccountPermissions = ( ) => {
20+ export const useAccountPermissions = ( enabled = true ) => {
2121 return useQuery < IamAccountPermissions , APIError [ ] > ( {
2222 ...iamQueries . permissions ,
2323 ...queryPresets . oneTimeFetch ,
2424 ...queryPresets . noRetry ,
25+ enabled,
2526 } ) ;
2627} ;
2728
You can’t perform that action at this time.
0 commit comments