From 4b757e19a7aa6cfc049603ca31d1518777fc15d4 Mon Sep 17 00:00:00 2001
From: Samiul Monir <samiul.monir@elastic.co>
Date: Thu, 21 Nov 2024 12:35:03 -0500
Subject: [PATCH] Fixing semantic_text field tests

---
 .../index_details_page.test.tsx               | 23 ++++++++++++++++++-
 .../select_inference_id.test.tsx              | 23 +++++++++++++++++--
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/index_details_page.test.tsx b/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/index_details_page.test.tsx
index 5a97dadc870cb..4badcc04540b1 100644
--- a/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/index_details_page.test.tsx
+++ b/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/index_details_page.test.tsx
@@ -727,6 +727,11 @@ describe('<IndexDetailsPage />', () => {
           isActive: true,
           hasAtLeast: jest.fn((type) => true),
         };
+        const INFERENCE_LOCATOR = 'SEARCH_INFERENCE_ENDPOINTS';
+        const createMockLocator = (id: string) => ({
+          useUrl: jest.fn().mockReturnValue('https://redirect.me/to/inference_endpoints'),
+        });
+        const mockInferenceManagementLocator = createMockLocator(INFERENCE_LOCATOR);
         beforeEach(async () => {
           httpRequestsMockHelpers.setInferenceModels({
             data: [
@@ -750,7 +755,9 @@ describe('<IndexDetailsPage />', () => {
                 docLinks: {
                   links: {
                     ml: '',
-                    enterpriseSearch: '',
+                    inferenceManagement: {
+                      inferenceAPIDocumentation: 'https://abc.com/inference-api-create',
+                    },
                   },
                 },
                 core: {
@@ -819,6 +826,20 @@ describe('<IndexDetailsPage />', () => {
                       },
                     },
                   },
+                  share: {
+                    url: {
+                      locators: {
+                        get: jest.fn((id) => {
+                          switch (id) {
+                            case INFERENCE_LOCATOR:
+                              return mockInferenceManagementLocator;
+                            default:
+                              throw new Error(`Unknown locator id: ${id}`);
+                          }
+                        }),
+                      },
+                    },
+                  },
                 },
               },
             });
diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/select_inference_id.test.tsx b/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/select_inference_id.test.tsx
index 2fb9165e8fd10..1c9633f829bc3 100644
--- a/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/select_inference_id.test.tsx
+++ b/x-pack/plugins/index_management/__jest__/client_integration/index_details_page/select_inference_id.test.tsx
@@ -20,6 +20,11 @@ import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
 
 const createInferenceEndpointMock = jest.fn();
 const mockDispatch = jest.fn();
+const INFERENCE_LOCATOR = 'SEARCH_INFERENCE_ENDPOINTS';
+const createMockLocator = (id: string) => ({
+  useUrl: jest.fn().mockReturnValue('https://redirect.me/to/inference_endpoints'),
+});
+const mockInferenceManagementLocator = createMockLocator(INFERENCE_LOCATOR);
 
 jest.mock('../../../public/application/app_context', () => ({
   useAppContext: jest.fn().mockReturnValue({
@@ -33,8 +38,8 @@ jest.mock('../../../public/application/app_context', () => ({
     },
     docLinks: {
       links: {
-        enterpriseSearch: {
-          inferenceApiCreate: 'https://abc.com/inference-api-create',
+        inferenceManagement: {
+          inferenceAPIDocumentation: 'https://abc.com/inference-api-create',
         },
       },
     },
@@ -47,6 +52,20 @@ jest.mock('../../../public/application/app_context', () => ({
           },
         },
       },
+      share: {
+        url: {
+          locators: {
+            get: jest.fn((id) => {
+              switch (id) {
+                case INFERENCE_LOCATOR:
+                  return mockInferenceManagementLocator;
+                default:
+                  throw new Error(`Unknown locator id: ${id}`);
+              }
+            }),
+          },
+        },
+      },
     },
   }),
 }));