Skip to content

Commit 8c8b58a

Browse files
test: improve coverage
1 parent 9163cba commit 8c8b58a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/discussions/common/ActionsDropdown.test.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ describe('ActionsDropdown', () => {
242242
await waitFor(() => expect(screen.queryByText('Copy link')).not.toBeInTheDocument());
243243
});
244244

245+
it('should close the dropdown when pressing escape', async () => {
246+
const discussionObject = buildTestContent({ editable_fields: ['copy_link'] }).discussion;
247+
await mockThreadAndComment(discussionObject);
248+
renderComponent({ ...camelCaseObject(discussionObject) });
249+
250+
const openButton = await findOpenActionsDropdownButton();
251+
await act(async () => {
252+
fireEvent.click(openButton);
253+
});
254+
255+
await waitFor(() => expect(screen.getByRole('button', { name: 'Copy link' })).toBeInTheDocument());
256+
257+
await act(async () => {
258+
fireEvent.keyDown(document.body, { key: 'Escape', code: 'Escape' });
259+
});
260+
261+
await waitFor(() => expect(screen.queryByRole('button', { name: 'Copy link' })).toBeNull());
262+
});
263+
245264
describe.each(canPerformActionTestData)('Actions', ({
246265
testFor, action, label, ...commentOrPost
247266
}) => {

0 commit comments

Comments
 (0)