-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8.18' into backport/8.18/pr-209973
- Loading branch information
Showing
52 changed files
with
1,530 additions
and
345 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
...ference-endpoint-ui-common/src/components/configuration/configuration_form_items.test.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,87 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { ConfigurationFormItems } from './configuration_form_items'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { FieldType } from '../../types/dynamic_config/types'; | ||
|
||
describe('ConfigurationFormItems', () => { | ||
const mockItems = [ | ||
{ | ||
key: 'model_id', | ||
isValid: true, | ||
label: 'Model ID', | ||
description: 'Enter model ID', | ||
validationErrors: [], | ||
required: true, | ||
sensitive: false, | ||
value: '', | ||
default_value: '', | ||
updatable: false, | ||
type: FieldType.STRING, | ||
supported_task_types: ['text_embedding'], | ||
}, | ||
]; | ||
|
||
const defaultProps = { | ||
isLoading: false, | ||
items: mockItems, | ||
setConfigEntry: jest.fn(), | ||
}; | ||
|
||
it('renders link when isInternalProvider is true and key is model_id', () => { | ||
render(<ConfigurationFormItems {...defaultProps} isInternalProvider={true} />); | ||
|
||
const link = screen.getByRole('link', { name: /looking for elasticsearch model ids/i }); | ||
expect(link).toBeInTheDocument(); | ||
expect(link).toHaveAttribute( | ||
'href', | ||
'https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html#default-enpoints' | ||
); | ||
|
||
expect(screen.getByTestId('model_id-input')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not renders link when isInternalProvider is true and key is model_id', () => { | ||
const numAllocations = [ | ||
{ | ||
key: 'num_allocations', | ||
isValid: true, | ||
label: 'Number Allocations', | ||
description: | ||
'The total number of allocations this model is assigned across machine learning nodes.', | ||
validationErrors: [], | ||
required: true, | ||
sensitive: false, | ||
value: '', | ||
default_value: 1, | ||
updatable: true, | ||
type: FieldType.INTEGER, | ||
supported_task_types: ['text_embedding'], | ||
}, | ||
]; | ||
|
||
const props = { | ||
isLoading: false, | ||
items: numAllocations, | ||
setConfigEntry: jest.fn(), | ||
}; | ||
|
||
render(<ConfigurationFormItems {...props} isInternalProvider={true} />); | ||
|
||
const link = screen.queryByRole('link', { name: /looking for elasticsearch model ids/i }); | ||
expect(link).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('does not renders link when isInternalProvider is false and key is model_id', () => { | ||
render(<ConfigurationFormItems {...defaultProps} isInternalProvider={false} />); | ||
|
||
const link = screen.queryByRole('link', { name: /looking for elasticsearch model ids/i }); | ||
expect(link).not.toBeInTheDocument(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.