1
1
import React from 'react'
2
2
import * as reactRedux from 'react-redux'
3
- import { cleanup , render , screen } from 'uiSrc/utils/test-utils'
3
+ import {
4
+ cleanup ,
5
+ initialStateDefault ,
6
+ mockStore ,
7
+ render ,
8
+ screen ,
9
+ } from 'uiSrc/utils/test-utils'
4
10
import { TelemetryPageView } from 'uiSrc/telemetry/pageViews'
5
11
import { sendPageViewTelemetry } from 'uiSrc/telemetry'
6
12
import {
@@ -11,6 +17,7 @@ import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
11
17
import { redisearchListSelector } from 'uiSrc/slices/browser/redisearch'
12
18
import VectorSearchPage from './VectorSearchPage'
13
19
import useRedisInstanceCompatibility from '../create-index/hooks/useRedisInstanceCompatibility'
20
+ import { RootState } from 'uiSrc/slices/store'
14
21
15
22
// Mock the telemetry module, so we don't send actual telemetry data during tests
16
23
jest . mock ( 'uiSrc/telemetry' , ( ) => ( {
@@ -22,7 +29,24 @@ jest.mock('../create-index/hooks/useRedisInstanceCompatibility', () =>
22
29
jest . fn ( ) ,
23
30
)
24
31
25
- const renderVectorSearchPageComponent = ( ) => render ( < VectorSearchPage /> )
32
+ const renderVectorSearchPageComponent = ( ) => {
33
+ const testState : RootState = {
34
+ ...initialStateDefault ,
35
+ connections : {
36
+ ...initialStateDefault . connections ,
37
+ instances : {
38
+ ...initialStateDefault . connections . instances ,
39
+ connectedInstance : {
40
+ ...initialStateDefault . connections . instances . connectedInstance ,
41
+ ...INSTANCES_MOCK [ 0 ] ,
42
+ } ,
43
+ } ,
44
+ } ,
45
+ }
46
+ const store = mockStore ( testState )
47
+
48
+ return render ( < VectorSearchPage /> , { store } )
49
+ }
26
50
27
51
describe ( 'VectorSearchPage' , ( ) => {
28
52
const mockUseRedisInstanceCompatibility =
@@ -49,6 +73,11 @@ describe('VectorSearchPage', () => {
49
73
50
74
const vectorSearchQuery = screen . getByTestId ( 'vector-search-query' )
51
75
expect ( vectorSearchQuery ) . toBeInTheDocument ( )
76
+
77
+ // Verify the title of the page
78
+ expect ( document . title ) . toBe (
79
+ `${ INSTANCES_MOCK [ 0 ] . name } [db${ INSTANCES_MOCK [ 0 ] . db } ] - Vector Search` ,
80
+ )
52
81
} )
53
82
54
83
it ( 'should render loader while checking the database compatibility' , ( ) => {
0 commit comments