Skip to content

Commit

Permalink
chore: Add data-test attribute to picker item remove button #273 (#2271)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbranley authored Feb 22, 2024
1 parent 15283bf commit 721273a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ui/src/picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ describe('Picker.tsx', () => {
expect(queryByTestId(name)).toBeInTheDocument()
})

it('Renders data-test attr on selection remove button', () => {
const { queryByTestId } = render(<XPicker model={{...pickerProps, values: [name]}} />)

const removeButton = (queryByTestId('remove_'+name) as HTMLElement)
expect(removeButton).toBeInTheDocument()
fireEvent.click(removeButton)
expect(queryByTestId('remove_'+name)).toBe(null)
})

it('Sets correct args - init', () => {
render(<XPicker model={pickerProps} />)
expect(wave.args[name]).toBeNull()
Expand Down
1 change: 1 addition & 0 deletions ui/src/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const XPicker = ({ model: m }: { model: Picker }) => {
{m.label && <Fluent.Label required={m.required}>{m.label}</Fluent.Label>}
<Fluent.TagPicker
inputProps={{ 'data-test': m.name } as Fluent.IInputProps}
removeButtonIconProps={{ iconName: 'Cancel', 'data-test' : 'remove_' + m.name } as Fluent.IIconProps}
removeButtonAriaLabel="Remove"
onResolveSuggestions={filterSuggestedTags}
onChange={onChange}
Expand Down

0 comments on commit 721273a

Please sign in to comment.