2022-03-21 02:59:26 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2024-01-01 02:43:48 -06:00
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2022-03-21 02:59:26 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2022-03-21 02:59:26 -05:00
|
|
|
import React from 'react';
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2022-03-21 02:59:26 -05:00
|
|
|
import { withTheme } from '../fake_theme';
|
2023-10-23 07:13:17 -05:00
|
|
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
|
|
import userEvent from '@testing-library/user-event';
|
2022-03-21 02:59:26 -05:00
|
|
|
import QueryThresholds from '../../../pgadmin/static/js/components/QueryThresholds';
|
|
|
|
|
|
|
|
/* MUI Components need to be wrapped in Theme for theme vars */
|
|
|
|
describe('QueryThresholds', () => {
|
|
|
|
let defult_value = {
|
|
|
|
'warning': 5,
|
|
|
|
'alert': 6
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('QueryThresholds', () => {
|
2023-10-23 07:13:17 -05:00
|
|
|
let ThemedFormInputQueryThresholds = withTheme(QueryThresholds);
|
|
|
|
let onChange = jest.fn();
|
2022-03-21 02:59:26 -05:00
|
|
|
beforeEach(() => {
|
2023-10-23 07:13:17 -05:00
|
|
|
render(
|
2022-03-21 02:59:26 -05:00
|
|
|
<ThemedFormInputQueryThresholds
|
2022-03-23 02:58:35 -05:00
|
|
|
testcid="QueryThresholdCid"
|
2022-03-21 02:59:26 -05:00
|
|
|
helpMessage="some help message"
|
|
|
|
value={defult_value}
|
|
|
|
controlProps={{
|
|
|
|
extraprop: 'test'
|
|
|
|
}}
|
2022-03-23 02:58:35 -05:00
|
|
|
onChange={onChange}
|
2022-03-21 02:59:26 -05:00
|
|
|
/>);
|
|
|
|
});
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
it('Warning', async () => {
|
|
|
|
const user = userEvent.setup();
|
|
|
|
const inp = screen.getAllByRole('textbox').at(0);
|
|
|
|
await user.type(inp, '7');
|
|
|
|
await waitFor(()=>{
|
|
|
|
expect(onChange).toHaveBeenCalledWith({ warning: '57', alert: 6 });
|
|
|
|
});
|
2022-03-21 02:59:26 -05:00
|
|
|
});
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
it('Alert', async () => {
|
|
|
|
const user = userEvent.setup();
|
|
|
|
const inp = screen.getAllByRole('textbox').at(1);
|
|
|
|
await user.type(inp, '8');
|
|
|
|
await waitFor(()=>{
|
|
|
|
expect(onChange).toHaveBeenCalledWith({ warning: 5, alert: '68' });
|
|
|
|
});
|
2022-03-21 02:59:26 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|