From d76714f2a2a0edfa03fa2a91c99ae7ce19618bef Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 5 Feb 2023 17:45:16 +0100 Subject: [PATCH] fix(commons): Move "wait for other promises to finish" util to commons Signed-off-by: Tilman Vatteroth --- .../realtime-note/realtime-note.service.spec.ts | 1 - .../test-utils/wait-for-other-promises-to-finish.ts | 12 ------------ commons/src/index.ts | 2 ++ .../src/utils/wait-for-other-promises-to-finish.ts | 0 .../create-non-existing-note-hint.test.tsx | 2 +- 5 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 backend/src/realtime/realtime-note/test-utils/wait-for-other-promises-to-finish.ts rename {frontend => commons}/src/utils/wait-for-other-promises-to-finish.ts (100%) diff --git a/backend/src/realtime/realtime-note/realtime-note.service.spec.ts b/backend/src/realtime/realtime-note/realtime-note.service.spec.ts index 34e0dd8a4..774158756 100644 --- a/backend/src/realtime/realtime-note/realtime-note.service.spec.ts +++ b/backend/src/realtime/realtime-note/realtime-note.service.spec.ts @@ -17,7 +17,6 @@ import { RealtimeNoteService } from './realtime-note.service'; import { mockAwareness } from './test-utils/mock-awareness'; import { mockRealtimeNote } from './test-utils/mock-realtime-note'; import { mockWebsocketDoc } from './test-utils/mock-websocket-doc'; -import { waitForOtherPromisesToFinish } from './test-utils/wait-for-other-promises-to-finish'; import { WebsocketDoc } from './websocket-doc'; describe('RealtimeNoteService', () => { diff --git a/backend/src/realtime/realtime-note/test-utils/wait-for-other-promises-to-finish.ts b/backend/src/realtime/realtime-note/test-utils/wait-for-other-promises-to-finish.ts deleted file mode 100644 index 3886a1d8b..000000000 --- a/backend/src/realtime/realtime-note/test-utils/wait-for-other-promises-to-finish.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -/** - * Waits until all other pending promises are processed. - */ -export async function waitForOtherPromisesToFinish(): Promise { - return await new Promise((resolve) => process.nextTick(resolve)); -} diff --git a/commons/src/index.ts b/commons/src/index.ts index e2ec552b7..43a13b828 100644 --- a/commons/src/index.ts +++ b/commons/src/index.ts @@ -25,3 +25,5 @@ export { encodeServerVersionUpdatedMessage } from './messages/server-version-upd export { WebsocketTransporter } from './websocket-transporter.js' export type { MessageTransporterEvents } from './y-doc-message-transporter.js' + +export { waitForOtherPromisesToFinish } from './utils/wait-for-other-promises-to-finish.js' diff --git a/frontend/src/utils/wait-for-other-promises-to-finish.ts b/commons/src/utils/wait-for-other-promises-to-finish.ts similarity index 100% rename from frontend/src/utils/wait-for-other-promises-to-finish.ts rename to commons/src/utils/wait-for-other-promises-to-finish.ts diff --git a/frontend/src/components/common/note-loading-boundary/create-non-existing-note-hint.test.tsx b/frontend/src/components/common/note-loading-boundary/create-non-existing-note-hint.test.tsx index ad9815e95..c0aa75ae2 100644 --- a/frontend/src/components/common/note-loading-boundary/create-non-existing-note-hint.test.tsx +++ b/frontend/src/components/common/note-loading-boundary/create-non-existing-note-hint.test.tsx @@ -6,9 +6,9 @@ import * as createNoteWithPrimaryAliasModule from '../../../api/notes' import type { Note, NoteMetadata } from '../../../api/notes/types' import * as useSingleStringUrlParameterModule from '../../../hooks/common/use-single-string-url-parameter' -import { waitForOtherPromisesToFinish } from '../../../utils/wait-for-other-promises-to-finish' import { mockI18n } from '../../markdown-renderer/test-utils/mock-i18n' import { CreateNonExistingNoteHint } from './create-non-existing-note-hint' +import { waitForOtherPromisesToFinish } from '@hedgedoc/commons' import { act, render, screen, waitFor } from '@testing-library/react' import { Mock } from 'ts-mockery'