Skip to content

Commit 855fd93

Browse files
JonasBabillyvg
authored andcommitted
admin: add icon test (#89439)
Add icon test and assert that onAction is called if skipConfirmModal is truthy
1 parent 3bc823a commit 855fd93

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
2+
3+
import DropdownActions from './dropdownActions';
4+
5+
describe('DropdownActions', () => {
6+
it('selecting actions calls onAction', async () => {
7+
const cb = jest.fn();
8+
render(
9+
<DropdownActions
10+
label="Trigger"
11+
actions={[
12+
{
13+
disabled: false,
14+
key: 'first',
15+
name: 'Option',
16+
onAction: cb,
17+
skipConfirmModal: true,
18+
},
19+
]}
20+
/>
21+
);
22+
23+
await userEvent.click(screen.getByText('Trigger'));
24+
await userEvent.click(screen.getByText('Option'));
25+
expect(screen.queryByTestId('disabled-icon')).not.toBeInTheDocument();
26+
expect(cb).toHaveBeenCalled();
27+
});
28+
29+
it('disabled actions have an icon', async () => {
30+
const cb = jest.fn();
31+
render(
32+
<DropdownActions
33+
label="Trigger"
34+
actions={[{disabled: true, key: 'first', name: 'Disabled Option', onAction: cb}]}
35+
/>
36+
);
37+
38+
await userEvent.click(screen.getByText('Trigger'));
39+
expect(await screen.findByTestId('disabled-icon')).toBeInTheDocument();
40+
});
41+
});

static/gsAdmin/components/dropdownActions.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function mapActionsToCompactSelect(
3939
label: (
4040
<div>
4141
{action.name}
42-
{action.disabled && <StyledIconNot size="xs" />}
42+
{action.disabled && <StyledIconNot data-test-id="disabled-icon" size="xs" />}
4343
</div>
4444
),
4545
details: action.help,

0 commit comments

Comments
 (0)