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
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ describe('TestConnectionsLog', () => {
render(<TestConnectionsLog data={mockedData} />)
})

it('should be all collapsed nav groups', () => {
it('should be a collapsed nav group', () => {
const mockedData: ITestConnection = {
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
success: [{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }]
success: []
}
render(<TestConnectionsLog data={mockedData} />)

expect(screen.getByTestId('success-connections-closed')).toBeInTheDocument()
expect(screen.queryByTestId('success-connections-closed')).not.toBeInTheDocument()
expect(screen.getByTestId('failed-connections-closed')).toBeInTheDocument()
})

it('should open and collapse other groups', () => {
const mockedData: ITestConnection = {
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
fail: [],
success: [{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }]
}
render(<TestConnectionsLog data={mockedData} />)
Expand All @@ -32,19 +32,11 @@ describe('TestConnectionsLog', () => {
within(screen.getByTestId('success-connections-closed')).getByRole('button')
)
expect(screen.getByTestId('success-connections-open')).toBeInTheDocument()

expect(screen.getByTestId('failed-connections-closed')).toBeInTheDocument()

fireEvent.click(
within(screen.getByTestId('failed-connections-closed')).getByRole('button')
)
expect(screen.getByTestId('failed-connections-open')).toBeInTheDocument()
expect(screen.getByTestId('success-connections-closed')).toBeInTheDocument()
})

it('should show proper items length', () => {
const mockedData: ITestConnection = {
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
fail: [],
success: [
{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' },
{ index: 2, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }
Expand All @@ -55,8 +47,5 @@ describe('TestConnectionsLog', () => {
expect(
within(screen.getByTestId('success-connections-closed')).getByTestId('number-of-connections')
).toHaveTextContent('2')
expect(
within(screen.getByTestId('failed-connections-closed')).getByTestId('number-of-connections')
).toHaveTextContent('1')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export interface Props {

const TestConnectionsLog = (props: Props) => {
const { data } = props

const statusData = data?.fail?.length ? data.fail : data?.success
const status = data?.fail?.length ? ResultsStatus.Failed : ResultsStatus.Success
const [openedNav, setOpenedNav] = useState<string>('')

const onToggle = (length: number = 0, isOpen: boolean, name: string) => {
Expand All @@ -34,33 +35,22 @@ const TestConnectionsLog = (props: Props) => {
</div>
)

const navTitle = status === ResultsStatus.Success ? 'Connected successfully' : 'Failed to connect'

const getNavGroupState = (name: ResultsStatus) => (openedNav === name ? 'open' : 'closed')

return (
<>
<EuiCollapsibleNavGroup
title={<CollapsibleNavTitle title="Connected successfully" length={data?.success?.length ?? 0} />}
className={cx(styles.collapsibleNav, ResultsStatus.Success, { [styles.disabled]: !data?.success?.length })}
isCollapsible
initialIsOpen={false}
onToggle={(isOpen) => onToggle(data?.success?.length, isOpen, ResultsStatus.Success)}
forceState={getNavGroupState(ResultsStatus.Success)}
data-testid={`success-connections-${getNavGroupState(ResultsStatus.Success)}`}
>
<TestConnectionsTable data={data?.success ?? []} />
</EuiCollapsibleNavGroup>
<EuiCollapsibleNavGroup
title={<CollapsibleNavTitle title="Failed to connect" length={data?.fail?.length ?? 0} />}
className={cx(styles.collapsibleNav, ResultsStatus.Failed, { [styles.disabled]: !data?.fail?.length })}
isCollapsible
initialIsOpen={false}
onToggle={(isOpen) => onToggle(data?.fail?.length, isOpen, ResultsStatus.Failed)}
forceState={getNavGroupState(ResultsStatus.Failed)}
data-testid={`failed-connections-${getNavGroupState(ResultsStatus.Failed)}`}
>
<TestConnectionsTable data={data?.fail ?? []} />
</EuiCollapsibleNavGroup>
</>
<EuiCollapsibleNavGroup
title={<CollapsibleNavTitle title={navTitle} length={statusData?.length ?? 0} />}
className={cx(styles.collapsibleNav, status, { [styles.disabled]: !statusData?.length })}
isCollapsible
initialIsOpen={false}
onToggle={(isOpen) => onToggle(statusData?.length, isOpen, status)}
forceState={getNavGroupState(status)}
data-testid={`${status}-connections-${getNavGroupState(status)}`}
>
<TestConnectionsTable data={statusData ?? []} />
</EuiCollapsibleNavGroup>
)
}

Expand Down
16 changes: 13 additions & 3 deletions redisinsight/ui/src/pages/rdi/statistics/StatisticsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { get } from 'lodash'
import React, { useEffect } from 'react'
import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useParams } from 'react-router-dom'
import { EuiText } from '@elastic/eui'
import { EuiLoadingSpinner, EuiText } from '@elastic/eui'

import { connectedInstanceSelector } from 'uiSrc/slices/rdi/instances'
import { getPipelineStatusAction, rdiPipelineStatusSelector } from 'uiSrc/slices/rdi/pipeline'
Expand All @@ -27,6 +27,7 @@ const isPipelineDeployed = (
) => get(data, ['pipelines', 'default', 'status']) === PipelineStatus.Ready

const StatisticsPage = () => {
const [pageLoading, setPageLoading] = useState(true)
const { rdiInstanceId } = useParams<{ rdiInstanceId: string }>()

const dispatch = useDispatch()
Expand Down Expand Up @@ -65,9 +66,13 @@ const StatisticsPage = () => {
})
}

const hideSpinner = () => {
setPageLoading(false)
}

useEffect(() => {
dispatch(getPipelineStatusAction(rdiInstanceId))
dispatch(fetchRdiStatistics(rdiInstanceId))
dispatch(fetchRdiStatistics(rdiInstanceId, undefined, hideSpinner, hideSpinner))

sendPageViewTelemetry({
name: TelemetryPageView.RDI_STATUS,
Expand Down Expand Up @@ -97,6 +102,11 @@ const StatisticsPage = () => {
<RdiInstancePageTemplate>
<div className={styles.pageContainer}>
<div className={styles.bodyContainer}>
{pageLoading && (
<div className={styles.cover}>
<EuiLoadingSpinner size="xl" />
</div>
)}
{!isPipelineDeployed(statusData) ? (
// TODO add loader
<Empty rdiInstanceId={rdiInstanceId} />
Expand Down
14 changes: 14 additions & 0 deletions redisinsight/ui/src/pages/rdi/statistics/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
position: relative;
}

.cover {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 2;
opacity: 0.8;
background-color: var(--euiColorLightestShade);
}

.bodyContainer {
:global {
.euiPanel:first-child {
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/tests/web/critical-path/rdi/configuration.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ test.after(async() => {
},
targets: {
target: {
type: 'redis',
host,
port,
password: password
connection: {
type: 'redis',
host,
port,
password: password
}
}
}
};
const config = yaml.dump(configData, { indent: 2 });
console.log(JSON.stringify(config));

await myRedisDatabasePage.setActivePage(RedisOverviewPage.Rdi);
await rdiInstancesListPage.clickRdiByName(rdiInstance.name);
Expand All @@ -97,8 +98,8 @@ test.after(async() => {

await t.click(rdiInstancePage.configurationInput);
const lines = config.split('\n');
// the verable shows the level of object depth for input by line in monaco
const maxLevelDepth = 3;
// the variable shows the level of object depth for input by line in monaco
const maxLevelDepth = 4;
const targetName = 'target';

await rdiInstancePage.MonacoEditor.insertTextByLines(rdiInstancePage.configurationInput, lines, maxLevelDepth);
Expand Down