2023-01-31 19:54:16 +08:00
import { act , render , screen , waitFor } from '@testing-library/react' ;
2022-03-26 02:12:52 +08:00
import userEvent from '@testing-library/user-event' ;
2022-12-09 20:50:01 +08:00
import { omit } from 'lodash' ;
2022-02-01 16:39:48 +08:00
import React from 'react' ;
2022-09-22 21:05:29 +08:00
import createMockDatasource from '../../__mocks__/datasource' ;
2022-04-28 08:06:21 +08:00
import { createMockInstanceSetttings } from '../../__mocks__/instanceSettings' ;
2022-02-01 16:39:48 +08:00
import {
createMockResourceGroupsBySubscription ,
createMockSubscriptions ,
mockResourcesByResourceGroup ,
2022-05-03 09:57:56 +08:00
mockSearchResults ,
2022-02-01 16:39:48 +08:00
} from '../../__mocks__/resourcePickerRows' ;
2022-06-17 16:15:20 +08:00
import ResourcePickerData , { ResourcePickerQueryType } from '../../resourcePicker/resourcePickerData' ;
2022-04-22 21:33:13 +08:00
2022-03-25 19:22:28 +08:00
import { ResourceRowType } from './types' ;
2022-02-01 16:39:48 +08:00
2022-04-22 21:33:13 +08:00
import ResourcePicker from '.' ;
2023-01-17 21:11:11 +08:00
jest . mock ( '@grafana/runtime' , ( ) = > ( {
2023-02-14 23:46:42 +08:00
. . . jest . requireActual ( '@grafana/runtime' ) ,
2023-01-17 21:11:11 +08:00
getTemplateSrv : ( ) = > ( {
replace : ( val : string ) = > {
return val ;
} ,
} ) ,
} ) ) ;
2022-02-01 16:39:48 +08:00
const noResourceURI = '' ;
2022-03-23 21:38:46 +08:00
const singleSubscriptionSelectionURI = '/subscriptions/def-456' ;
2022-02-01 16:39:48 +08:00
const singleResourceGroupSelectionURI = '/subscriptions/def-456/resourceGroups/dev-3' ;
const singleResourceSelectionURI =
2022-03-23 21:38:46 +08:00
'/subscriptions/def-456/resourceGroups/dev-3/providers/Microsoft.Compute/virtualMachines/db-server' ;
2022-02-01 16:39:48 +08:00
2023-02-23 18:07:44 +08:00
const noop = ( ) = > { } ;
2022-12-09 20:50:01 +08:00
function createMockResourcePickerData ( preserveImplementation? : string [ ] ) {
2022-09-22 21:05:29 +08:00
const mockDatasource = createMockDatasource ( ) ;
const mockResourcePicker = new ResourcePickerData (
createMockInstanceSetttings ( ) ,
mockDatasource . azureMonitorDatasource
) ;
2022-04-28 08:06:21 +08:00
2022-12-09 20:50:01 +08:00
const mockFunctions = omit (
{
getSubscriptions : jest.fn ( ) . mockResolvedValue ( createMockSubscriptions ( ) ) ,
getResourceGroupsBySubscriptionId : jest.fn ( ) . mockResolvedValue ( createMockResourceGroupsBySubscription ( ) ) ,
getResourcesForResourceGroup : jest.fn ( ) . mockResolvedValue ( mockResourcesByResourceGroup ( ) ) ,
getResourceURIFromWorkspace : jest.fn ( ) . mockReturnValue ( '' ) ,
getResourceURIDisplayProperties : jest.fn ( ) . mockResolvedValue ( { } ) ,
search : jest.fn ( ) . mockResolvedValue ( mockSearchResults ( ) ) ,
} ,
preserveImplementation || [ ]
) ;
2022-04-28 08:06:21 +08:00
2022-12-09 20:50:01 +08:00
return Object . assign ( mockResourcePicker , mockFunctions ) ;
2022-04-28 08:06:21 +08:00
}
2022-06-17 16:15:20 +08:00
const queryType : ResourcePickerQueryType = 'logs' ;
2022-03-25 19:22:28 +08:00
const defaultProps = {
templateVariables : [ ] ,
2023-01-24 22:44:48 +08:00
resources : [ ] ,
2022-04-28 08:06:21 +08:00
resourcePickerData : createMockResourcePickerData ( ) ,
2022-03-25 19:22:28 +08:00
onCancel : noop ,
onApply : noop ,
selectableEntryTypes : [
ResourceRowType . Subscription ,
ResourceRowType . ResourceGroup ,
ResourceRowType . Resource ,
ResourceRowType . Variable ,
] ,
2022-06-17 16:15:20 +08:00
queryType ,
2023-01-20 18:19:31 +08:00
disableRow : jest.fn ( ) ,
2023-01-24 22:44:48 +08:00
renderAdvanced : jest.fn ( ) ,
2022-03-23 21:38:46 +08:00
} ;
2022-03-25 19:22:28 +08:00
2022-02-01 16:39:48 +08:00
describe ( 'AzureMonitor ResourcePicker' , ( ) = > {
beforeEach ( ( ) = > {
2022-04-28 00:57:18 +08:00
window . HTMLElement . prototype . scrollIntoView = jest . fn ( ) ;
2022-02-01 16:39:48 +08:00
} ) ;
2022-03-23 21:38:46 +08:00
it ( 'should pre-load subscriptions when there is no existing selection' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ noResourceURI ] } / > ) ;
2022-03-23 21:38:46 +08:00
const subscriptionCheckbox = await screen . findByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckbox ) . toBeInTheDocument ( ) ;
expect ( subscriptionCheckbox ) . not . toBeChecked ( ) ;
const uncheckedCheckboxes = await screen . findAllByRole ( 'checkbox' , { checked : false } ) ;
expect ( uncheckedCheckboxes . length ) . toBe ( 3 ) ;
} ) ;
it ( 'should show a subscription as selected if there is one saved' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ singleSubscriptionSelectionURI ] } / > ) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'Dev Subscription' ) ) . toHaveLength ( 2 ) ;
2023-03-15 18:12:13 +08:00
} ) ;
2022-04-28 00:57:18 +08:00
const subscriptionCheckboxes = await screen . findAllByLabelText ( 'Dev Subscription' ) ;
expect ( subscriptionCheckboxes [ 0 ] ) . toBeChecked ( ) ;
expect ( subscriptionCheckboxes [ 1 ] ) . toBeChecked ( ) ;
2022-03-23 21:38:46 +08:00
} ) ;
2022-02-01 16:39:48 +08:00
2022-03-25 19:22:28 +08:00
it ( 'should show a resourceGroup as selected if there is one saved' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ singleResourceGroupSelectionURI ] } / > ) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'A Great Resource Group' ) ) . toHaveLength ( 2 ) ;
} ) ;
2022-04-28 00:57:18 +08:00
const resourceGroupCheckboxes = await screen . findAllByLabelText ( 'A Great Resource Group' ) ;
expect ( resourceGroupCheckboxes [ 0 ] ) . toBeChecked ( ) ;
expect ( resourceGroupCheckboxes [ 1 ] ) . toBeChecked ( ) ;
2022-02-01 16:39:48 +08:00
} ) ;
2022-05-03 09:57:56 +08:00
it ( 'should show scroll down to a resource and mark it as selected if there is one saved' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ singleResourceSelectionURI ] } / > ) ;
2023-01-31 19:54:16 +08:00
await waitFor ( ( ) = > {
expect ( screen . queryByText ( 'Loading...' ) ) . not . toBeInTheDocument ( ) ;
} ) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'db-server' ) ) . toHaveLength ( 2 ) ;
} ) ;
2022-04-28 00:57:18 +08:00
const resourceCheckboxes = await screen . findAllByLabelText ( 'db-server' ) ;
expect ( resourceCheckboxes [ 0 ] ) . toBeChecked ( ) ;
expect ( resourceCheckboxes [ 1 ] ) . toBeChecked ( ) ;
} ) ;
it ( 'opens the selected nested resources' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ singleResourceSelectionURI ] } / > ) ;
2022-04-28 00:57:18 +08:00
const collapseSubscriptionBtn = await screen . findByLabelText ( 'Collapse Dev Subscription' ) ;
expect ( collapseSubscriptionBtn ) . toBeInTheDocument ( ) ;
const collapseResourceGroupBtn = await screen . findByLabelText ( 'Collapse A Great Resource Group' ) ;
expect ( collapseResourceGroupBtn ) . toBeInTheDocument ( ) ;
} ) ;
it ( 'scrolls down to the selected resource' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ singleResourceSelectionURI ] } / > ) ;
2022-04-28 00:57:18 +08:00
await screen . findByLabelText ( 'Collapse A Great Resource Group' ) ;
expect ( window . HTMLElement . prototype . scrollIntoView ) . toBeCalledTimes ( 1 ) ;
2022-02-01 16:39:48 +08:00
} ) ;
2022-03-23 21:38:46 +08:00
it ( 'should be able to expand a subscription when clicked and reveal resource groups' , async ( ) = > {
2022-03-25 19:22:28 +08:00
render ( < ResourcePicker { ...defaultProps } / > ) ;
2022-03-23 21:38:46 +08:00
const expandSubscriptionButton = await screen . findByLabelText ( 'Expand Primary Subscription' ) ;
expect ( expandSubscriptionButton ) . toBeInTheDocument ( ) ;
expect ( screen . queryByLabelText ( 'A Great Resource Group' ) ) . not . toBeInTheDocument ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( expandSubscriptionButton ) ;
2022-03-23 21:38:46 +08:00
expect ( await screen . findByLabelText ( 'A Great Resource Group' ) ) . toBeInTheDocument ( ) ;
} ) ;
2022-02-01 16:39:48 +08:00
2022-05-03 09:57:56 +08:00
it ( 'should call onApply with a new subscription uri when a user clicks on the checkbox in the row' , async ( ) = > {
2022-03-23 21:38:46 +08:00
const onApply = jest . fn ( ) ;
2022-03-25 19:22:28 +08:00
render ( < ResourcePicker { ...defaultProps } onApply = { onApply } / > ) ;
2022-03-23 21:38:46 +08:00
const subscriptionCheckbox = await screen . findByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckbox ) . toBeInTheDocument ( ) ;
expect ( subscriptionCheckbox ) . not . toBeChecked ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( subscriptionCheckbox ) ;
2022-03-23 21:38:46 +08:00
const applyButton = screen . getByRole ( 'button' , { name : 'Apply' } ) ;
2023-01-24 22:44:48 +08:00
expect ( applyButton ) . toBeEnabled ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( applyButton ) ;
2022-03-23 21:38:46 +08:00
expect ( onApply ) . toBeCalledTimes ( 1 ) ;
2023-01-17 21:11:11 +08:00
expect ( onApply ) . toBeCalledWith ( [ '/subscriptions/def-123' ] ) ;
} ) ;
it ( 'should call onApply removing an element' , async ( ) = > {
const onApply = jest . fn ( ) ;
render ( < ResourcePicker { ...defaultProps } resources = { [ '/subscriptions/def-123' ] } onApply = { onApply } / > ) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'Primary Subscription' ) ) . toHaveLength ( 2 ) ;
} ) ;
2023-01-17 21:11:11 +08:00
const subscriptionCheckbox = await screen . findAllByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckbox . at ( 0 ) ) . toBeChecked ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( subscriptionCheckbox . at ( 0 ) ! ) ;
2023-01-17 21:11:11 +08:00
const applyButton = screen . getByRole ( 'button' , { name : 'Apply' } ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( applyButton ) ;
2023-01-17 21:11:11 +08:00
expect ( onApply ) . toBeCalledTimes ( 1 ) ;
expect ( onApply ) . toBeCalledWith ( [ ] ) ;
} ) ;
it ( 'should call onApply removing an element ignoring the case' , async ( ) = > {
const onApply = jest . fn ( ) ;
render (
< ResourcePicker { ...defaultProps } resources = { [ '/subscriptions/def-456/resourceGroups/DEV-3' ] } onApply = { onApply } / >
) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'A Great Resource Group' ) ) . toHaveLength ( 2 ) ;
} ) ;
2023-01-17 21:11:11 +08:00
const subscriptionCheckbox = await screen . findAllByLabelText ( 'A Great Resource Group' ) ;
expect ( subscriptionCheckbox . at ( 0 ) ) . toBeChecked ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( subscriptionCheckbox . at ( 0 ) ! ) ;
2023-01-17 21:11:11 +08:00
const applyButton = screen . getByRole ( 'button' , { name : 'Apply' } ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( applyButton ) ;
2023-01-17 21:11:11 +08:00
expect ( onApply ) . toBeCalledTimes ( 1 ) ;
expect ( onApply ) . toBeCalledWith ( [ ] ) ;
2022-02-01 16:39:48 +08:00
} ) ;
2022-03-26 02:12:52 +08:00
2023-01-24 22:44:48 +08:00
it ( 'should call onApply with a new resource when a user clicks on the checkbox in the row' , async ( ) = > {
2022-08-01 23:48:49 +08:00
const onApply = jest . fn ( ) ;
2023-01-24 22:44:48 +08:00
render ( < ResourcePicker { ...defaultProps } queryType = { 'metrics' } onApply = { onApply } resources = { [ ] } / > ) ;
const subscriptionButton = await screen . findByRole ( 'button' , { name : 'Expand Primary Subscription' } ) ;
expect ( subscriptionButton ) . toBeInTheDocument ( ) ;
expect ( screen . queryByRole ( 'button' , { name : 'Expand A Great Resource Group' } ) ) . not . toBeInTheDocument ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( subscriptionButton ) ;
2023-01-24 22:44:48 +08:00
const resourceGroupButton = await screen . findByRole ( 'button' , { name : 'Expand A Great Resource Group' } ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( resourceGroupButton ) ;
2023-01-24 22:44:48 +08:00
const checkbox = await screen . findByLabelText ( 'web-server' ) ;
await userEvent . click ( checkbox ) ;
expect ( checkbox ) . toBeChecked ( ) ;
2022-08-01 23:48:49 +08:00
const applyButton = screen . getByRole ( 'button' , { name : 'Apply' } ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( applyButton ) ;
2023-01-24 22:44:48 +08:00
2022-08-01 23:48:49 +08:00
expect ( onApply ) . toBeCalledTimes ( 1 ) ;
2023-01-24 22:44:48 +08:00
expect ( onApply ) . toBeCalledWith ( [
{
metricNamespace : 'Microsoft.Compute/virtualMachines' ,
region : 'northeurope' ,
resourceGroup : 'dev-3' ,
resourceName : 'web-server' ,
subscription : 'def-456' ,
} ,
] ) ;
2023-01-17 21:11:11 +08:00
} ) ;
it ( 'should call onApply removing a resource element' , async ( ) = > {
const onApply = jest . fn ( ) ;
2023-01-24 22:44:48 +08:00
render (
< ResourcePicker
{ . . . defaultProps }
onApply = { onApply }
resources = { [
{
metricNamespace : 'Microsoft.Compute/virtualMachines' ,
region : 'northeurope' ,
resourceGroup : 'dev-3' ,
resourceName : 'web-server' ,
subscription : 'def-456' ,
} ,
] }
/ >
) ;
2023-01-31 19:54:16 +08:00
await waitFor ( ( ) = > {
expect ( screen . queryByText ( 'Loading...' ) ) . not . toBeInTheDocument ( ) ;
} ) ;
2023-04-11 17:51:54 +08:00
await waitFor ( ( ) = > {
expect ( screen . getAllByLabelText ( 'web-server' ) ) . toHaveLength ( 2 ) ;
} ) ;
2023-01-24 22:44:48 +08:00
const checkbox = await screen . findAllByLabelText ( 'web-server' ) ;
expect ( checkbox . at ( 0 ) ) . toBeChecked ( ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( checkbox . at ( 0 ) ! ) ;
2023-01-17 21:11:11 +08:00
const applyButton = screen . getByRole ( 'button' , { name : 'Apply' } ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( applyButton ) ;
2023-01-17 21:11:11 +08:00
expect ( onApply ) . toBeCalledTimes ( 1 ) ;
expect ( onApply ) . toBeCalledWith ( [ ] ) ;
2022-08-01 23:48:49 +08:00
} ) ;
2022-05-03 09:57:56 +08:00
it ( 'renders a search field which show search results when there are results' , async ( ) = > {
render ( < ResourcePicker { ...defaultProps } / > ) ;
const searchRow1 = screen . queryByLabelText ( 'search-result' ) ;
expect ( searchRow1 ) . not . toBeInTheDocument ( ) ;
const searchField = await screen . findByLabelText ( 'resource search' ) ;
expect ( searchField ) . toBeInTheDocument ( ) ;
await userEvent . type ( searchField , 'sea' ) ;
const searchRow2 = await screen . findByLabelText ( 'search-result' ) ;
expect ( searchRow2 ) . toBeInTheDocument ( ) ;
} ) ;
it ( 'renders no results if there are no search results' , async ( ) = > {
const rpd = createMockResourcePickerData ( ) ;
rpd . search = jest . fn ( ) . mockResolvedValue ( [ ] ) ;
render ( < ResourcePicker { ...defaultProps } resourcePickerData = { rpd } / > ) ;
const searchField = await screen . findByLabelText ( 'resource search' ) ;
expect ( searchField ) . toBeInTheDocument ( ) ;
await userEvent . type ( searchField , 'some search that has no results' ) ;
const noResults = await screen . findByText ( 'No resources found' ) ;
expect ( noResults ) . toBeInTheDocument ( ) ;
} ) ;
it ( 'renders a loading state while waiting for search results' , async ( ) = > {
const rpd = createMockResourcePickerData ( ) ;
2023-03-15 18:12:13 +08:00
let promiseResolver : ( value : unknown ) = > void = ( ) = > { } ;
const promiseToResolve = new Promise ( ( resolve ) = > {
promiseResolver = resolve ;
2022-05-03 09:57:56 +08:00
} ) ;
2023-03-15 18:12:13 +08:00
rpd . search = jest . fn ( ) . mockImplementation ( ( ) = > promiseToResolve ) ;
2022-05-03 09:57:56 +08:00
render ( < ResourcePicker { ...defaultProps } resourcePickerData = { rpd } / > ) ;
const searchField = await screen . findByLabelText ( 'resource search' ) ;
expect ( searchField ) . toBeInTheDocument ( ) ;
await userEvent . type ( searchField , 'sear' ) ;
const loading = await screen . findByText ( 'Loading...' ) ;
expect ( loading ) . toBeInTheDocument ( ) ;
2023-03-15 18:12:13 +08:00
// resolve the promise
promiseResolver ( mockSearchResults ( ) ) ;
2022-05-03 09:57:56 +08:00
const searchResult = await screen . findByLabelText ( 'search-result' ) ;
expect ( searchResult ) . toBeInTheDocument ( ) ;
const loadingAfterResults = screen . queryByText ( 'Loading...' ) ;
expect ( loadingAfterResults ) . not . toBeInTheDocument ( ) ;
} ) ;
it ( 'resets result when the user clears their search' , async ( ) = > {
2023-01-17 21:11:11 +08:00
render ( < ResourcePicker { ...defaultProps } resources = { [ noResourceURI ] } / > ) ;
2022-05-03 09:57:56 +08:00
const subscriptionCheckboxBeforeSearch = await screen . findByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckboxBeforeSearch ) . toBeInTheDocument ( ) ;
const searchRow1 = screen . queryByLabelText ( 'search-result' ) ;
expect ( searchRow1 ) . not . toBeInTheDocument ( ) ;
const searchField = await screen . findByLabelText ( 'resource search' ) ;
expect ( searchField ) . toBeInTheDocument ( ) ;
await userEvent . type ( searchField , 'sea' ) ;
const searchRow2 = await screen . findByLabelText ( 'search-result' ) ;
expect ( searchRow2 ) . toBeInTheDocument ( ) ;
const subscriptionCheckboxAfterSearch = screen . queryByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckboxAfterSearch ) . not . toBeInTheDocument ( ) ;
await userEvent . clear ( searchField ) ;
const subscriptionCheckboxAfterClear = await screen . findByLabelText ( 'Primary Subscription' ) ;
expect ( subscriptionCheckboxAfterClear ) . toBeInTheDocument ( ) ;
} ) ;
2022-12-09 20:50:01 +08:00
it ( 'should throw an error if no namespaces are found' , async ( ) = > {
const resourcePickerData = createMockResourcePickerData ( [ 'getResourceGroupsBySubscriptionId' ] ) ;
render (
< ResourcePicker
{ . . . defaultProps }
queryType = { 'metrics' }
resourcePickerData = { resourcePickerData }
2023-01-17 21:11:11 +08:00
resources = { [ noResourceURI ] }
2022-12-09 20:50:01 +08:00
/ >
) ;
const subscriptionExpand = await screen . findByLabelText ( 'Expand Primary Subscription' ) ;
2023-03-15 18:12:13 +08:00
await userEvent . click ( subscriptionExpand ) ;
2022-12-09 20:50:01 +08:00
const error = await screen . findByRole ( 'alert' ) ;
expect ( error ) . toHaveTextContent ( 'An error occurred while requesting resources from Azure Monitor' ) ;
expect ( error ) . toHaveTextContent (
'Unable to resolve a list of valid metric namespaces. Validate the datasource configuration is correct and required permissions have been granted for all subscriptions. Grafana requires at least the Reader role to be assigned.'
) ;
} ) ;
2023-01-31 19:54:16 +08:00
it ( 'display a row for a selected resource even if it is not part of the current rows' , async ( ) = > {
const resourcePickerData = createMockResourcePickerData ( [ ] ) ;
resourcePickerData . fetchInitialRows = jest . fn ( ) . mockResolvedValue ( [ ] ) ;
render (
< ResourcePicker
{ . . . defaultProps }
resources = { [
{
metricNamespace : 'Microsoft.Compute/virtualMachines' ,
region : 'northeurope' ,
resourceGroup : 'dev-3' ,
resourceName : 'web-server' ,
subscription : 'def-456' ,
} ,
] }
resourcePickerData = { resourcePickerData }
/ >
) ;
const checkbox = await screen . findAllByLabelText ( 'web-server' ) ;
expect ( checkbox ) . toHaveLength ( 1 ) ;
expect ( checkbox . at ( 0 ) ) . toBeChecked ( ) ;
} ) ;
2022-03-25 19:22:28 +08:00
describe ( 'when rendering resource picker without any selectable entry types' , ( ) = > {
it ( 'renders no checkboxes' , async ( ) = > {
await act ( async ( ) = > {
render ( < ResourcePicker { ...defaultProps } selectableEntryTypes = { [ ] } / > ) ;
} ) ;
const checkboxes = screen . queryAllByRole ( 'checkbox' ) ;
expect ( checkboxes . length ) . toBe ( 0 ) ;
} ) ;
} ) ;
2022-02-01 16:39:48 +08:00
} ) ;