Modified Select component to take in a testid parameter that sets the data-testid of the material ui Select component, ensuring backwards compatibility with default value corresponding to previously hardcoded parameter

Signed-off-by: Simon Edström <simon.edstrom@scania.com>
This commit is contained in:
Simon Edström
2024-06-24 22:03:10 +02:00
parent c9a2e96634
commit 8fadb84aa4
@@ -32,6 +32,7 @@ import React, { useEffect, useState } from 'react';
import ClosedDropdown from './static/ClosedDropdown';
import OpenedDropdown from './static/OpenedDropdown';
import { string } from 'zod';
/** @public */
export type SelectInputBaseClassKey = 'root' | 'input';
@@ -136,6 +137,7 @@ export type SelectProps = {
native?: boolean;
disabled?: boolean;
margin?: 'dense' | 'none';
testid?: string;
};
/** @public */
@@ -151,6 +153,7 @@ export function SelectComponent(props: SelectProps) {
native = false,
disabled = false,
margin,
testid = 'select',
} = props;
const classes = useStyles();
const [value, setValue] = useState<SelectedItems>(
@@ -203,7 +206,7 @@ export function SelectComponent(props: SelectProps) {
value={value}
native={native}
disabled={disabled}
data-testid="select"
data-testid={testid}
displayEmpty
multiple={multiple}
margin={margin}