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 @@ -73,17 +73,20 @@ export function FilterResultsStep({
};
}, []);

const handleBlur = useCallback((queryIndex: number) => {
return (field: string) => {
if (!blurTimeoutRef.current) {
const newQuery: WidgetQuery = {
...queries[queryIndex],
conditions: field,
};
onQueryChange(queryIndex, newQuery);
}
};
}, []);
const handleBlur = useCallback(
(queryIndex: number) => {
return (field: string) => {
if (!blurTimeoutRef.current) {
const newQuery: WidgetQuery = {
...queries[queryIndex],
conditions: field,
};
onQueryChange(queryIndex, newQuery);
}
};
},
[queries]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that was the queries... funny, I would have fixed this in the PR #33241

Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to do the same with handleSearch 😉

);

return (
<BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {urlEncode} from '@sentry/utils';

import {initializeOrg} from 'sentry-test/initializeOrg';
import {mountGlobalModal} from 'sentry-test/modal';
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
import {act, render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
import {textWithMarkupMatcher} from 'sentry-test/utils';

import * as indicators from 'sentry/actionCreators/indicator';
Expand Down Expand Up @@ -177,6 +177,7 @@ describe('WidgetBuilder', function () {
afterEach(function () {
MockApiClient.clearMockResponses();
jest.clearAllMocks();
jest.useRealTimers();
});

it('no feature access', function () {
Expand Down Expand Up @@ -1062,6 +1063,50 @@ describe('WidgetBuilder', function () {
});
});

it('does not error when query conditions field is blurred', async function () {
jest.useFakeTimers();
const widget: Widget = {
id: '0',
title: 'sdk usage',
interval: '5m',
displayType: DisplayType.BAR,
queries: [
{
name: 'filled in',
conditions: 'event.type:error',
fields: ['count()', 'count_unique(id)'],
aggregates: ['count()', 'count_unique(id)'],
columns: [],
orderby: '-count',
},
],
};

const dashboard: DashboardDetails = {
id: '1',
title: 'Dashboard',
createdBy: undefined,
dateCreated: '2020-01-01T00:00:00.000Z',
widgets: [widget],
};

const handleSave = jest.fn();

renderTestComponent({dashboard, onSave: handleSave, params: {widgetIndex: '0'}});

userEvent.click(await screen.findByLabelText('Add Query'));

// Triggering the onBlur of the new field should not error
userEvent.click(
screen.getAllByPlaceholderText('Search for events, users, tags, and more')[1]
);
userEvent.keyboard('{esc}');
act(() => {
// Run all timers because the handleBlur contains a setTimeout
jest.runAllTimers();
});
});

describe('Sort by selectors', function () {
it('renders', async function () {
renderTestComponent({
Expand Down