From c9128c3436e0d2318369c7cc174dad80ab2a47af Mon Sep 17 00:00:00 2001 From: Oleksii Kurinnyi Date: Tue, 17 Sep 2024 15:53:19 +0300 Subject: [PATCH] fix: usage of userEvent Signed-off-by: Oleksii Kurinnyi --- .../__tests__/__snapshots__/index.spec.tsx.snap | 1 - .../Form/SshPassphrase/__tests__/index.spec.tsx | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/__snapshots__/index.spec.tsx.snap b/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/__snapshots__/index.spec.tsx.snap index e50dfd19f..36151634b 100644 --- a/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/__snapshots__/index.spec.tsx.snap +++ b/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/__snapshots__/index.spec.tsx.snap @@ -41,7 +41,6 @@ exports[`SshPassphrase snapshot 1`] = ` required={false} type="password" /> - diff --git a/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/index.spec.tsx b/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/index.spec.tsx index 8efb588da..cec07f2f3 100644 --- a/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/index.spec.tsx +++ b/packages/dashboard-frontend/src/pages/UserPreferences/SshKeys/AddModal/Form/SshPassphrase/__tests__/index.spec.tsx @@ -34,7 +34,7 @@ describe('SshPassphrase', () => { }); describe('text area', () => { - it('should handle SSH passphrase', () => { + it('should handle SSH passphrase', async () => { renderComponent(); expect(mockOnChange).not.toHaveBeenCalled(); @@ -42,12 +42,13 @@ describe('SshPassphrase', () => { const input = screen.getByPlaceholderText('Enter passphrase (optional)'); const passphrase = 'passphrase'; - userEvent.paste(input, passphrase); + await userEvent.click(input) + await userEvent.paste(passphrase); expect(mockOnChange).toHaveBeenCalledWith(passphrase); }); - it('should handle the empty value', () => { + it('should handle the empty value', async () => { renderComponent(); expect(mockOnChange).not.toHaveBeenCalled(); @@ -55,12 +56,13 @@ describe('SshPassphrase', () => { const input = screen.getByPlaceholderText('Enter passphrase (optional)'); // fill the SSH key data field - userEvent.paste(input, 'ssh-key-data'); + await userEvent.click(input); + await userEvent.paste('ssh-key-data'); mockOnChange.mockClear(); // clear the SSH key data field - userEvent.clear(input); + await userEvent.clear(input); expect(mockOnChange).toHaveBeenCalledWith(''); });