Skip to content

Commit

Permalink
fix tests and not calling blur manually
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Jun 27, 2023
1 parent 3b4d054 commit 10bbd74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export class EventReporter {
* Called when the users selects an application in their search results
*/
public navigateToApplication(context: TrackedApplicationClick) {
this.searchBlur();

const application = context?.application ?? 'unknown';

this.trackUiMetric(METRIC_TYPE.CLICK, ClickMetric.USER_NAVIGATED_TO_APPLICATION, application);
Expand All @@ -116,8 +114,6 @@ export class EventReporter {
* Called when the users selects Saved Object in their search results
*/
public navigateToSavedObject(context: TrackedSavedObjectClick) {
this.searchBlur();

const type = context?.type ?? 'unknown';

this.trackUiMetric(METRIC_TYPE.CLICK, ClickMetric.USER_NAVIGATED_TO_SAVED_OBJECT, type);
Expand Down
22 changes: 11 additions & 11 deletions x-pack/plugins/global_search_bar/public/telemetry/telmetry.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ describe('SearchBar', () => {

fireEvent.click(await screen.findByTestId('nav-search-option'));

expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_blur', {
focus_time_ms: 1000,
});
expect(mockReportEvent).nthCalledWith(2, 'global_search_bar_click_application', {
expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_click_application', {
selected_rank: 1,
selected_term: 'Discover',
selected_label: 'Discover',
application: 'discover',
terms: '',
});
expect(mockReportEvent).nthCalledWith(2, 'global_search_bar_blur', {
focus_time_ms: 1000,
});
expect(mockReportEvent).toHaveBeenCalledTimes(2);
});

Expand Down Expand Up @@ -219,15 +219,15 @@ describe('SearchBar', () => {

fireEvent.click(await screen.findByTestId('nav-search-option'));

expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_blur', {
focus_time_ms: 1000,
});
expect(mockReportEvent).nthCalledWith(2, 'global_search_bar_click_application', {
expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_click_application', {
selected_rank: 1,
selected_term: 'Discover',
selected_label: 'Discover',
application: 'discover',
terms: 'Ahoy!',
});
expect(mockReportEvent).nthCalledWith(2, 'global_search_bar_blur', {
focus_time_ms: 1000,
});
expect(mockReportEvent).toHaveBeenCalledTimes(2);
});

Expand All @@ -251,7 +251,7 @@ describe('SearchBar', () => {

await focusAndUpdate();

expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_unhandled_error', {
expect(mockReportEvent).nthCalledWith(1, 'global_search_bar_error', {
error_message: 'Error: service unavailable :(',
terms: 'Ahoy!',
});
Expand Down

0 comments on commit 10bbd74

Please sign in to comment.