From a802656478625387c2ccd694ac01673fa73b0e93 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 31 Jul 2022 17:29:00 +0200 Subject: [PATCH] Fixes warnings in some tests (#2241) Signed-off-by: Tilman Vatteroth --- .../copy-to-clipboard-button.test.tsx | 12 +++---- ...reate-non-existing-note-hint.test.tsx.snap | 10 +++--- .../create-non-existing-note-hint.test.tsx | 35 +++++++++++++------ .../create-non-existing-note-hint.tsx | 2 +- .../common/user-avatar/user-avatar.test.tsx | 6 ++++ .../wait-for-other-promises-to-finish.ts | 17 +++++++++ 6 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 src/utils/wait-for-other-promises-to-finish.ts diff --git a/src/components/common/copyable/copy-to-clipboard-button/copy-to-clipboard-button.test.tsx b/src/components/common/copyable/copy-to-clipboard-button/copy-to-clipboard-button.test.tsx index 2c45a9624..b66bab8e2 100644 --- a/src/components/common/copyable/copy-to-clipboard-button/copy-to-clipboard-button.test.tsx +++ b/src/components/common/copyable/copy-to-clipboard-button/copy-to-clipboard-button.test.tsx @@ -4,15 +4,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - import { mockI18n } from '../../../markdown-renderer/test-utils/mock-i18n' import { CopyToClipboardButton } from './copy-to-clipboard-button' -import { render, screen } from '@testing-library/react' +import { act, render, screen } from '@testing-library/react' import * as uuidModule from 'uuid' jest.mock('uuid') @@ -46,7 +40,9 @@ describe('Copy to clipboard button', () => { const view = render(copyToClipboardButton) expect(view.container).toMatchSnapshot() const button = await screen.findByTitle('renderer.highlightCode.copyCode') - button.click() + act(() => { + button.click() + }) const tooltip = await screen.findByRole('tooltip') expect(tooltip).toHaveTextContent(expectSuccess ? 'copyOverlay.success' : 'copyOverlay.error') expect(tooltip).toHaveAttribute('id', overlayId) diff --git a/src/components/common/note-loading-boundary/__snapshots__/create-non-existing-note-hint.test.tsx.snap b/src/components/common/note-loading-boundary/__snapshots__/create-non-existing-note-hint.test.tsx.snap index a2eed506b..2159a9540 100644 --- a/src/components/common/note-loading-boundary/__snapshots__/create-non-existing-note-hint.test.tsx.snap +++ b/src/components/common/note-loading-boundary/__snapshots__/create-non-existing-note-hint.test.tsx.snap @@ -35,7 +35,7 @@ exports[`create non existing note hint renders an button as initial state 1`] =