mirror of
https://github.com/grafana/grafana.git
synced 2025-01-14 02:32:29 -06:00
Prevent submitting the datasource form in Loki's datasource configuration page (#31823)
This commit is contained in:
parent
c764bca58f
commit
d0fa7b81f0
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { CustomHeadersSettings, Props } from './CustomHeadersSettings';
|
import { CustomHeadersSettings, Props } from './CustomHeadersSettings';
|
||||||
|
import { Button } from '../Button';
|
||||||
|
|
||||||
const setup = (propOverrides?: object) => {
|
const setup = (propOverrides?: object) => {
|
||||||
const props: Props = {
|
const props: Props = {
|
||||||
@ -48,6 +49,11 @@ describe('Render', () => {
|
|||||||
expect(wrapper.find('SecretFormField').exists()).toBeTruthy();
|
expect(wrapper.find('SecretFormField').exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('add header button should not submit the form', () => {
|
||||||
|
const wrapper = setup();
|
||||||
|
expect(wrapper.find(Button).getDOMNode()).toHaveAttribute('type', 'button');
|
||||||
|
});
|
||||||
|
|
||||||
it('should remove a header', () => {
|
it('should remove a header', () => {
|
||||||
const wrapper = setup({
|
const wrapper = setup({
|
||||||
dataSourceConfig: {
|
dataSourceConfig: {
|
||||||
|
@ -206,6 +206,7 @@ export class CustomHeadersSettings extends PureComponent<Props, State> {
|
|||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon="plus"
|
icon="plus"
|
||||||
|
type="button"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
this.onHeaderAdd();
|
this.onHeaderAdd();
|
||||||
}}
|
}}
|
||||||
|
@ -38,6 +38,12 @@ describe('DerivedFields', () => {
|
|||||||
expect(wrapper.find(Button).filterWhere((button: any) => button.contains('Show example log message')).length).toBe(
|
expect(wrapper.find(Button).filterWhere((button: any) => button.contains('Show example log message')).length).toBe(
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
wrapper
|
||||||
|
.find(Button)
|
||||||
|
.filterWhere((button: any) => button.contains('Show example log message'))
|
||||||
|
.getDOMNode()
|
||||||
|
).toHaveAttribute('type', 'button');
|
||||||
expect(wrapper.find(DerivedField).length).toBe(2);
|
expect(wrapper.find(DerivedField).length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ export const DerivedFields = (props: Props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{value && value.length > 0 && (
|
{value && value.length > 0 && (
|
||||||
<Button variant="secondary" onClick={() => setShowDebug(!showDebug)}>
|
<Button variant="secondary" type="button" onClick={() => setShowDebug(!showDebug)}>
|
||||||
{showDebug ? 'Hide example log message' : 'Show example log message'}
|
{showDebug ? 'Hide example log message' : 'Show example log message'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user