Skip to content

Commit 8ff116a

Browse files
authored
[RI-7194] fix Create Index style issues (#4813)
* RI-7194: use proper button play icon * fix flex gap * update VectorSearchPage telemetry test mock
1 parent c61328c commit 8ff116a

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

redisinsight/ui/src/components/base/layout/flex/flex.styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export type FlexItemProps = React.HTMLAttributes<HTMLDivElement> &
316316

317317
export const StyledFlexItem = styled.div<FlexItemProps>`
318318
display: flex;
319+
gap: ${({ $gap = 'none' }) => ($gap ? flexGroupStyles.gapSizes[$gap] : '')};
319320
flex-direction: ${({ $direction = 'column' }) =>
320321
flexGroupStyles.direction[$direction] ?? 'column'};
321322
${({ grow }) => {

redisinsight/ui/src/pages/vector-search/VectorSearchPage.spec.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
INSTANCE_ID_MOCK,
88
INSTANCES_MOCK,
99
} from 'uiSrc/mocks/handlers/instances/instancesHandlers'
10+
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
11+
import { redisearchListSelector } from 'uiSrc/slices/browser/redisearch'
1012
import { VectorSearchPage } from './VectorSearchPage'
1113

1214
// Mock the telemetry module, so we don't send actual telemetry data during tests
@@ -35,14 +37,24 @@ describe('VectorSearchPage', () => {
3537
jest.clearAllMocks()
3638

3739
mockUseSelector = jest.spyOn(reactRedux, 'useSelector')
38-
mockUseSelector
39-
.mockImplementationOnce(() => INSTANCES_MOCK[0]) // connectedInstanceSelector
40-
.mockImplementation(() => ({
40+
mockUseSelector.mockImplementation((selector) => {
41+
if (selector === connectedInstanceSelector) {
42+
return INSTANCES_MOCK[0]
43+
}
44+
if (selector === redisearchListSelector) {
45+
return {
46+
loading: false,
47+
data: [],
48+
}
49+
}
50+
// Default fallback for other selectors
51+
return {
4152
loading: false,
42-
spec: {}, // Provide at least an empty object for COMMANDS_SPEC
53+
spec: {},
4354
commandsArray: [],
4455
commandGroups: [],
45-
})) // appRedisCommandsSelector
56+
}
57+
})
4658
})
4759

4860
afterEach(() => {

redisinsight/ui/src/pages/vector-search/create-index/steps/CreateIndexStep.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('CreateIndexStep', () => {
6464
it('should render the command preview button', () => {
6565
render(<CreateIndexStep {...defaultProps} />)
6666

67-
expect(screen.getByText('Command preview')).toBeInTheDocument()
67+
expect(screen.getByText('Command preview')).toBeInTheDocument()
6868
})
6969

7070
it('should render the tab labels', () => {
@@ -143,7 +143,7 @@ describe('CreateIndexStep', () => {
143143

144144
// Verify all 8 field boxes are rendered (from bikesIndexFieldsBoxes config)
145145
const fieldLabels = ['id', 'description', 'price', 'price_1', 'name', 'category', 'embedding', 'embedding_1']
146-
146+
147147
fieldLabels.forEach(label => {
148148
expect(screen.getByText(label)).toBeInTheDocument()
149149
})
@@ -161,7 +161,7 @@ describe('CreateIndexStep', () => {
161161
it('should have proper button text', () => {
162162
render(<CreateIndexStep {...defaultProps} />)
163163

164-
const commandPreviewButton = screen.getByText('Command preview')
164+
const commandPreviewButton = screen.getByText('Command preview')
165165
expect(commandPreviewButton).toBeInTheDocument()
166166
})
167167
})

redisinsight/ui/src/pages/vector-search/create-index/steps/CreateIndexStep.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { VectorIndexTab } from 'uiSrc/components/new-index/create-index-step/Cre
1313
import { BuildNewIndexTabTrigger } from 'uiSrc/components/new-index/create-index-step/build-new-index-tab/BuildNewIndexTabTrigger'
1414
import { TextInput } from 'uiSrc/components/base/inputs'
1515

16+
import { PlayFilledIcon } from 'uiSrc/components/base/icons'
1617
import { bikesIndexFieldsBoxes } from './config'
1718
import { CreateIndexStepScreenWrapper, SearchInputWrapper } from './styles'
1819
import { PreviewCommandDrawer } from './PreviewCommandDrawer'
@@ -80,8 +81,11 @@ export const CreateIndexStep: IStepComponent = ({
8081
tabs={indexFieldsTabs}
8182
/>
8283
<FlexGroup justify="end">
83-
<EmptyButton onClick={() => setIsDrawerOpen(true)}>
84-
► Command preview
84+
<EmptyButton
85+
icon={PlayFilledIcon}
86+
onClick={() => setIsDrawerOpen(true)}
87+
>
88+
Command preview
8589
</EmptyButton>
8690
</FlexGroup>
8791
</FlexItem>

redisinsight/ui/src/pages/vector-search/saved-queries/SavedQueriesScreen.spec.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ describe('SavedQueriesScreen', () => {
6767
it('should render insert buttons for each query', () => {
6868
render(<SavedQueriesScreen {...defaultProps} />)
6969

70-
const insertButtons = screen.getAllByText('Insert')
70+
const insertButtons = screen.getAllByText('Insert')
7171
expect(insertButtons).toHaveLength(2) // 2 queries in the selected index
7272
})
7373

7474
it('should call onQueryInsert when insert button is clicked', () => {
7575
render(<SavedQueriesScreen {...defaultProps} />)
7676

77-
const firstInsertButton = screen.getAllByText('Insert')[0]
77+
const firstInsertButton = screen.getAllByText('Insert')[0]
7878
fireEvent.click(firstInsertButton)
7979

8080
expect(mockOnQueryInsert).toHaveBeenCalledTimes(1)
@@ -86,7 +86,7 @@ describe('SavedQueriesScreen', () => {
8686
it('should call onQueryInsert with correct query value for second button', () => {
8787
render(<SavedQueriesScreen {...defaultProps} />)
8888

89-
const insertButtons = screen.getAllByText('Insert')
89+
const insertButtons = screen.getAllByText('Insert')
9090

9191
// Click second insert button
9292
fireEvent.click(insertButtons[1])
@@ -117,7 +117,7 @@ describe('SavedQueriesScreen', () => {
117117

118118
expect(screen.getByText('Search for restaurants')).toBeInTheDocument()
119119

120-
const insertButtons = screen.getAllByText('Insert')
120+
const insertButtons = screen.getAllByText('Insert')
121121
expect(insertButtons).toHaveLength(1) // 1 query in restaurant index
122122
})
123123

@@ -129,7 +129,7 @@ describe('SavedQueriesScreen', () => {
129129

130130
render(<SavedQueriesScreen {...propsWithRestaurantIndex} />)
131131

132-
const insertButtons = screen.getAllByText('Insert')
132+
const insertButtons = screen.getAllByText('Insert')
133133

134134
fireEvent.click(insertButtons[0])
135135
expect(mockOnQueryInsert).toHaveBeenCalledWith(
@@ -154,7 +154,7 @@ describe('SavedQueriesScreen', () => {
154154

155155
render(<SavedQueriesScreen {...propsWithEmptyQueries} />)
156156

157-
expect(screen.queryByText('Insert')).not.toBeInTheDocument()
157+
expect(screen.queryByText('Insert')).not.toBeInTheDocument()
158158
})
159159
})
160160
})

redisinsight/ui/src/pages/vector-search/saved-queries/SavedQueriesScreen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { RiSelect } from 'uiSrc/components/base/forms/select/RiSelect'
66
import { Button } from 'uiSrc/components/base/forms/buttons'
77
import { FieldTag } from 'uiSrc/components/new-index/create-index-step/field-box/FieldTag'
88

9+
import { PlayFilledIcon } from 'uiSrc/components/base/icons'
910
import {
1011
RightAlignedWrapper,
1112
TagsWrapper,
@@ -70,9 +71,11 @@ export const SavedQueriesScreen = ({
7071
<RightAlignedWrapper>
7172
<Button
7273
variant="secondary-invert"
74+
icon={PlayFilledIcon}
75+
size="s"
7376
onClick={() => onQueryInsert(query.value)}
7477
>
75-
Insert
78+
Insert
7679
</Button>
7780
</RightAlignedWrapper>
7881
</VectorSearchScreenBlockWrapper>

0 commit comments

Comments
 (0)