Skip to content

Commit 8d0c2a2

Browse files
authored
Merge pull request #2567 from RedisInsight/fe/bugfix/RI-4928_change_ms_to_msec
#RI-4928 - ms not changed to msec below slow-log-slower-than input in configurations
2 parents d8a2acb + bcb23da commit 8d0c2a2

File tree

8 files changed

+62
-36
lines changed

8 files changed

+62
-36
lines changed

redisinsight/ui/src/constants/durationUnits.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { EuiSuperSelectOption } from '@elastic/eui'
33
export enum DurationUnits {
44
microSeconds = 'µs',
55
milliSeconds = 'ms',
6+
mSeconds = 'msec',
67
}
78

89
export const DURATION_UNITS: EuiSuperSelectOption<DurationUnits>[] = [
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const OAUTH_CLOUD_CAPI_KEYS_DATA = [
2+
{
3+
id: '1',
4+
name: 'RedisInsight-f4868252-a128-4a02-af75-bd3c99898267-2020-11-01T-123',
5+
createdAt: '2023-08-02T09:07:41.680Z',
6+
lastUsed: '2023-08-02T09:07:41.680Z',
7+
valid: true,
8+
}
9+
]

redisinsight/ui/src/mocks/handlers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import analytics from './analytics'
66
import browser from './browser'
77
import recommendations from './recommendations'
88
import triggeredFunctions from './triggeredFunctions'
9+
import cloud from './oauth'
910

1011
// @ts-ignore
1112
export const handlers: RestHandler<MockedRequest>[] = [].concat(
@@ -16,4 +17,5 @@ export const handlers: RestHandler<MockedRequest>[] = [].concat(
1617
browser,
1718
recommendations,
1819
triggeredFunctions,
20+
cloud,
1921
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { rest, RestHandler } from 'msw'
2+
import { getMswURL } from 'uiSrc/utils/test-utils'
3+
import { ApiEndpoints } from 'uiSrc/constants'
4+
import { OAUTH_CLOUD_CAPI_KEYS_DATA } from 'uiSrc/mocks/data/oauth'
5+
6+
const handlers: RestHandler[] = [
7+
// fetch cloud capi keys
8+
rest.get(
9+
getMswURL(ApiEndpoints.CLOUD_CAPI_KEYS),
10+
async (_req, res, ctx) => res(
11+
ctx.status(200),
12+
ctx.json(OAUTH_CLOUD_CAPI_KEYS_DATA),
13+
)
14+
),
15+
]
16+
17+
export default handlers
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { DefaultBodyType, MockedRequest, RestHandler } from 'msw'
2+
3+
import cloud from './cloud'
4+
5+
const handlers: RestHandler<MockedRequest<DefaultBodyType>>[] = [].concat(cloud)
6+
export default handlers

redisinsight/ui/src/pages/settings/components/cloud-settings/CloudSettings.spec.tsx

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React from 'react'
22
import { cloneDeep } from 'lodash'
33
import { act, cleanup, fireEvent, mockedStore, render, screen, waitForEuiPopoverVisible } from 'uiSrc/utils/test-utils'
44

5-
import { getCapiKeys, oauthCapiKeysSelector, removeAllCapiKeys } from 'uiSrc/slices/oauth/cloud'
5+
import { getCapiKeys, getCapiKeysSuccess, oauthCapiKeysSelector, removeAllCapiKeys } from 'uiSrc/slices/oauth/cloud'
66
import { apiService } from 'uiSrc/services'
77
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
8+
import { OAUTH_CLOUD_CAPI_KEYS_DATA } from 'uiSrc/mocks/data/oauth'
89

910
import CloudSettings from './CloudSettings'
1011

@@ -29,6 +30,22 @@ jest.mock('uiSrc/telemetry', () => ({
2930
}))
3031

3132
describe('CloudSettings', () => {
33+
it('should show delete popover and call proper action on delete', async () => {
34+
(oauthCapiKeysSelector as jest.Mock).mockReturnValue({
35+
data: OAUTH_CLOUD_CAPI_KEYS_DATA,
36+
loading: false
37+
})
38+
render(<CloudSettings />)
39+
40+
fireEvent.click(screen.getByTestId('delete-key-btn'))
41+
await waitForEuiPopoverVisible()
42+
43+
fireEvent.click(screen.getByTestId('delete-key-confirm-btn'))
44+
45+
expect(store.getActions())
46+
.toEqual([getCapiKeys(), getCapiKeysSuccess(OAUTH_CLOUD_CAPI_KEYS_DATA), removeAllCapiKeys()])
47+
})
48+
3249
it('should render', () => {
3350
expect(render(<CloudSettings />)).toBeTruthy()
3451
})
@@ -40,32 +57,14 @@ describe('CloudSettings', () => {
4057
})
4158

4259
it('should be disabled delete all button', () => {
43-
render(<CloudSettings />)
44-
45-
expect(screen.getByTestId('delete-key-btn')).toBeDisabled()
46-
})
47-
48-
it('should show delete popover and call proper action on delete', async () => {
4960
(oauthCapiKeysSelector as jest.Mock).mockReturnValue({
50-
data: [
51-
{
52-
id: '1',
53-
name: 'RedisInsight-f4868252-a128-4a02-af75-bd3c99898267-2020-11-01T-123',
54-
createdAt: '2023-08-02T09:07:41.680Z',
55-
lastUsed: '2023-08-02T09:07:41.680Z',
56-
valid: true,
57-
}
58-
],
61+
data: [],
5962
loading: false
6063
})
61-
render(<CloudSettings />)
6264

63-
fireEvent.click(screen.getByTestId('delete-key-btn'))
64-
await waitForEuiPopoverVisible()
65-
66-
fireEvent.click(screen.getByTestId('delete-key-confirm-btn'))
65+
render(<CloudSettings />)
6766

68-
expect(store.getActions()).toEqual([getCapiKeys(), removeAllCapiKeys()])
67+
expect(screen.getByTestId('delete-key-btn')).toBeDisabled()
6968
})
7069

7170
it('should call proper telemetry events', async () => {
@@ -74,15 +73,7 @@ describe('CloudSettings', () => {
7473
sendEventTelemetry.mockImplementation(() => sendEventTelemetryMock);
7574

7675
(oauthCapiKeysSelector as jest.Mock).mockReturnValue({
77-
data: [
78-
{
79-
id: '1',
80-
name: 'RedisInsight-f4868252-a128-4a02-af75-bd3c99898267-2020-11-01T-123',
81-
createdAt: '2023-08-02T09:07:41.680Z',
82-
lastUsed: '2023-08-02T09:07:41.680Z',
83-
valid: true,
84-
}
85-
],
76+
data: OAUTH_CLOUD_CAPI_KEYS_DATA,
8677
loading: false
8778
})
8879
render(<CloudSettings />)

redisinsight/ui/src/pages/slowLog/SlowLogPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux'
1212
import { useParams } from 'react-router-dom'
1313
import { AutoSizer } from 'react-virtualized'
1414

15-
import { DEFAULT_SLOWLOG_MAX_LEN } from 'uiSrc/constants'
15+
import { DEFAULT_SLOWLOG_MAX_LEN, DurationUnits } from 'uiSrc/constants'
1616
import { DATE_FORMAT } from 'uiSrc/pages/slowLog/components/SlowLogTable/SlowLogTable'
1717
import { convertNumberByUnits } from 'uiSrc/pages/slowLog/utils'
1818
import { appContextDbConfig } from 'uiSrc/slices/app/context'
@@ -140,7 +140,7 @@ const SlowLogPage = () => {
140140
<EuiText size="xs" color="subdued" data-testid="config-info">
141141
Execution time: {numberWithSpaces(convertNumberByUnits(slowlogLogSlowerThan, durationUnit))}
142142
&nbsp;
143-
{durationUnit},
143+
{durationUnit === DurationUnits.milliSeconds ? DurationUnits.mSeconds : DurationUnits.microSeconds},
144144
Max length: {numberWithSpaces(slowlogMaxLen)}
145145
</EuiText>
146146
)}

redisinsight/ui/src/pages/slowLog/components/SlowLogConfig/SlowLogConfig.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ const SlowLogConfig = ({ closePopover, onRefresh }: Props) => {
129129

130130
const unitConverter = () => {
131131
if (Number.isNaN(toNumber(slowerThan))) {
132-
return `- ${DurationUnits.milliSeconds}`
132+
return `- ${DurationUnits.mSeconds}`
133133
}
134134

135135
if (slowerThan === `${MINUS_ONE}`) {
136-
return `-1 ${DurationUnits.milliSeconds}`
136+
return `-1 ${DurationUnits.mSeconds}`
137137
}
138138

139139
if (durationUnit === DurationUnits.microSeconds) {
140140
const value = numberWithSpaces(convertNumberByUnits(toNumber(slowerThan), DurationUnits.milliSeconds))
141-
return `${value} ${DurationUnits.milliSeconds}`
141+
return `${value} ${DurationUnits.mSeconds}`
142142
}
143143

144144
if (durationUnit === DurationUnits.milliSeconds) {

0 commit comments

Comments
 (0)