From 1e07c7c8749e5e577d9d57fbfdc714567138aad6 Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:50:50 -0500 Subject: [PATCH] InfluxDB: Tests for #73247 (#73250) * add test assertions to cover default config UI state in influxDB plugin --- .../editor/config/ConfigEditor.test.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.test.tsx b/public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.test.tsx index c3a6179e9a7..ccf2646b950 100644 --- a/public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.test.tsx +++ b/public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.test.tsx @@ -1,6 +1,8 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; +import { InfluxVersion } from '../../../types'; + import ConfigEditor, { Props } from './ConfigEditor'; jest.mock('lodash', () => { @@ -62,6 +64,30 @@ describe('ConfigEditor', () => { expect(screen.getByDisplayValue('configured')).toBeInTheDocument(); }); + it('influxQL options should show up if version is not defined', () => { + setup({}); + expect(screen.queryByLabelText('Password')).toBeInTheDocument(); + }); + + it('influxQL options should show up if version is ill-defined', () => { + setup({ + jsonData: { + version: 'influx', + }, + }); + expect(screen.queryByLabelText('Password')).toBeInTheDocument(); + }); + + it('influxQL options should not show up if version is defined as flux', () => { + setup({ + jsonData: { + version: InfluxVersion.Flux, + }, + }); + expect(screen.queryByLabelText('Password')).not.toBeInTheDocument(); + expect(screen.queryByLabelText('Token')).toBeInTheDocument(); + }); + it('should hide white listed cookies input when browser access chosen', () => { setup({ access: 'direct',