|
|
@ -1,4 +1,4 @@ |
|
|
|
import { act, render, screen } from '@testing-library/react'; |
|
|
|
import { act, render, screen, waitFor } from '@testing-library/react'; |
|
|
|
import userEvent from '@testing-library/user-event'; |
|
|
|
import userEvent from '@testing-library/user-event'; |
|
|
|
import { omit } from 'lodash'; |
|
|
|
import { omit } from 'lodash'; |
|
|
|
import React from 'react'; |
|
|
|
import React from 'react'; |
|
|
@ -105,6 +105,9 @@ describe('AzureMonitor ResourcePicker', () => { |
|
|
|
|
|
|
|
|
|
|
|
it('should show scroll down to a resource and mark it as selected if there is one saved', async () => { |
|
|
|
it('should show scroll down to a resource and mark it as selected if there is one saved', async () => { |
|
|
|
render(<ResourcePicker {...defaultProps} resources={[singleResourceSelectionURI]} />); |
|
|
|
render(<ResourcePicker {...defaultProps} resources={[singleResourceSelectionURI]} />); |
|
|
|
|
|
|
|
await waitFor(() => { |
|
|
|
|
|
|
|
expect(screen.queryByText('Loading...')).not.toBeInTheDocument(); |
|
|
|
|
|
|
|
}); |
|
|
|
const resourceCheckboxes = await screen.findAllByLabelText('db-server'); |
|
|
|
const resourceCheckboxes = await screen.findAllByLabelText('db-server'); |
|
|
|
expect(resourceCheckboxes.length).toBe(2); |
|
|
|
expect(resourceCheckboxes.length).toBe(2); |
|
|
|
expect(resourceCheckboxes[0]).toBeChecked(); |
|
|
|
expect(resourceCheckboxes[0]).toBeChecked(); |
|
|
@ -222,6 +225,9 @@ describe('AzureMonitor ResourcePicker', () => { |
|
|
|
]} |
|
|
|
]} |
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
await waitFor(() => { |
|
|
|
|
|
|
|
expect(screen.queryByText('Loading...')).not.toBeInTheDocument(); |
|
|
|
|
|
|
|
}); |
|
|
|
const checkbox = await screen.findAllByLabelText('web-server'); |
|
|
|
const checkbox = await screen.findAllByLabelText('web-server'); |
|
|
|
expect(checkbox).toHaveLength(2); |
|
|
|
expect(checkbox).toHaveLength(2); |
|
|
|
expect(checkbox.at(0)).toBeChecked(); |
|
|
|
expect(checkbox.at(0)).toBeChecked(); |
|
|
@ -332,6 +338,29 @@ describe('AzureMonitor ResourcePicker', () => { |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('when rendering resource picker without any selectable entry types', () => { |
|
|
|
describe('when rendering resource picker without any selectable entry types', () => { |
|
|
|
it('renders no checkboxes', async () => { |
|
|
|
it('renders no checkboxes', async () => { |
|
|
|
await act(async () => { |
|
|
|
await act(async () => { |
|
|
|