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 @@ -56,17 +56,29 @@ describe('SavedQueriesScreen', () => {

// Check that preset queries are rendered for bikes index
expect(
screen.getByText('Search for "Nord" bikes ordered by price'),
screen.getByText("Run a vector search for 'Comfortable commuter bike'"),
).toBeInTheDocument()
expect(
screen.getByText('Find road alloy bikes under 20kg'),
screen.getByText(
"Run a vector search for 'Commuter bike for people over 60'",
),
).toBeInTheDocument()
expect(
screen.getByText(
"Run a vector search for 'Female specific mountain bike'",
),
).toBeInTheDocument()
expect(
screen.getByText(
"Run a vector search for 'Female specific mountain bike' for bikes type 'Mountain bikes' and with price between $3500 and $3500",
),
).toBeInTheDocument()
})

it('should render insert buttons for each query', () => {
renderComponent()
const insertButtons = screen.getAllByText('Insert')
expect(insertButtons).toHaveLength(2)
expect(insertButtons).toHaveLength(4)
})

it('should select the first index by default', () => {
Expand All @@ -93,7 +105,9 @@ describe('SavedQueriesScreen', () => {
const firstInsertButton = screen.getAllByText('Insert')[0]
fireEvent.click(firstInsertButton)
expect(mockOnQueryInsert).toHaveBeenCalledWith(
'FT.SEARCH idx:bikes_vss "@brand:Nord" SORTBY price ASC',
expect.stringContaining(
'FT.SEARCH idx:bikes_vss \"*=>[KNN 3 @description_embeddings $my_blob AS score ]\" RETURN 4 score brand type description PARAMS 2 my_blob \"\\xecNN<\\xec\\xc78=\\`',
),
)
})

Expand All @@ -102,7 +116,9 @@ describe('SavedQueriesScreen', () => {
const secondInsertButton = screen.getAllByText('Insert')[1]
fireEvent.click(secondInsertButton)
expect(mockOnQueryInsert).toHaveBeenCalledWith(
'FT.SEARCH idx:bikes_vss "@material:{alloy} @weight:[0 20]"',
expect.stringContaining(
'FT.SEARCH idx:bikes_vss \"*=>[KNN 3 @description_embeddings $my_blob AS score ]\" PARAMS 2 my_blob \"A=\\xe1\\xbb\\x8a\\xad\\x9b<&7R',
),
)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// This is because of the long vec value in the data
/* eslint-disable max-len */
import React, { useState, useMemo, useEffect } from 'react'

import { Title } from 'uiSrc/components/base/text'
Expand All @@ -25,64 +23,18 @@ import NoDataMessage from '../components/no-data-message/NoDataMessage'
import { QueryCard } from './QueryCard'
import { IndexSelect } from './IndexSelect'
import { NoDataMessageKeys } from '../components/no-data-message/data'
import { savedQueries } from './saved-queries'

const mockSavedIndexes: SavedIndex[] = [
{
value: PresetDataType.BIKES,
tags: [FieldTypes.TAG, FieldTypes.TEXT, FieldTypes.VECTOR],
queries: [
{
label: 'Search for "Nord" bikes ordered by price',
value: 'FT.SEARCH idx:bikes_vss "@brand:Nord" SORTBY price ASC',
},
{
label: 'Find road alloy bikes under 20kg',
value: 'FT.SEARCH idx:bikes_vss "@material:{alloy} @weight:[0 20]"',
},
],
queries: savedQueries[PresetDataType.BIKES],
},
{
value: PresetDataType.MOVIES,
tags: [FieldTypes.TAG, FieldTypes.TEXT, FieldTypes.VECTOR],
queries: [
{
label: 'I want a fun animated movie about toys and friendship',
value:
'FT.SEARCH idx:movies_vss "*=>[KNN 3 @embedding $vec AS score]" ' +
`PARAMS 2 vec ${String.raw`"\x9a\x99\x19\x3f\xcd\xcc\xcc\x3d\x9a\x99\x4c\x3f\x9a\x99\x33\x3e\x9a\x99\x33\x3f\xcd\xcc\x66\x3e\xcd\xcc\xcc\x3d\xcd\xcc\x4c\x3e"`} ` +
'SORTBY score ' +
'RETURN 3 title plot score ' +
'DIALECT 2',
},
{
label: 'A feel-good film about music and students',
value:
'FT.SEARCH idx:movies_vss "@genres:{Music} =>[KNN 5 @embedding $vec AS score]" ' +
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
'SORTBY score ' +
'RETURN 3 title genres score ' +
'DIALECT 2',
},
{
label: 'Find classic musical rebellion films from the 90s',
value:
'FT.SEARCH idx:movies_vss "(@genres:{Music} @year:[1970 1979]) =>[KNN 5 @embedding $vec AS score]" ' +
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
'SORTBY score ' +
'RETURN 4 title year genres score ' +
'DIALECT 2',
},
{
label:
'You like Animated and Sci-Fi movies. Personalize results by filtering the vector search',
value:
`FT.SEARCH idx:movies_vss '@genres:{"Animated"|"Sci-Fi"} =>[KNN 5 @embedding $vec AS score]' ` +
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
'SORTBY score ' +
'RETURN 3 title genres score ' +
'DIALECT 2',
},
],
queries: savedQueries[PresetDataType.MOVIES],
},
]

Expand Down
Loading
Loading