Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { cloneDeep } from 'lodash'
import React from 'react'
import { instance, mock } from 'ts-mockito'
import { cleanup, mockedStore, render, fireEvent, act, screen, waitForEuiToolTipVisible } from 'uiSrc/utils/test-utils'
import { TelemetryEvent, sendEventTelemetry } from 'uiSrc/telemetry'
import { INSTANCE_ID_MOCK } from 'uiSrc/mocks/handlers/instances/instancesHandlers'
import QueryCardHeader, { Props } from './QueryCardHeader'

const mockedProps = mock<Props>()
Expand All @@ -30,11 +28,6 @@ jest.mock('uiSrc/slices/app/plugins', () => ({
}),
}))

jest.mock('uiSrc/telemetry', () => ({
...jest.requireActual('uiSrc/telemetry'),
sendEventTelemetry: jest.fn(),
}))

describe('QueryCardHeader', () => {
it('should render', () => {
// connectedInstanceSelector.mockImplementation(() => ({
Expand Down Expand Up @@ -64,25 +57,4 @@ describe('QueryCardHeader', () => {

expect(screen.getByTestId('copy-command')).toBeDisabled()
})

it('should render disabled copy button', async () => {
const command = 'info'
const sendEventTelemetryMock = jest.fn();
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
render(<QueryCardHeader {...instance(mockedProps)} query={command} />)

await act(async () => {
fireEvent.click(screen.getByTestId('copy-command'))
})

expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.WORKBENCH_COMMAND_COPIED,
eventData: {
command,
databaseId: INSTANCE_ID_MOCK,
}
});

(sendEventTelemetry as jest.Mock).mockRestore()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ const QueryCardHeader = (props: Props) => {
eventData: {
databaseId: instanceId,
command: getCommandNameFromQuery(query, COMMANDS_SPEC),
rawMode: isRawMode(activeMode),
group: isGroupMode(activeResultsMode),
...additionalData
}
})
Expand All @@ -137,7 +139,7 @@ const QueryCardHeader = (props: Props) => {
const handleCopy = (event: React.MouseEvent, query: string) => {
sendEvent(TelemetryEvent.WORKBENCH_COMMAND_COPIED, query)
eventStop(event)
navigator.clipboard?.writeText?.(query)
navigator.clipboard.writeText(query)
}

const onDropDownViewClick = (event: React.MouseEvent) => {
Expand All @@ -154,8 +156,6 @@ const QueryCardHeader = (props: Props) => {
TelemetryEvent.WORKBENCH_RESULT_VIEW_CHANGED,
query,
{
rawMode: isRawMode(activeMode),
group: isGroupMode(activeResultsMode),
previousView: previousView.name,
isPreviousViewInternal: !!previousView?.internal,
currentView: currentView.name,
Expand Down