Skip to content

Commit 98e525b

Browse files
committed
Merge branch 'main' into feature/RI-3646_Change_Expiration_timeline_to_Bar_chart
2 parents 85a9cdc + 9d75621 commit 98e525b

File tree

15 files changed

+261
-184
lines changed

15 files changed

+261
-184
lines changed

redisinsight/ui/src/components/notifications/Notifications.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const Notifications = () => {
5454
size="s"
5555
onClick={() => onSubmitNotification(toast, group)}
5656
className={styles.toastSuccessBtn}
57+
data-testid="submit-tooltip-btn"
5758
>
5859
Ok
5960
</EuiButton>

redisinsight/ui/src/pages/browser/components/keys-header/styles.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
padding: 18px 18px 0;
77

88
display: flex;
9+
flex-shrink: 0;
910
flex-direction: column;
1011
position: relative;
1112

redisinsight/ui/src/pages/databaseAnalysis/components/header/Header.spec.tsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import React from 'react'
22
import { cloneDeep } from 'lodash'
3+
import { useSelector } from 'react-redux'
34
import { instance, mock } from 'ts-mockito'
45
import { getDBAnalysis } from 'uiSrc/slices/analytics/dbAnalysis'
6+
import { RootState } from 'uiSrc/slices/store'
57
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
68
import { INSTANCE_ID_MOCK } from 'uiSrc/mocks/handlers/analytics/clusterDetailsHandlers'
79

810
import {
11+
act,
912
cleanup,
1013
mockedStore,
1114
fireEvent,
1215
render,
1316
screen,
17+
waitForEuiToolTipVisible,
1418
} from 'uiSrc/utils/test-utils'
1519

1620
import Header, { Props } from './Header'
@@ -41,7 +45,33 @@ jest.mock('uiSrc/telemetry', () => ({
4145
sendEventTelemetry: jest.fn(),
4246
}))
4347

48+
jest.mock('react-redux', () => ({
49+
...jest.requireActual('react-redux'),
50+
useSelector: jest.fn(),
51+
}))
52+
53+
const connectType = (state: any, connectionType: any) => {
54+
(useSelector as jest.Mock).mockImplementation((callback: (arg0: RootState) => RootState) => callback({
55+
...state,
56+
connections: {
57+
...state.connections,
58+
instances: {
59+
...state.connections.instances,
60+
connectedInstance: {
61+
...state.connections.instances.connectedInstance,
62+
connectionType,
63+
}
64+
}
65+
},
66+
}))
67+
}
68+
4469
describe('DatabaseAnalysisHeader', () => {
70+
beforeEach(() => {
71+
const state: any = store.getState()
72+
connectType(state, 'STANDALONE')
73+
})
74+
4575
it('should render', () => {
4676
expect(render(<Header {...instance(mockedProps)} />)).toBeTruthy()
4777
})
@@ -101,3 +131,57 @@ describe('DatabaseAnalysisHeader', () => {
101131
expect(onChangeSelectedAnalysis).toBeCalled()
102132
})
103133
})
134+
135+
describe('CLUSTER db', () => {
136+
beforeEach(() => {
137+
const state: any = store.getState()
138+
connectType(state, 'CLUSTER')
139+
})
140+
141+
it('should render cluster tooltip message', async () => {
142+
render(<Header {...instance(mockedProps)} />)
143+
144+
await act(async () => {
145+
fireEvent.mouseOver(screen.getByTestId('db-new-reports-icon'))
146+
})
147+
await waitForEuiToolTipVisible()
148+
149+
expect(screen.getByTestId('db-new-reports-tooltip')).toHaveTextContent('Analyze up to 10 000 keys per shard to get an overview of your data.')
150+
})
151+
})
152+
153+
describe('STANDALONE db', () => {
154+
beforeEach(() => {
155+
const state: any = store.getState()
156+
connectType(state, 'STANDALONE')
157+
})
158+
159+
it('should render default tooltip message', async () => {
160+
render(<Header {...instance(mockedProps)} />)
161+
162+
await act(async () => {
163+
fireEvent.mouseOver(screen.getByTestId('db-new-reports-icon'))
164+
})
165+
await waitForEuiToolTipVisible()
166+
167+
expect(screen.getByTestId('db-new-reports-tooltip')).toHaveTextContent('Redis Database AnalysisAnalyze up to 10 000 keys per Redis database to get an overview of your data.')
168+
})
169+
})
170+
171+
describe('SENTINEL db', () => {
172+
beforeEach(() => {
173+
const state: any = store.getState()
174+
connectType(state, 'SENTINEL')
175+
})
176+
177+
it('should render default tooltip message', async () => {
178+
render(<Header {...instance(mockedProps)} />)
179+
180+
await act(async () => {
181+
fireEvent.mouseOver(screen.getByTestId('db-new-reports-icon'))
182+
})
183+
await waitForEuiToolTipVisible()
184+
185+
expect(screen.getByTestId('db-new-reports-tooltip')).toHaveTextContent('Redis Database AnalysisAnalyze up to 10 000 keys per Redis database to get an overview of your data.')
186+
})
187+
})

redisinsight/ui/src/pages/databaseAnalysis/components/header/Header.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { numberWithSpaces } from 'uiSrc/utils/numbers'
2020
import { getApproximatePercentage } from 'uiSrc/utils/validations'
2121
import { BrowserStorageItem, DEFAULT_DELIMITER } from 'uiSrc/constants'
2222
import { appContextBrowserTree } from 'uiSrc/slices/app/context'
23+
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
24+
import { ConnectionType } from 'uiSrc/slices/interfaces'
2325
import AnalyticsTabs from 'uiSrc/components/analytics-tabs'
2426
import { Nullable } from 'uiSrc/utils'
2527
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
@@ -30,6 +32,9 @@ import styles from './styles.module.scss'
3032

3133
const dateFormat = 'd MMM yyyy HH:mm'
3234

35+
const commonTooltipMessage = 'Analyze up to 10 000 keys per Redis database to get an overview of your data.'
36+
const clusterTooltipMessage = 'Analyze up to 10 000 keys per shard to get an overview of your data.'
37+
3338
export interface Props {
3439
items: ShortDatabaseAnalysis[]
3540
selectedValue: Nullable<string>
@@ -47,6 +52,7 @@ const Header = (props: Props) => {
4752
analysisLoading
4853
} = props
4954

55+
const { connectionType } = useSelector(connectedInstanceSelector)
5056
const { instanceId } = useParams<{ instanceId: string }>()
5157
const dispatch = useDispatch()
5258

@@ -149,8 +155,9 @@ const Header = (props: Props) => {
149155
position="bottom"
150156
anchorClassName={styles.tooltipAnchor}
151157
className={styles.tooltip}
152-
title="Memory Efficiency"
153-
content="Analyze up to 10K keys in your Redis database to get an overview of your data and memory efficiency recommendations."
158+
title="Redis Database Analysis"
159+
content={connectionType === ConnectionType.Cluster ? clusterTooltipMessage : commonTooltipMessage}
160+
data-testid="db-new-reports-tooltip"
154161
>
155162
<EuiIcon
156163
className={styles.infoIcon}

tests/e2e/pageObjects/add-redis-database-page.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ export class AddRedisDatabasePage {
8888
await t.typeText(this.passwordInput, parameters.databasePassword, { replace: true, paste: true });
8989
}
9090
// Enter logical index
91-
await t
92-
.click(this.databaseIndexCheckbox)
93-
.typeText(this.databaseIndexInput, index, { replace: true, paste: true})
91+
await t.click(this.databaseIndexCheckbox);
92+
await t.typeText(this.databaseIndexInput, index, { replace: true, paste: true});
9493
// Click for saving
95-
.click(this.addRedisDatabaseButton);
94+
await t.click(this.addRedisDatabaseButton);
9695
}
9796

9897
/**
@@ -117,7 +116,7 @@ export class AddRedisDatabasePage {
117116

118117
/**
119118
* Adding a new database from RE Cluster via auto-discover flow
120-
* @param prameters the parameters of the database
119+
* @param parameters the parameters of the database
121120
*/
122121
async addAutodiscoverREClucterDatabase(parameters: AddNewDatabaseParameters): Promise<void> {
123122
await t

0 commit comments

Comments
 (0)