Skip to content

Commit aeb1927

Browse files
committed
Add ids to input elements in order to simplifly tests
1 parent 548d1cb commit aeb1927

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/ui/ConfigEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
124124
onChange={this.onEditionChange}
125125
value={jsonData.edition}
126126
placeholder="Select your checkmk edition"
127+
inputId="checkmk-edition"
127128
/>
128129
</InlineField>
129130
<InlineField

src/ui/components.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export const CheckMkSelect = <Key extends RequestSpecStringKeys>(props: CheckMkS
174174
return (
175175
<InlineField labelWidth={LABEL_WIDTH} label={props.label}>
176176
<CheckMkAsyncSelect
177-
inputId={`input_${props.label}`}
177+
inputId={`input_${props.label?.replace(/ /g, '_')}`}
178178
label={label}
179179
autocompleter={autocompleter}
180180
onChange={onChange}
@@ -376,11 +376,12 @@ export const HostTagFilter: React.FC<HostTagFilterProps> = (props) => {
376376
};
377377

378378
interface HostLabelProps extends CommonProps<RequestSpec['host_labels']> {
379+
inputId: string;
379380
autocompleter: (value: string) => Promise<Array<SelectableValue<string>>>;
380381
}
381382

382383
export const HostLabelFilter: React.FC<HostLabelProps> = (props) => {
383-
const { value, autocompleter, label, onChange } = props;
384+
const { value, autocompleter, label, onChange, inputId } = props;
384385

385386
const onLabelsChange = (items: Array<SelectableValue<string>>) => {
386387
const result: string[] = [];
@@ -410,6 +411,7 @@ export const HostLabelFilter: React.FC<HostLabelProps> = (props) => {
410411
onChange={onLabelsChange}
411412
value={toMultiSelectValue(value)}
412413
placeholder="Type to trigger search"
414+
inputId={inputId}
413415
/>
414416
</InlineField>
415417
);
@@ -487,6 +489,7 @@ export const OnlyActiveChildren = (props: OnlyActiveChildrenProps): JSX.Element
487489
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
488490
onChange={(value) => setActiveComponents((c) => [...c, value.value!])}
489491
value={{ label: 'Add Filter' }}
492+
inputId="input_add_filter"
490493
/>
491494
</InlineField>
492495
)}

src/ui/filters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export const Filters = (props: FiltersProp): JSX.Element => {
156156
value={qHost.host_labels}
157157
onChange={(host_labels: string[]) => setHostFilter({ ...qHost, host_labels: host_labels })}
158158
autocompleter={hostLabelAutocompleter}
159+
inputId="input_host_label"
159160
/>
160161
<HostTagFilter
161162
label={labelForRequestSpecKey('host_tags', requestSpec)}

0 commit comments

Comments
 (0)