mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-01 13:13:10 +00:00
MINOR: fix search index language configuration not saving (#15896)
* fix search index language configuration not saving * minor changes
This commit is contained in:
parent
9995a13ac9
commit
23eb4ee1c9
@ -52,6 +52,10 @@ describe('Search Index Application', { tags: 'Settings' }, () => {
|
|||||||
|
|
||||||
cy.get('#root\\/batchSize').type('0');
|
cy.get('#root\\/batchSize').type('0');
|
||||||
cy.get('form [title="Chart"] [role="img"]').click();
|
cy.get('form [title="Chart"] [role="img"]').click();
|
||||||
|
cy.get(
|
||||||
|
'[data-testid="select-widget"] > .ant-select-selector > .ant-select-selection-item'
|
||||||
|
).click();
|
||||||
|
cy.get('[data-testid="select-option-JP"]').click();
|
||||||
|
|
||||||
cy.get('[data-testid="submit-btn"]').click();
|
cy.get('[data-testid="submit-btn"]').click();
|
||||||
verifyResponseStatusCode('@updateApplication', 200);
|
verifyResponseStatusCode('@updateApplication', 200);
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Collate.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Registry, WidgetProps } from '@rjsf/utils';
|
||||||
|
import {
|
||||||
|
act,
|
||||||
|
findByRole,
|
||||||
|
fireEvent,
|
||||||
|
render,
|
||||||
|
screen,
|
||||||
|
waitForElement,
|
||||||
|
} from '@testing-library/react';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import React from 'react';
|
||||||
|
import { MOCK_SELECT_WIDGET } from '../../../../../mocks/SelectWidget.mock';
|
||||||
|
import SelectWidget from './SelectWidget';
|
||||||
|
|
||||||
|
const mockOnFocus = jest.fn();
|
||||||
|
const mockOnBlur = jest.fn();
|
||||||
|
const mockOnChange = jest.fn();
|
||||||
|
|
||||||
|
const mockProps: WidgetProps = {
|
||||||
|
onFocus: mockOnFocus,
|
||||||
|
onBlur: mockOnBlur,
|
||||||
|
onChange: mockOnChange,
|
||||||
|
registry: {} as Registry,
|
||||||
|
...MOCK_SELECT_WIDGET,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Test SelectWidget Component', () => {
|
||||||
|
it('Should render select component', async () => {
|
||||||
|
render(<SelectWidget {...mockProps} />);
|
||||||
|
|
||||||
|
const selectInput = screen.getByTestId('select-widget');
|
||||||
|
|
||||||
|
expect(selectInput).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should be disabled', async () => {
|
||||||
|
render(<SelectWidget {...mockProps} disabled />);
|
||||||
|
|
||||||
|
const selectInput = await findByRole(
|
||||||
|
screen.getByTestId('select-widget'),
|
||||||
|
'combobox'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(selectInput).toBeDisabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should call onFocus', async () => {
|
||||||
|
render(<SelectWidget {...mockProps} />);
|
||||||
|
|
||||||
|
const selectInput = screen.getByTestId('select-widget');
|
||||||
|
|
||||||
|
fireEvent.focus(selectInput);
|
||||||
|
|
||||||
|
expect(mockOnFocus).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should call onBlur', async () => {
|
||||||
|
render(<SelectWidget {...mockProps} />);
|
||||||
|
|
||||||
|
const selectInput = screen.getByTestId('select-widget');
|
||||||
|
|
||||||
|
fireEvent.blur(selectInput);
|
||||||
|
|
||||||
|
expect(mockOnBlur).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should call onChange', async () => {
|
||||||
|
render(<SelectWidget {...mockProps} />);
|
||||||
|
|
||||||
|
const selectInput = await findByRole(
|
||||||
|
screen.getByTestId('select-widget'),
|
||||||
|
'combobox'
|
||||||
|
);
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
userEvent.click(selectInput);
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitForElement(() => screen.getByTestId('select-option-JP'));
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
fireEvent.click(screen.getByTestId('select-option-EN'));
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockOnChange).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2023 Collate.
|
* Copyright 2024 Collate.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -12,10 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
import { WidgetProps } from '@rjsf/utils';
|
import { WidgetProps } from '@rjsf/utils';
|
||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
import { capitalize, uniqueId } from 'lodash';
|
import { capitalize } from 'lodash';
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
const MultiSelectWidget: FC<WidgetProps> = ({
|
const SelectWidget: FC<WidgetProps> = ({
|
||||||
onFocus,
|
onFocus,
|
||||||
onBlur,
|
onBlur,
|
||||||
onChange,
|
onChange,
|
||||||
@ -25,16 +25,20 @@ const MultiSelectWidget: FC<WidgetProps> = ({
|
|||||||
<Select
|
<Select
|
||||||
autoFocus={rest.autofocus}
|
autoFocus={rest.autofocus}
|
||||||
className="d-block w-full"
|
className="d-block w-full"
|
||||||
|
data-testid="select-widget"
|
||||||
disabled={rest.disabled}
|
disabled={rest.disabled}
|
||||||
id={rest.id}
|
id={rest.id}
|
||||||
mode={rest.multiple ? 'multiple' : 'tags'}
|
mode={rest.multiple ? 'multiple' : undefined}
|
||||||
placeholder={rest.placeholder}
|
placeholder={rest.placeholder}
|
||||||
value={rest.value}
|
value={rest.value}
|
||||||
onBlur={() => onBlur(rest.id, rest.value)}
|
onBlur={() => onBlur(rest.id, rest.value)}
|
||||||
onChange={(value) => onChange(value)}
|
onChange={(value) => onChange(value)}
|
||||||
onFocus={() => onFocus(rest.id, rest.value)}>
|
onFocus={() => onFocus(rest.id, rest.value)}>
|
||||||
{(rest.options.enumOptions ?? []).map((option) => (
|
{(rest.options.enumOptions ?? []).map((option) => (
|
||||||
<Select.Option key={uniqueId()} value={option.value}>
|
<Select.Option
|
||||||
|
data-testid={`select-option-${option.label}`}
|
||||||
|
key={option.value}
|
||||||
|
value={option.value}>
|
||||||
{capitalize(option.label)}
|
{capitalize(option.label)}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
@ -42,4 +46,4 @@ const MultiSelectWidget: FC<WidgetProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MultiSelectWidget;
|
export default SelectWidget;
|
@ -26,8 +26,8 @@ import DescriptionFieldTemplate from '../Form/JSONSchema/JSONSchemaTemplate/Desc
|
|||||||
import { FieldErrorTemplate } from '../Form/JSONSchema/JSONSchemaTemplate/FieldErrorTemplate/FieldErrorTemplate';
|
import { FieldErrorTemplate } from '../Form/JSONSchema/JSONSchemaTemplate/FieldErrorTemplate/FieldErrorTemplate';
|
||||||
import { ObjectFieldTemplate } from '../Form/JSONSchema/JSONSchemaTemplate/ObjectFieldTemplate';
|
import { ObjectFieldTemplate } from '../Form/JSONSchema/JSONSchemaTemplate/ObjectFieldTemplate';
|
||||||
import AsyncSelectWidget from '../Form/JSONSchema/JsonSchemaWidgets/AsyncSelectWidget';
|
import AsyncSelectWidget from '../Form/JSONSchema/JsonSchemaWidgets/AsyncSelectWidget';
|
||||||
import MultiSelectWidget from '../Form/JSONSchema/JsonSchemaWidgets/MultiSelectWidget';
|
|
||||||
import PasswordWidget from '../Form/JSONSchema/JsonSchemaWidgets/PasswordWidget';
|
import PasswordWidget from '../Form/JSONSchema/JsonSchemaWidgets/PasswordWidget';
|
||||||
|
import SelectWidget from '../Form/JSONSchema/JsonSchemaWidgets/SelectWidget';
|
||||||
import Loader from '../Loader/Loader';
|
import Loader from '../Loader/Loader';
|
||||||
|
|
||||||
export interface Props extends FormProps {
|
export interface Props extends FormProps {
|
||||||
@ -70,7 +70,7 @@ const FormBuilder: FunctionComponent<Props> = forwardRef(
|
|||||||
const widgets = {
|
const widgets = {
|
||||||
PasswordWidget: PasswordWidget,
|
PasswordWidget: PasswordWidget,
|
||||||
autoComplete: AsyncSelectWidget,
|
autoComplete: AsyncSelectWidget,
|
||||||
...(useSelectWidget && { SelectWidget: MultiSelectWidget }),
|
...(useSelectWidget && { SelectWidget: SelectWidget }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Collate.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export const MOCK_SELECT_WIDGET = {
|
||||||
|
autofocus: false,
|
||||||
|
disabled: false,
|
||||||
|
formContext: { handleFocus: undefined },
|
||||||
|
hideError: undefined,
|
||||||
|
hideLabel: false,
|
||||||
|
id: 'root/searchIndexMappingLanguage',
|
||||||
|
label: 'Search Index Language',
|
||||||
|
name: 'searchIndexMappingLanguage',
|
||||||
|
options: {
|
||||||
|
enumOptions: [
|
||||||
|
{ label: 'EN', value: 'EN' },
|
||||||
|
{ label: 'JP', value: 'JP' },
|
||||||
|
{ label: 'ZH', value: 'ZH' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
placeholder: '',
|
||||||
|
rawErrors: undefined,
|
||||||
|
readonly: false,
|
||||||
|
required: false,
|
||||||
|
schema: {
|
||||||
|
description: 'Recreate Indexes with updated Language',
|
||||||
|
title: 'Search Index Language',
|
||||||
|
javaType: 'org.openmetadata.schema.type.IndexMappingLanguage',
|
||||||
|
enum: ['EN', 'JP', 'ZH'],
|
||||||
|
},
|
||||||
|
uiSchema: {},
|
||||||
|
value: 'JP',
|
||||||
|
};
|
@ -72,6 +72,7 @@ export type ListTestCaseParamsBySearch = ListTestCaseParams & {
|
|||||||
endTimestamp?: number;
|
endTimestamp?: number;
|
||||||
testPlatforms?: TestPlatform[];
|
testPlatforms?: TestPlatform[];
|
||||||
offset?: number;
|
offset?: number;
|
||||||
|
owner?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListTestDefinitionsParams = ListParams & {
|
export type ListTestDefinitionsParams = ListParams & {
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
@blue-2: #3ca2f4;
|
@blue-2: #3ca2f4;
|
||||||
@blue-3: #0950c5;
|
@blue-3: #0950c5;
|
||||||
@blue-4: #f1f9ff;
|
@blue-4: #f1f9ff;
|
||||||
|
@partial-success-1: #06a4a4;
|
||||||
|
@partial-success-2: #bdeeee;
|
||||||
@black: #000000;
|
@black: #000000;
|
||||||
@aborted-color: #efae2f;
|
@aborted-color: #efae2f;
|
||||||
@text-color: #292929;
|
@text-color: #292929;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user