/usr/share/grafana/public/app/plugins/datasource/influxdb/components/editor/config-v2
import '@testing-library/jest-dom'; import { render, screen, fireEvent } from '@testing-library/react'; import { InfluxVersion } from '../../../types'; import { AdvancedDbConnectionSettings } from './AdvancedDBConnectionSettings'; import { createTestProps } from './helpers'; describe('AdvancedDbConnectionSettings', () => { const onOptionsChangeMock = jest.fn(); const defaultProps = createTestProps({ options: { jsonData: {}, secureJsonData: {}, secureJsonFields: {}, }, mocks: { onOptionsChange: onOptionsChangeMock, }, }); beforeEach(() => { jest.clearAllMocks(); }); it('toggles visibility of advanced settings', () => { render(<AdvancedDbConnectionSettings {...defaultProps} />); const toggle = screen.getByTestId('influxdb-v2-config-toggle-switch'); fireEvent.click(toggle); }); it('renders HTTP Method field for InfluxQL version', () => { const props = { ...defaultProps, options: { ...defaultProps.options, jsonData: { version: InfluxVersion.InfluxQL }, }, }; render(<AdvancedDbConnectionSettings {...props} />); const toggle = screen.getByTestId('influxdb-v2-config-toggle-switch'); fireEvent.click(toggle); expect(screen.getByTestId('influxdb-v2-config-http-method-select')).toBeInTheDocument(); }); it('renders insecure connection switch for SQL version and triggers change', () => { const props = { ...defaultProps, options: { ...defaultProps.options, jsonData: { version: InfluxVersion.SQL, insecureGrpc: false }, }, }; render(<AdvancedDbConnectionSettings {...props} />); const toggle = screen.getByTestId('influxdb-v2-config-toggle-switch'); fireEvent.click(toggle); const switchEl = screen.getByTestId('influxdb-v2-config-insecure-switch'); expect(switchEl).toBeInTheDocument(); fireEvent.click(switchEl); expect(onOptionsChangeMock).toHaveBeenCalled(); }); it('renders Min time interval input for InfluxQL', () => { const props = { ...defaultProps, options: { ...defaultProps.options, jsonData: { version: InfluxVersion.InfluxQL, timeInterval: '' }, }, }; render(<AdvancedDbConnectionSettings {...props} />); const toggle = screen.getByTestId('influxdb-v2-config-toggle-switch'); fireEvent.click(toggle); const input = screen.getByTestId('influxdb-v2-config-time-interval'); expect(input).toBeInTheDocument(); fireEvent.change(input, { target: { value: '15' } }); expect(onOptionsChangeMock).toHaveBeenCalled(); }); it('renders Min time interval input for Flux', () => { const props = { ...defaultProps, options: { ...defaultProps.options, jsonData: { version: InfluxVersion.Flux, timeInterval: '' }, }, }; render(<AdvancedDbConnectionSettings {...props} />); const toggle = screen.getByTestId('influxdb-v2-config-toggle-switch'); fireEvent.click(toggle); const input = screen.getByTestId('influxdb-v2-config-time-interval'); expect(input).toBeInTheDocument(); fireEvent.change(input, { target: { value: '15' } }); expect(onOptionsChangeMock).toHaveBeenCalled(); }); });
.
Edit
..
Edit
AdvancedDBConnectionSettings.test.tsx
Edit
AdvancedDBConnectionSettings.tsx
Edit
AdvancedHttpSettings.test.tsx
Edit
AdvancedHttpSettings.tsx
Edit
AuthSettings.test.tsx
Edit
AuthSettings.tsx
Edit
ConfigEditor.test.tsx
Edit
ConfigEditor.tsx
Edit
DatabaseConnectionSection.test.tsx
Edit
DatabaseConnectionSection.tsx
Edit
InfluxFluxDBConnection.test.tsx
Edit
InfluxFluxDBConnection.tsx
Edit
InfluxInfluxQLDBConnection.test.tsx
Edit
InfluxInfluxQLDBConnection.tsx
Edit
InfluxSQLDBConnection.test.tsx
Edit
InfluxSQLDBConnection.tsx
Edit
LeftSideBar.test.tsx
Edit
LeftSideBar.tsx
Edit
UrlAndAuthenticationSection.test.tsx
Edit
UrlAndAuthenticationSection.tsx
Edit
constants.ts
Edit
helpers.ts
Edit
tracking.ts
Edit
types.ts
Edit
versions.ts
Edit