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 @@ -316,6 +316,7 @@

export const StyledFlexItem = styled.div<FlexItemProps>`
display: flex;
gap: ${({ $gap = 'none' }) => ($gap ? flexGroupStyles.gapSizes[$gap] : '')};

Check warning on line 319 in redisinsight/ui/src/components/base/layout/flex/flex.styles.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
flex-direction: ${({ $direction = 'column' }) =>
flexGroupStyles.direction[$direction] ?? 'column'};
${({ grow }) => {
Expand Down
22 changes: 17 additions & 5 deletions redisinsight/ui/src/pages/vector-search/VectorSearchPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
INSTANCE_ID_MOCK,
INSTANCES_MOCK,
} from 'uiSrc/mocks/handlers/instances/instancesHandlers'
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
import { redisearchListSelector } from 'uiSrc/slices/browser/redisearch'
import { VectorSearchPage } from './VectorSearchPage'

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

mockUseSelector = jest.spyOn(reactRedux, 'useSelector')
mockUseSelector
.mockImplementationOnce(() => INSTANCES_MOCK[0]) // connectedInstanceSelector
.mockImplementation(() => ({
mockUseSelector.mockImplementation((selector) => {
if (selector === connectedInstanceSelector) {
return INSTANCES_MOCK[0]
}
if (selector === redisearchListSelector) {
return {
loading: false,
data: [],
}
}
// Default fallback for other selectors
return {
loading: false,
spec: {}, // Provide at least an empty object for COMMANDS_SPEC
spec: {},
commandsArray: [],
commandGroups: [],
})) // appRedisCommandsSelector
}
})
})

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('CreateIndexStep', () => {
it('should render the command preview button', () => {
render(<CreateIndexStep {...defaultProps} />)

expect(screen.getByText('Command preview')).toBeInTheDocument()
expect(screen.getByText('Command preview')).toBeInTheDocument()
})

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

// Verify all 8 field boxes are rendered (from bikesIndexFieldsBoxes config)
const fieldLabels = ['id', 'description', 'price', 'price_1', 'name', 'category', 'embedding', 'embedding_1']

fieldLabels.forEach(label => {
expect(screen.getByText(label)).toBeInTheDocument()
})
Expand All @@ -161,7 +161,7 @@ describe('CreateIndexStep', () => {
it('should have proper button text', () => {
render(<CreateIndexStep {...defaultProps} />)

const commandPreviewButton = screen.getByText('Command preview')
const commandPreviewButton = screen.getByText('Command preview')
expect(commandPreviewButton).toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { BuildNewIndexTabTrigger } from 'uiSrc/components/new-index/create-index-step/build-new-index-tab/BuildNewIndexTabTrigger'
import { TextInput } from 'uiSrc/components/base/inputs'

import { PlayFilledIcon } from 'uiSrc/components/base/icons'
import { bikesIndexFieldsBoxes } from './config'
import { CreateIndexStepScreenWrapper, SearchInputWrapper } from './styles'
import { PreviewCommandDrawer } from './PreviewCommandDrawer'
Expand Down Expand Up @@ -80,8 +81,11 @@
tabs={indexFieldsTabs}
/>
<FlexGroup justify="end">
<EmptyButton onClick={() => setIsDrawerOpen(true)}>
► Command preview
<EmptyButton
icon={PlayFilledIcon}
onClick={() => setIsDrawerOpen(true)}

Check warning on line 86 in redisinsight/ui/src/pages/vector-search/create-index/steps/CreateIndexStep.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 86 in redisinsight/ui/src/pages/vector-search/create-index/steps/CreateIndexStep.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
>
Command preview
</EmptyButton>
</FlexGroup>
</FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ describe('SavedQueriesScreen', () => {
it('should render insert buttons for each query', () => {
render(<SavedQueriesScreen {...defaultProps} />)

const insertButtons = screen.getAllByText('Insert')
const insertButtons = screen.getAllByText('Insert')
expect(insertButtons).toHaveLength(2) // 2 queries in the selected index
})

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

const firstInsertButton = screen.getAllByText('Insert')[0]
const firstInsertButton = screen.getAllByText('Insert')[0]
fireEvent.click(firstInsertButton)

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

const insertButtons = screen.getAllByText('Insert')
const insertButtons = screen.getAllByText('Insert')

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

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

const insertButtons = screen.getAllByText('Insert')
const insertButtons = screen.getAllByText('Insert')
expect(insertButtons).toHaveLength(1) // 1 query in restaurant index
})

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

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

const insertButtons = screen.getAllByText('Insert')
const insertButtons = screen.getAllByText('Insert')

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

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

expect(screen.queryByText('Insert')).not.toBeInTheDocument()
expect(screen.queryByText('Insert')).not.toBeInTheDocument()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RiSelect } from 'uiSrc/components/base/forms/select/RiSelect'
import { Button } from 'uiSrc/components/base/forms/buttons'
import { FieldTag } from 'uiSrc/components/new-index/create-index-step/field-box/FieldTag'

import { PlayFilledIcon } from 'uiSrc/components/base/icons'
import {
RightAlignedWrapper,
TagsWrapper,
Expand Down Expand Up @@ -70,9 +71,11 @@ export const SavedQueriesScreen = ({
<RightAlignedWrapper>
<Button
variant="secondary-invert"
icon={PlayFilledIcon}
size="s"
onClick={() => onQueryInsert(query.value)}
>
Insert
Insert
</Button>
</RightAlignedWrapper>
</VectorSearchScreenBlockWrapper>
Expand Down
Loading