⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
explore
/
View File Name :
SecondaryActions.test.tsx
import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { noop } from 'lodash'; import React from 'react'; import { SecondaryActions } from './SecondaryActions'; describe('SecondaryActions', () => { it('should render component with three buttons', () => { render(
); expect(screen.getByRole('button', { name: /Add query/i })).toBeInTheDocument(); expect(screen.getByRole('button', { name: /Query history/i })).toBeInTheDocument(); expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should not render hidden elements', () => { render(
); expect(screen.queryByRole('button', { name: /Add query/i })).not.toBeInTheDocument(); expect(screen.queryByRole('button', { name: /Query history/i })).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should disable add row button if addQueryRowButtonDisabled=true', () => { render(
); expect(screen.getByRole('button', { name: /Add query/i })).toBeDisabled(); expect(screen.getByRole('button', { name: /Query history/i })).toBeInTheDocument(); expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should map click handlers correctly', async () => { const user = userEvent.setup(); const onClickAddRow = jest.fn(); const onClickHistory = jest.fn(); const onClickQueryInspector = jest.fn(); render(
); await user.click(screen.getByRole('button', { name: /Add query/i })); expect(onClickAddRow).toBeCalledTimes(1); await user.click(screen.getByRole('button', { name: /Query history/i })); expect(onClickHistory).toBeCalledTimes(1); await user.click(screen.getByRole('button', { name: /Query inspector/i })); expect(onClickQueryInspector).toBeCalledTimes(1); }); });