mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
fix(frontend): Fix create-non-existing-note-hint.test.tsx
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
6e5363b971
commit
0695bbb2ad
1 changed files with 11 additions and 4 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import * as useSingleStringUrlParameterModule from '../../../hooks/common/use-single-string-url-parameter'
|
import * as useSingleStringUrlParameterModule from '../../../hooks/common/use-single-string-url-parameter'
|
||||||
import { mockI18n } from '../../markdown-renderer/test-utils/mock-i18n'
|
import { mockI18n } from '../../markdown-renderer/test-utils/mock-i18n'
|
||||||
import { act, render, screen } from '@testing-library/react'
|
import { act, render, screen, waitFor } from '@testing-library/react'
|
||||||
import { CreateNonExistingNoteHint } from './create-non-existing-note-hint'
|
import { CreateNonExistingNoteHint } from './create-non-existing-note-hint'
|
||||||
import * as createNoteWithPrimaryAliasModule from '../../../api/notes'
|
import * as createNoteWithPrimaryAliasModule from '../../../api/notes'
|
||||||
import type { Note, NoteMetadata } from '../../../api/notes/types'
|
import type { Note, NoteMetadata } from '../../../api/notes/types'
|
||||||
|
@ -34,6 +34,7 @@ describe('create non existing note hint', () => {
|
||||||
expect(markdown).toBe('')
|
expect(markdown).toBe('')
|
||||||
expect(primaryAlias).toBe(mockedNoteId)
|
expect(primaryAlias).toBe(mockedNoteId)
|
||||||
const metadata: NoteMetadata = Mock.of<NoteMetadata>({ primaryAddress: 'mockedPrimaryAlias' })
|
const metadata: NoteMetadata = Mock.of<NoteMetadata>({ primaryAddress: 'mockedPrimaryAlias' })
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||||
await waitForOtherPromisesToFinish()
|
await waitForOtherPromisesToFinish()
|
||||||
return Mock.of<Note>({ metadata })
|
return Mock.of<Note>({ metadata })
|
||||||
})
|
})
|
||||||
|
@ -80,7 +81,9 @@ describe('create non existing note hint', () => {
|
||||||
await act(() => {
|
await act(() => {
|
||||||
button.click()
|
button.click()
|
||||||
})
|
})
|
||||||
await screen.findByTestId('loadingMessage')
|
await waitFor(async () => {
|
||||||
|
expect(await screen.findByTestId('loadingMessage')).toBeInTheDocument()
|
||||||
|
})
|
||||||
expect(onNoteCreatedCallback).not.toBeCalled()
|
expect(onNoteCreatedCallback).not.toBeCalled()
|
||||||
expect(view.container).toMatchSnapshot()
|
expect(view.container).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
@ -93,7 +96,9 @@ describe('create non existing note hint', () => {
|
||||||
await act(() => {
|
await act(() => {
|
||||||
button.click()
|
button.click()
|
||||||
})
|
})
|
||||||
await screen.findByTestId('noteCreated')
|
await waitFor(async () => {
|
||||||
|
expect(await screen.findByTestId('noteCreated')).toBeInTheDocument()
|
||||||
|
})
|
||||||
expect(onNoteCreatedCallback).toBeCalled()
|
expect(onNoteCreatedCallback).toBeCalled()
|
||||||
expect(view.container).toMatchSnapshot()
|
expect(view.container).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
@ -106,7 +111,9 @@ describe('create non existing note hint', () => {
|
||||||
await act(() => {
|
await act(() => {
|
||||||
button.click()
|
button.click()
|
||||||
})
|
})
|
||||||
await screen.findByTestId('failedMessage')
|
await waitFor(async () => {
|
||||||
|
expect(await screen.findByTestId('failedMessage')).toBeInTheDocument()
|
||||||
|
})
|
||||||
expect(onNoteCreatedCallback).not.toBeCalled()
|
expect(onNoteCreatedCallback).not.toBeCalled()
|
||||||
expect(view.container).toMatchSnapshot()
|
expect(view.container).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue