Skip to content

Commit dddf23b

Browse files
author
Kubit
committed
Modify dataTesId to be unique
1 parent 90d68c4 commit dddf23b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/components/inputDropdown/__tests__/inputDropdown.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('New Input Dropdown Component', () => {
220220
const listOptions = screen.getByRole(ROLES.LISTBOX);
221221
expect(listOptions).toBeInTheDocument();
222222

223-
const inputOption = screen.getByTestId('testidOptionsListOption0');
223+
const inputOption = screen.getByTestId('testidOptionsListOption0option1');
224224
expect(inputOption).toHaveFocus();
225225
});
226226

@@ -252,7 +252,9 @@ describe('New Input Dropdown Component', () => {
252252
fireEvent.keyDown(inputDropdown, ARROW_DOWN);
253253
});
254254

255-
const inputOption = screen.getByTestId('testidOptionsListOption0');
255+
const inputOption = screen.getByTestId(
256+
'testidOptionsListOption0option1LastNoHightlightedLabel'
257+
);
256258

257259
await act(async () => {
258260
fireEvent.keyDown(inputOption, {

src/components/inputSearch/__tests__/inputSearch.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ describe('New Input Search Component', () => {
208208
});
209209

210210
it('Should focus second option with arrow down', async () => {
211-
renderProvider(
211+
const { debug } = renderProvider(
212212
<InputSearch
213213
{...mockProps}
214214
optionList={[
215215
{
216-
options: ['option1', 'option'],
216+
options: ['option1', 'option2'],
217217
},
218218
]}
219219
value=""
@@ -230,15 +230,15 @@ describe('New Input Search Component', () => {
230230
const listOptions = screen.getByRole(ROLES.LISTBOX);
231231
expect(listOptions).toBeInTheDocument();
232232

233-
const inputOption1 = screen.getByTestId('testidOptionsList0Option1');
234-
const inputOption2 = screen.getByTestId('testidOptionsList0Option2');
233+
const inputOption1 = screen.getByTestId('testidOptionsList0Option1option1');
234+
const inputOption2 = screen.getByTestId('testidOptionsList0Option2option2');
235235

236236
fireEvent.keyDown(inputOption1, ARROW_DOWN);
237237
fireEvent.keyUp(inputOption2, ARROW_DOWN);
238238
fireEvent.keyDown(inputOption1, ARROW_DOWN);
239239

240+
debug();
240241
expect(inputOption2).toHaveFocus();
241-
242242
fireEvent.keyDown(inputOption2, ARROW_UP);
243243
expect(inputOption1).toHaveFocus();
244244
});

src/components/listOptions/listOptionsStandAlone.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ export const ListOptionsStandAlone = React.forwardRef(
7979
props.multiSelect,
8080
props.caseSensitive
8181
);
82+
const title = props.title?.content || '';
83+
const dataTestIdOption = `${dataTestId}${title}Option${index}${option.label}`;
84+
8285
const optionComponent = (
8386
<Option
8487
key={`${id}Option${index}`}
8588
aria-selected={isSelection ? selected : undefined}
8689
as={isNavigation ? 'div' : 'li'}
8790
checkedIcon={props.checkedIcon}
88-
dataTestId={`${dataTestId}Option${index}`}
91+
dataTestId={dataTestIdOption}
8992
focus={focus === index}
9093
labelCharsHighlighted={props.charsHighlighted}
9194
multiSelect={props.multiSelect}

0 commit comments

Comments
 (0)