mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-13 05:21:31 +08:00

* feat: qb-suggestions base setup * chore: make the dropdown a little similar to the designs * chore: move out example queries from og and add to renderer * chore: added the handlers for example queries * chore: hide the example queries as soon as the user starts typing * feat: handle changes for cancel query * chore: remove stupid concept of option group * chore: show only first 3 items and add option to show all filters * chore: minor css changes and remove transitions * feat: integrate suggestions api and control re-renders * feat: added keyboard shortcuts for the dropdown * fix: design cleanups and touchups * fix: build issues and tests * chore: extra safety check for base64 and fix tests * fix: qs doesn't handle padding in base64 strings, added client logic * chore: some code comments * chore: some code comments * chore: increase the height of the bar when key is set * chore: address minor designs * chore: update the keyboard shortcut to cmd+/ * feat: correct the option render for logs for tooltip * chore: search bar to not loose focus on btn click * fix: update the spacing and icon for search bar * chore: address review comments
109 lines
3.2 KiB
TypeScript
109 lines
3.2 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import { SELECTED_VIEWS } from 'pages/LogsExplorer/utils';
|
|
import MockQueryClientProvider from 'providers/test/MockQueryClientProvider';
|
|
|
|
import LeftToolbarActions from '../LeftToolbarActions';
|
|
import RightToolbarActions from '../RightToolbarActions';
|
|
|
|
describe('ToolbarActions', () => {
|
|
it('LeftToolbarActions - renders correctly with default props', async () => {
|
|
const handleChangeSelectedView = jest.fn();
|
|
const handleToggleShowFrequencyChart = jest.fn();
|
|
const { queryByTestId } = render(
|
|
<LeftToolbarActions
|
|
items={{
|
|
search: {
|
|
name: 'search',
|
|
label: 'Search',
|
|
disabled: false,
|
|
show: true,
|
|
},
|
|
queryBuilder: {
|
|
name: 'query-builder',
|
|
label: 'Query Builder',
|
|
disabled: false,
|
|
show: true,
|
|
},
|
|
clickhouse: {
|
|
name: 'clickhouse',
|
|
label: 'Clickhouse',
|
|
disabled: false,
|
|
},
|
|
}}
|
|
selectedView={SELECTED_VIEWS.SEARCH}
|
|
onChangeSelectedView={handleChangeSelectedView}
|
|
onToggleHistrogramVisibility={handleToggleShowFrequencyChart}
|
|
showFrequencyChart
|
|
/>,
|
|
);
|
|
expect(screen.getByTestId('search-view')).toBeInTheDocument();
|
|
expect(screen.getByTestId('query-builder-view')).toBeInTheDocument();
|
|
|
|
// clickhouse should not be present as its show: false
|
|
expect(queryByTestId('clickhouse-view')).not.toBeInTheDocument();
|
|
|
|
await userEvent.click(screen.getByTestId('search-view'));
|
|
expect(handleChangeSelectedView).toBeCalled();
|
|
|
|
await userEvent.click(screen.getByTestId('query-builder-view'));
|
|
expect(handleChangeSelectedView).toBeCalled();
|
|
});
|
|
|
|
it('renders - clickhouse view and test histogram toggle', async () => {
|
|
const handleChangeSelectedView = jest.fn();
|
|
const handleToggleShowFrequencyChart = jest.fn();
|
|
const { queryByTestId, getByRole } = render(
|
|
<LeftToolbarActions
|
|
items={{
|
|
search: {
|
|
name: 'search',
|
|
label: 'Search',
|
|
disabled: false,
|
|
show: false,
|
|
},
|
|
queryBuilder: {
|
|
name: 'query-builder',
|
|
label: 'Query Builder',
|
|
disabled: false,
|
|
show: true,
|
|
},
|
|
clickhouse: {
|
|
name: 'clickhouse',
|
|
label: 'Clickhouse',
|
|
disabled: false,
|
|
show: true,
|
|
},
|
|
}}
|
|
selectedView={SELECTED_VIEWS.QUERY_BUILDER}
|
|
onChangeSelectedView={handleChangeSelectedView}
|
|
onToggleHistrogramVisibility={handleToggleShowFrequencyChart}
|
|
showFrequencyChart
|
|
/>,
|
|
);
|
|
|
|
const clickHouseView = queryByTestId('clickhouse-view');
|
|
expect(clickHouseView).toBeInTheDocument();
|
|
|
|
await userEvent.click(clickHouseView as HTMLElement);
|
|
expect(handleChangeSelectedView).toBeCalled();
|
|
|
|
await userEvent.click(getByRole('switch'));
|
|
expect(handleToggleShowFrequencyChart).toBeCalled();
|
|
});
|
|
|
|
it('RightToolbarActions - render correctly with props', async () => {
|
|
const onStageRunQuery = jest.fn();
|
|
const { queryByText } = render(
|
|
<MockQueryClientProvider>
|
|
<RightToolbarActions onStageRunQuery={onStageRunQuery} />,
|
|
</MockQueryClientProvider>,
|
|
);
|
|
|
|
const stageNRunBtn = queryByText('Stage & Run Query');
|
|
expect(stageNRunBtn).toBeInTheDocument();
|
|
await userEvent.click(stageNRunBtn as HTMLElement);
|
|
expect(onStageRunQuery).toBeCalled();
|
|
});
|
|
});
|