Skip to content

Commit 51fa351

Browse files
committed
fix BulkDeleteSummaryButton.spec.tsx test, added test to spacer.spec.tsx, small changes to SentinelDatabases.tsx
1 parent 2fb76d1 commit 51fa351

File tree

5 files changed

+107
-39
lines changed

5 files changed

+107
-39
lines changed

redisinsight/ui/src/components/base/icons/Icon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { useTheme } from '@redis-ui/styles'
33
import cx from 'classnames'
44
import { IconSizeType } from '@redis-ui/icons'
55
import { MonochromeIconProps } from 'uiSrc/components/base/icons'
6+
import { Theme } from 'uiSrc/components/base/theme/types'
67

78
type BaseIconProps = Omit<MonochromeIconProps, 'color' | 'size'> & {
89
icon: React.ComponentType<any>
910
color?:
10-
| keyof ReturnType<typeof useTheme>['semantic']['color']['icon']
11+
| keyof Theme['semantic']['color']['icon']
1112
| 'currentColor'
1213
| (string & {})
1314
size?: IconSizeType | null
@@ -30,7 +31,7 @@ const sizesMap = {
3031
* @returns A boolean indicating if the color is valid and a type predicate
3132
*/
3233
function isValidIconColor(
33-
theme: ReturnType<typeof useTheme>,
34+
theme: Theme,
3435
color: string | number | symbol,
3536
): color is keyof typeof theme.semantic.color.icon {
3637
return color in theme.semantic.color.icon
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react'
2+
3+
import { render } from 'uiSrc/utils/test-utils'
4+
import { Spacer } from './Spacer'
5+
import { SpacerProps } from './spacer.styles'
6+
7+
const sizeToValue = {
8+
xs: '0.2rem',
9+
s: '0.4rem',
10+
m: '0.8rem',
11+
l: '1.6rem',
12+
xl: '2rem',
13+
xxl: '2.4rem',
14+
} as const
15+
describe('Spacer', () => {
16+
test('is rendered', () => {
17+
const { container } = render(<Spacer />)
18+
19+
expect(container.firstChild).toBeTruthy()
20+
})
21+
22+
describe('Size', () => {
23+
Object.entries(sizeToValue).forEach(([size, value]) => {
24+
it(`size '${size}' is rendered`, () => {
25+
const { container } = render(
26+
<Spacer size={size as SpacerProps['size']} />,
27+
)
28+
expect(container.firstChild).toHaveStyle(`height: ${value}`)
29+
})
30+
})
31+
})
32+
33+
describe('Direction', () => {
34+
it(`width is rendered for Horizontal direction`, () => {
35+
const { container } = render(<Spacer />)
36+
expect(container.firstChild).toHaveStyle(`height: 1.6rem`)
37+
expect(container.firstChild).not.toHaveStyle(`width: 1.6rem`)
38+
})
39+
it(`width is rendered for explicit Horizontal direction`, () => {
40+
const { container } = render(<Spacer direction="horizontal" />)
41+
expect(container.firstChild).toHaveStyle(`width: 1.6rem`)
42+
expect(container.firstChild).not.toHaveStyle(`height: 1.6rem`)
43+
})
44+
it(`height is rendered for Vertical direction`, () => {
45+
const { container } = render(<Spacer direction="vertical" />)
46+
expect(container.firstChild).toHaveStyle('height: 1.6rem')
47+
expect(container.firstChild).not.toHaveStyle(`width: 1.6rem`)
48+
})
49+
})
50+
})

redisinsight/ui/src/components/base/link/UserProfileLink.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import styled from "styled-components"
2-
import { useTheme } from "@redis-ui/styles"
3-
import { Link } from "./Link"
1+
import styled from 'styled-components'
2+
import { Link } from './Link'
3+
import { Theme } from 'uiSrc/components/base/theme/types'
44

55
export const UserProfileLink = styled(Link)`
66
padding: 8px 12px !important;
77
width: 100%;
8-
color: ${({ theme }: { theme: ReturnType<typeof useTheme> }) =>
8+
color: ${({ theme }: { theme: Theme }) =>
99
theme.semantic.color.text.informative400} !important;
1010
text-decoration: none !important;
1111

redisinsight/ui/src/pages/autodiscover-sentinel/sentinel-databases/components/SentinelDatabases/SentinelDatabases.tsx

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { AutodiscoveryPageTemplate } from 'uiSrc/templates'
99
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
1010
import {
1111
DestructiveButton,
12+
EmptyButton,
1213
PrimaryButton,
1314
SecondaryButton,
1415
} from 'uiSrc/components/base/forms/buttons'
15-
import { RiIcon } from 'uiSrc/components/base/icons'
16+
import { ArrowLeftIcon, RiIcon } from 'uiSrc/components/base/icons'
1617
import { SearchInput } from 'uiSrc/components/base/inputs'
1718
import { Text } from 'uiSrc/components/base/text'
1819
import { RiPopover, RiTooltip } from 'uiSrc/components/base'
@@ -66,6 +67,7 @@ const SentinelDatabases = ({
6667
const [rowSelection, setRowSelection] = useState<
6768
Record<NonNullable<ModifiedSentinelMaster['id']>, boolean>
6869
>({})
70+
6971
useEffect(() => {
7072
setRowSelection(
7173
selection.reduce(
@@ -203,30 +205,45 @@ const SentinelDatabases = ({
203205
return (
204206
<AutodiscoveryPageTemplate>
205207
<DatabaseContainer justify="start">
206-
<PageTitle data-testid="title">
207-
Auto-Discover Redis Sentinel Primary Groups
208-
</PageTitle>
209-
210-
<Row justify="between" align="center" grow={false}>
211-
<FlexItem grow>
212-
<PageSubTitle>
213-
Redis Sentinel instance found. <br />
214-
Here is a list of primary groups your Sentinel instance is
215-
managing. Select the primary group(s) you want to add:
216-
</PageSubTitle>
217-
</FlexItem>
218-
<SearchContainer>
219-
<SearchForm>
220-
<SearchInput
221-
placeholder="Search..."
222-
onChange={onQueryChange}
223-
aria-label="Search"
224-
data-testid="search"
225-
/>
226-
</SearchForm>
227-
</SearchContainer>
208+
<Row align="center" justify="between" grow={false}>
209+
<Col align="start" justify="start">
210+
<EmptyButton
211+
icon={ArrowLeftIcon}
212+
onClick={onBack}
213+
className="btn-cancel btn-back"
214+
data-testid="btn-back-adding"
215+
>
216+
Add databases
217+
</EmptyButton>
218+
<Spacer size="s" />
219+
<PageTitle data-testid="title">
220+
Auto-Discover Redis Sentinel Primary Groups
221+
</PageTitle>
222+
<Spacer size="m" />
223+
{items.length > 0 && (
224+
<FlexItem grow>
225+
<PageSubTitle>
226+
Redis Sentinel instance found. <br />
227+
Here is a list of primary groups your Sentinel instance is
228+
managing. Select the primary group(s) you want to add:
229+
</PageSubTitle>
230+
</FlexItem>
231+
)}
232+
</Col>
233+
<Row justify="end" gap="s" grow={false}>
234+
<SearchContainer>
235+
<SearchForm>
236+
<SearchInput
237+
placeholder="Search..."
238+
onChange={onQueryChange}
239+
aria-label="Search"
240+
data-testid="search"
241+
/>
242+
</SearchForm>
243+
</SearchContainer>
244+
</Row>
228245
</Row>
229-
<Spacer size="l" />
246+
<Spacer size="m" />
230247
<DatabaseWrapper>
231248
<Table
232249
rowSelectionMode="multiple"
@@ -243,6 +260,13 @@ const SentinelDatabases = ({
243260
},
244261
]}
245262
stripedRows
263+
emptyState={() => (
264+
<Col centered full>
265+
<FlexItem padding={13}>
266+
<Text size="L">{message}</Text>
267+
</FlexItem>
268+
</Col>
269+
)}
246270
/>
247271
{!items.length && message !== notMastersMsg && (
248272
<>
@@ -258,14 +282,7 @@ const SentinelDatabases = ({
258282
</DatabaseWrapper>
259283
</DatabaseContainer>
260284
<Footer>
261-
<Row justify="between">
262-
<SecondaryButton
263-
onClick={onBack}
264-
className="btn-cancel btn-back"
265-
data-testid="btn-back-to-adding"
266-
>
267-
Back to adding databases
268-
</SecondaryButton>
285+
<Row justify="end">
269286
<Row gap="m" grow={false}>
270287
<CancelButton isPopoverOpen={isPopoverOpen} />
271288
<SubmitButton onClick={handleSubmit} />

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkDelete/BulkDeleteSummaryButton/BulkDeleteSummaryButton.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
2-
import { render, screen } from '@testing-library/react'
32
import BulkDeleteSummaryButton from './BulkDeleteSummaryButton'
3+
import { render, screen } from 'uiSrc/utils/test-utils'
44

55
const readBlobContent = async (blob: Blob): Promise<string> => {
66
return blob.text()

0 commit comments

Comments
 (0)