Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@types/detect-port": "^1.3.0",
"@types/electron-store": "^3.2.0",
"@types/express": "^4.17.3",
"@types/file-saver": "^2.0.5",
"@types/html-entities": "^1.3.4",
"@types/ioredis": "^4.26.0",
"@types/is-glob": "^4.0.2",
Expand Down Expand Up @@ -227,6 +228,7 @@
"electron-log": "^4.2.4",
"electron-store": "^8.0.0",
"electron-updater": "^5.0.5",
"file-saver": "^2.0.5",
"formik": "^2.2.9",
"html-entities": "^2.3.2",
"html-react-parser": "^1.2.4",
Expand Down
2 changes: 0 additions & 2 deletions redisinsight/ui/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import NavigationMenu from './navigation-menu/NavigationMenu'
import PageHeader from './page-header/PageHeader'
import GroupBadge from './group-badge/GroupBadge'
import ActionBar from './action-bar/ActionBar'
import Notifications from './notifications/Notifications'
import DatabaseListModules from './database-list-modules/DatabaseListModules'
import DatabaseListOptions from './database-list-options/DatabaseListOptions'
Expand All @@ -26,7 +25,6 @@ export {
NavigationMenu,
PageHeader,
GroupBadge,
ActionBar,
Notifications,
DatabaseListModules,
DatabaseListOptions,
Expand Down
2 changes: 1 addition & 1 deletion redisinsight/ui/src/components/scan-more/ScanMore.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ScanMore, { Props } from './ScanMore'

const mockedProps = mock<Props>()

describe('ActionBar', () => {
describe('ScanMore', () => {
it('should render', () => {
expect(render(<ScanMore {...instance(mockedProps)} />)).toBeTruthy()
})
Expand Down
1 change: 1 addition & 0 deletions redisinsight/ui/src/constants/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum ApiEndpoints {
DATABASES = 'databases',
DATABASES_IMPORT = 'databases/import',
DATABASES_EXPORT = 'databases/export',

CA_CERTIFICATES = 'certificates/ca',
CLIENT_CERTIFICATES = 'certificates/client',
Expand Down
120 changes: 63 additions & 57 deletions redisinsight/ui/src/mocks/handlers/instances/instancesHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,77 @@
import { rest, RestHandler } from 'msw'
import { ApiEndpoints } from 'uiSrc/constants'
import { ConnectionType } from 'uiSrc/slices/interfaces'
import { ConnectionType, Instance } from 'uiSrc/slices/interfaces'
import { getMswURL } from 'uiSrc/utils/test-utils'
import { Database as DatabaseInstanceResponse } from 'apiSrc/modules/database/models/database'
import { ExportDatabase } from 'apiSrc/modules/database/models/export-database'

export const INSTANCE_ID_MOCK = 'instanceId'

const handlers: RestHandler[] = [
// fetchInstancesAction
rest.get<DatabaseInstanceResponse[]>(getMswURL(ApiEndpoints.DATABASES), async (req, res, ctx) => res(
ctx.status(200),
ctx.json([
export const INSTANCES_MOCK: Instance[] = [
{
id: 'e37cc441-a4f2-402c-8bdb-fc2413cbbaff',
host: 'localhost',
port: 6379,
name: 'localhost',
username: null,
password: null,
connectionType: ConnectionType.Standalone,
nameFromProvider: null,
modules: [],
uoeu: 123,
lastConnection: new Date('2021-04-22T09:03:56.917Z'),
},
{
id: 'a0db1bc8-a353-4c43-a856-b72f4811d2d4',
host: 'localhost',
port: 12000,
name: 'oea123123',
username: null,
password: null,
connectionType: ConnectionType.Standalone,
nameFromProvider: null,
modules: [],
tls: {
verifyServerCert: true,
caCertId: '70b95d32-c19d-4311-bb24-e684af12cf15',
clientCertPairId: '70b95d32-c19d-4311-b23b24-e684af12cf15',
},
},
{
id: 'b83a3932-e95f-4f09-9d8a-55079f400186',
host: 'localhost',
port: 5005,
name: 'sentinel',
username: null,
password: null,
connectionType: ConnectionType.Sentinel,
nameFromProvider: null,
lastConnection: new Date('2021-04-22T18:40:44.031Z'),
modules: [],
endpoints: [
{
id: 'e37cc441-a4f2-402c-8bdb-fc2413cbbaff',
host: 'localhost',
port: 6379,
name: 'localhost',
username: null,
password: null,
connectionType: ConnectionType.Standalone,
nameFromProvider: null,
modules: [],
uoeu: 123,
lastConnection: new Date('2021-04-22T09:03:56.917Z'),
},
{
id: 'a0db1bc8-a353-4c43-a856-b72f4811d2d4',
host: 'localhost',
port: 12000,
name: 'oea123123',
username: null,
password: null,
connectionType: ConnectionType.Standalone,
nameFromProvider: null,
modules: [],
tls: {
verifyServerCert: true,
caCertId: '70b95d32-c19d-4311-bb24-e684af12cf15',
clientCertPairId: '70b95d32-c19d-4311-b23b24-e684af12cf15',
},
port: 5005,
},
{
id: 'b83a3932-e95f-4f09-9d8a-55079f400186',
host: 'localhost',
port: 5005,
name: 'sentinel',
username: null,
password: null,
connectionType: ConnectionType.Sentinel,
nameFromProvider: null,
lastConnection: new Date('2021-04-22T18:40:44.031Z'),
modules: [],
endpoints: [
{
host: 'localhost',
port: 5005,
},
{
host: '127.0.0.1',
port: 5006,
},
],
sentinelMaster: {
name: 'mymaster',
},
host: '127.0.0.1',
port: 5006,
},
]),
],
sentinelMaster: {
name: 'mymaster',
},
},
]

const handlers: RestHandler[] = [
// fetchInstancesAction
rest.get<DatabaseInstanceResponse[]>(getMswURL(ApiEndpoints.DATABASES), async (req, res, ctx) => res(
ctx.status(200),
ctx.json(INSTANCES_MOCK),
)),
rest.post<ExportDatabase>(getMswURL(ApiEndpoints.DATABASES_EXPORT), async (req, res, ctx) => res(
ctx.status(200),
ctx.json(INSTANCES_MOCK),
))
]

Expand Down
2 changes: 1 addition & 1 deletion redisinsight/ui/src/mocks/res/responseComposition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createResponseComposition, context, rest } from 'msw'
import { rest } from 'msw'
import { DEFAULT_ERROR_MESSAGE } from 'uiSrc/utils'

export const errorHandlers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@ import { EuiBasicTableColumn } from '@elastic/eui'
import React from 'react'
import { instance, mock } from 'ts-mockito'
import { Instance } from 'uiSrc/slices/interfaces'
import { render } from 'uiSrc/utils/test-utils'
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
import DatabasesList, { Props } from './DatabasesList'

const mockedProps = mock<Props>()

jest.mock('uiSrc/telemetry', () => ({
...jest.requireActual('uiSrc/telemetry'),
sendEventTelemetry: jest.fn(),
}))

jest.mock('uiSrc/slices/instances/instances', () => ({
...jest.requireActual('uiSrc/slices/instances/instances'),
instancesSelector: jest.fn().mockReturnValue({
loading: false,
error: '',
data: [
{
id: 'e37cc441-a4f2-402c-8bdb-fc2413cbbaff',
host: 'localhost',
port: 6379,
name: 'localhost',
username: null,
password: null,
connectionType: 'standalone',
nameFromProvider: null,
modules: [],
uoeu: 123,
lastConnection: new Date('2021-04-22T09:03:56.917Z'),
},
{
id: 'a0db1bc8-a353-4c43-a856-b72f4811d2d4',
host: 'localhost',
port: 12000,
name: 'oea123123',
username: null,
password: null,
connectionType: 'standalone',
nameFromProvider: null,
modules: [],
tls: {
verifyServerCert: true,
caCertId: '70b95d32-c19d-4311-bb24-e684af12cf15',
clientCertPairId: '70b95d32-c19d-4311-b23b24-e684af12cf15',
},
}
]
})
}))

const columnsMock = [
{
field: 'subscriptionId',
Expand Down Expand Up @@ -35,4 +80,31 @@ describe('DatabasesList', () => {
)
).toBeTruthy()
})

it('should call onExport and send telemetry on click export btn', () => {
const sendEventTelemetryMock = jest.fn()
const onExport = jest.fn()

sendEventTelemetry.mockImplementation(() => sendEventTelemetryMock)

const { container } = render(
<DatabasesList
{...instance(mockedProps)}
onExport={onExport}
columnVariations={columnVariationsMock}
/>
)

fireEvent.click(
container.querySelector('[data-test-subj="checkboxSelectAll"]') as Element
)

fireEvent.click(screen.getByTestId('export-btn'))
fireEvent.click(screen.getByTestId('export-selected-dbs'))

expect(onExport).toBeCalled()
expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.CONFIG_DATABASES_REDIS_EXPORT_CLICKED
})
})
})
Loading