-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/block-empty-dir-inplace-migration
- Loading branch information
Showing
10 changed files
with
109 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "fixed" | ||
message = "Fix handling of path prefix in `useSendTelemetry`." | ||
|
||
issues = ["20899"] | ||
pulls = ["20909"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type = "fixed" | ||
message = "Fixing replay search routes when path prefix is present." | ||
|
||
pulls = ["20910"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
graylog2-web-interface/src/logic/telemetry/useSendTelemetry.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import * as React from 'react'; | ||
import { renderHook } from 'wrappedTestingLibrary/hooks'; | ||
|
||
import TelemetryContext from 'logic/telemetry/TelemetryContext'; | ||
|
||
import useSendTelemetry from './useSendTelemetry'; | ||
|
||
jest.mock('util/AppConfig'); | ||
|
||
const contextValue = { | ||
sendTelemetry: jest.fn(), | ||
}; | ||
const DummyTelemetryContext = ({ children = undefined }: React.PropsWithChildren<{}>) => ( | ||
<TelemetryContext.Provider value={contextValue}>{children}</TelemetryContext.Provider> | ||
); | ||
|
||
describe('useSendTelemetry', () => { | ||
const setLocation = (pathname: string) => Object.defineProperty(window, 'location', { | ||
value: { | ||
pathname, | ||
}, | ||
writable: true, | ||
}); | ||
|
||
const oldLocation = window.location; | ||
|
||
afterEach(() => { | ||
window.location = oldLocation; | ||
}); | ||
|
||
it('should return `sendTelemetry` that retrieves current route', () => { | ||
setLocation('/welcome'); | ||
const { result } = renderHook(() => useSendTelemetry(), { wrapper: DummyTelemetryContext }); | ||
|
||
const sendTelemetry = result.current; | ||
|
||
expect(sendTelemetry).toBeDefined(); | ||
|
||
sendTelemetry('$pageview', { app_section: 'welcome section' }); | ||
|
||
expect(contextValue.sendTelemetry).toHaveBeenCalledWith('$pageview', { app_path_pattern: undefined, app_section: 'welcome section' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters