-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(indexes): check for vector search support when showing edit templ…
…ates COMPASS-8235 (#6196)
- Loading branch information
Showing
5 changed files
with
120 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...s/compass-indexes/src/components/search-indexes-modals/update-search-index-modal.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { render, screen, cleanup } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { UpdateSearchIndexModal } from './update-search-index-modal'; | ||
|
||
const knnVectorText = 'KNN Vector field mapping'; | ||
|
||
function renderUpdateSearchIndexModal( | ||
props?: Partial<React.ComponentProps<typeof UpdateSearchIndexModal>> | ||
) { | ||
return render( | ||
<UpdateSearchIndexModal | ||
namespace="test.test" | ||
indexName="testIndex" | ||
isVectorSearchSupported | ||
indexDefinition="testDefinition" | ||
isModalOpen={true} | ||
isBusy={false} | ||
onUpdateIndex={() => {}} | ||
onCloseModal={() => {}} | ||
error={'Invalid index definition.'} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
describe('Base Search Index Modal', function () { | ||
afterEach(cleanup); | ||
|
||
describe('when rendered', function () { | ||
beforeEach(function () { | ||
renderUpdateSearchIndexModal(); | ||
}); | ||
|
||
it('does not show the KNN vector field mapping template', function () { | ||
userEvent.click(screen.getByRole('button', { name: 'Template' })); | ||
expect(screen.queryByRole('option', { name: knnVectorText })).to.not | ||
.exist; | ||
}); | ||
}); | ||
|
||
describe('when rendered and isVectorSearchSupported is false', function () { | ||
beforeEach(function () { | ||
renderUpdateSearchIndexModal({ | ||
isVectorSearchSupported: false, | ||
}); | ||
}); | ||
|
||
it('shows the KNN vector field mapping template', function () { | ||
userEvent.click(screen.getByRole('button', { name: 'Template' })); | ||
expect(screen.getByRole('option', { name: knnVectorText })).to.be.visible; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters