mirror of
https://github.com/grafana/grafana.git
synced 2025-01-13 09:32:12 -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 { mount } from 'enzyme';
|
||||
import { CustomHeadersSettings, Props } from './CustomHeadersSettings';
|
||||
import { Button } from '../Button';
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const props: Props = {
|
||||
@ -48,6 +49,11 @@ describe('Render', () => {
|
||||
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', () => {
|
||||
const wrapper = setup({
|
||||
dataSourceConfig: {
|
||||
|
@ -206,6 +206,7 @@ export class CustomHeadersSettings extends PureComponent<Props, State> {
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon="plus"
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
this.onHeaderAdd();
|
||||
}}
|
||||
|
@ -38,6 +38,12 @@ describe('DerivedFields', () => {
|
||||
expect(wrapper.find(Button).filterWhere((button: any) => button.contains('Show example log message')).length).toBe(
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -82,7 +82,7 @@ export const DerivedFields = (props: Props) => {
|
||||
</Button>
|
||||
|
||||
{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'}
|
||||
</Button>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user