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 @@ -157,12 +157,16 @@ export const BaseSearchIndexModal: React.FunctionComponent<
onSubmit,
onClose,
}) => {
const initialSearchIndexType: SearchIndexType =
initialIndexType === 'search' || initialIndexType === 'vectorSearch'
? initialIndexType
: 'search';
const editorRef = useRef<EditorRef>(null);
const connectionInfoRef = useConnectionInfoRef();

const [indexName, setIndexName] = useState(initialIndexName);
const [searchIndexType, setSearchIndexType] = useState<string>(
initialIndexType ?? searchIndexTypes[0].value
const [searchIndexType, setSearchIndexType] = useState<SearchIndexType>(
initialSearchIndexType
);
const [indexDefinition, setIndexDefinition] = useState(
initialIndexDefinition
Expand Down Expand Up @@ -211,7 +215,7 @@ export const BaseSearchIndexModal: React.FunctionComponent<

useEffect(() => {
if (isModalOpen) {
setSearchIndexType('search');
setSearchIndexType(initialSearchIndexType);
setIndexName(initialIndexName);
setIndexDefinition(initialIndexDefinition);
setParsingError(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,36 @@ describe('Base Search Index Modal', function () {
expect(screen.getByRole('option', { name: knnVectorText })).to.be.visible;
});
});

it('renders search index info by default', function () {
renderUpdateSearchIndexModal();
expect(
screen
.getByText('View Atlas Search tutorials')
.closest('a')
?.getAttribute('href')
).to.equal('https://www.mongodb.com/docs/atlas/atlas-search/tutorial/');
});

it('renders search index info for regular search indexes', function () {
renderUpdateSearchIndexModal({ indexType: 'search' });
expect(
screen
.getByText('View Atlas Search tutorials')
.closest('a')
?.getAttribute('href')
).to.equal('https://www.mongodb.com/docs/atlas/atlas-search/tutorial/');
});

it('renders vector search index info for vector search indexes', function () {
renderUpdateSearchIndexModal({ indexType: 'vectorSearch' });
expect(
screen
.getByText('View Atlas Vector Search tutorials')
.closest('a')
?.getAttribute('href')
).to.equal(
'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial/'
);
});
});
Loading