diff --git a/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/constants.ts b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/constants.ts index 3e60bc33b049c..37c65ebb9a314 100644 --- a/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/constants.ts +++ b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/constants.ts @@ -32,3 +32,10 @@ export const DEFAULT_INFERENCE_ENDPOINTS_TABLE_STATE: AllInferenceEndpointsTable filterOptions: DEFAULT_FILTER_OPTIONS, queryParams: DEFAULT_QUERY_PARAMS, }; + +export const PIPELINE_URL = 'ingest/ingest_pipelines'; + +export const PRECONFIGURED_ENDPOINTS = { + ELSER: '.elser-2-elasticsearch', + E5: '.multilingual-e5-small-elasticsearch', +}; diff --git a/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_actions/actions/delete/delete_action.test.tsx b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_actions/actions/delete/delete_action.test.tsx new file mode 100644 index 0000000000000..f5f4a0b7e8bdc --- /dev/null +++ b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_actions/actions/delete/delete_action.test.tsx @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { render, screen, fireEvent } from '@testing-library/react'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import React from 'react'; + +import { DeleteAction } from './delete_action'; +import { InferenceEndpointUI } from '../../../../types'; + +describe('Delete Action', () => { + const mockProvider = { + inference_id: 'my-hugging-face', + service: 'hugging_face', + service_settings: { + api_key: 'aaaa', + url: 'https://dummy.huggingface.com', + }, + task_settings: {}, + } as any; + + const mockItem: InferenceEndpointUI = { + endpoint: 'my-hugging-face', + provider: mockProvider, + type: 'text_embedding', + }; + + const Wrapper = ({ item }: { item: InferenceEndpointUI }) => { + const queryClient = new QueryClient(); + return ( + + + + ); + }; + it('renders', () => { + render(); + + expect(screen.getByTestId('inferenceUIDeleteAction')).toBeEnabled(); + }); + + it('disable the delete action for preconfigured endpoint', () => { + const preconfiguredMockItem = { ...mockItem, endpoint: '.multilingual-e5-small-elasticsearch' }; + render(); + + expect(screen.getByTestId('inferenceUIDeleteAction')).toBeDisabled(); + }); + + it('loads confirm delete modal', () => { + render(); + + fireEvent.click(screen.getByTestId('inferenceUIDeleteAction')); + expect(screen.getByTestId('deleteModalForInferenceUI')).toBeInTheDocument(); + }); +}); diff --git a/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx index cb23ba650e5fa..e625e56d96f20 100644 --- a/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx +++ b/x-pack/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx @@ -45,6 +45,28 @@ const inferenceEndpoints = [ }, task_settings: {}, }, + { + inference_id: '.elser-2-elasticsearch', + task_type: 'sparse_embedding', + service: 'elasticsearch', + service_settings: { + num_allocations: 1, + num_threads: 1, + model_id: '.elser_model_2', + }, + task_settings: {}, + }, + { + inference_id: '.multilingual-e5-small-elasticsearch', + task_type: 'text_embedding', + service: 'elasticsearch', + service_settings: { + num_allocations: 1, + num_threads: 1, + model_id: '.multilingual-e5-small', + }, + task_settings: {}, + }, ] as InferenceAPIConfigResponse[]; jest.mock('../../hooks/use_delete_endpoint', () => ({ @@ -58,9 +80,11 @@ describe('When the tabular page is loaded', () => { render(); const rows = screen.getAllByRole('row'); - expect(rows[1]).toHaveTextContent('local-model'); - expect(rows[2]).toHaveTextContent('my-elser-model-05'); - expect(rows[3]).toHaveTextContent('third-party-model'); + expect(rows[1]).toHaveTextContent('.elser-2-elasticsearch'); + expect(rows[2]).toHaveTextContent('.multilingual-e5-small-elasticsearch'); + expect(rows[3]).toHaveTextContent('local-model'); + expect(rows[4]).toHaveTextContent('my-elser-model-05'); + expect(rows[5]).toHaveTextContent('third-party-model'); }); it('should display all service and model ids in the table', () => {