Skip to content

Commit

Permalink
Fixing semantic_text field tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Samiul-TheSoccerFan committed Nov 21, 2024
1 parent 41d3620 commit 4b757e1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -750,7 +755,9 @@ describe('<IndexDetailsPage />', () => {
docLinks: {
links: {
ml: '',
enterpriseSearch: '',
inferenceManagement: {
inferenceAPIDocumentation: 'https://abc.com/inference-api-create',
},
},
},
core: {
Expand Down Expand Up @@ -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}`);
}
}),
},
},
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
},
},
},
Expand All @@ -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}`);
}
}),
},
},
},
},
}),
}));
Expand Down

0 comments on commit 4b757e1

Please sign in to comment.