Skip to content

Commit ad1a890

Browse files
authored
Merge pull request #764 from RedisInsight/bugfix/fix-tests
# fix errors during ui tests
2 parents 3c8dbae + a9b297d commit ad1a890

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

redisinsight/ui/src/components/config/Config.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
setAnalyticsIdentified,
1616
} from 'uiSrc/slices/app/info'
1717

18-
import { checkIsAnalyticsGranted, getTelemetryService } from 'uiSrc/telemetry'
18+
import { getTelemetryService } from 'uiSrc/telemetry'
19+
import { checkIsAnalyticsGranted } from 'uiSrc/telemetry/checkAnalytics'
1920
import { setFavicon, isDifferentConsentsExists } from 'uiSrc/utils'
2021
import { fetchUnsupportedCliCommandsAction } from 'uiSrc/slices/cli/cli-settings'
2122
import { fetchRedisCommandsInfo } from 'uiSrc/slices/app/redis-commands'

redisinsight/ui/src/slices/tests/browser/stream.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from 'apiSrc/modules/browser/dto/stream.dto'
88
import { AxiosError } from 'axios'
99
import { cloneDeep, omit } from 'lodash'
10+
import { cleanup, initialStateDefault, mockedStore, } from 'uiSrc/utils/test-utils'
1011
import successMessages from 'uiSrc/components/notifications/success-messages'
1112
import { SortOrder } from 'uiSrc/constants'
1213
import { apiService } from 'uiSrc/services'
@@ -71,7 +72,6 @@ import reducer, {
7172
deleteMessageFromList
7273
} from 'uiSrc/slices/browser/stream'
7374
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
74-
import { cleanup, initialStateDefault, mockedStore, } from 'uiSrc/utils/test-utils'
7575
import { addErrorNotification, addMessageNotification } from '../../app/notifications'
7676

7777
jest.mock('uiSrc/services')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { get } from 'lodash'
2+
import store from 'uiSrc/slices/store'
3+
4+
// Check is user give access to collect his events
5+
export const checkIsAnalyticsGranted = () =>
6+
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
* Telemetry and analytics module.
33
* This module abstracts the exact service/framework used for tracking usage.
44
*/
5-
import { get } from 'lodash'
65
import isGlob from 'is-glob'
76
import * as jsonpath from 'jsonpath'
87
import { Nullable } from 'uiSrc/utils'
9-
import store from 'uiSrc/slices/store'
108
import { localStorageService } from 'uiSrc/services'
119
import { ApiEndpoints, BrowserStorageItem, KeyTypes } from 'uiSrc/constants'
1210
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
11+
import { checkIsAnalyticsGranted } from 'uiSrc/telemetry/checkAnalytics'
1312
import { ITelemetrySendEvent, ITelemetrySendPageView, ITelemetryService, MatchType } from './interfaces'
1413
import { TelemetryEvent } from './events'
1514
import { NON_TRACKING_ANONYMOUS_ID, SegmentTelemetryService } from './segment'
@@ -29,10 +28,6 @@ const getTelemetryService = (apiKey: string): ITelemetryService => {
2928
return telemetryService
3029
}
3130

32-
// Check is user give access to collect his events
33-
const checkIsAnalyticsGranted = () =>
34-
!!get(store.getState(), 'user.settings.config.agreements.analytics', false)
35-
3631
// Telemetry doesn't watch on sending anonymousId like arg of function. Only look at localStorage
3732
const setAnonymousId = (isAnalyticsGranted: boolean) => {
3833
const anonymousId = isAnalyticsGranted

redisinsight/ui/src/utils/test-utils.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ jest.mock(
160160
() => ({ children }) => children({ height: 600, width: 600 })
161161
)
162162

163+
jest.mock(
164+
'uiSrc/telemetry/checkAnalytics',
165+
() => ({
166+
checkIsAnalyticsGranted: jest.fn()
167+
})
168+
)
169+
163170
export const localStorageMock = {
164171
getItem: jest.fn(),
165172
setItem: jest.fn(),

0 commit comments

Comments
 (0)