mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Add eslint-plugin-testing-library (#23017)
* Add eslint-plugin-testing-library * Update .eslintrc.js * Only import from @testing-library/react * Fix issues GitOrigin-RevId: c225f1f70020d4431866119423cd839ce1ee5ed2
This commit is contained in:
+1
-2
@@ -1,10 +1,9 @@
|
||||
import { fireEvent, screen } from '@testing-library/dom'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import sinon from 'sinon'
|
||||
import { expect } from 'chai'
|
||||
import ActionsCopyProject from '../../../../../frontend/js/features/editor-left-menu/components/actions-copy-project'
|
||||
import { renderWithEditorContext } from '../../../helpers/render-with-context'
|
||||
import { waitFor } from '@testing-library/react'
|
||||
import * as useLocationModule from '../../../../../frontend/js/shared/hooks/use-location'
|
||||
|
||||
describe('<ActionsCopyProject />', function () {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { screen, waitFor } from '@testing-library/dom'
|
||||
import { screen, waitFor } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import ActionsMenu from '../../../../../frontend/js/features/editor-left-menu/components/actions-menu'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { screen, waitFor } from '@testing-library/dom'
|
||||
import { screen, waitFor } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import ActionsWordCount from '../../../../../frontend/js/features/editor-left-menu/components/actions-word-count'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { screen, waitFor } from '@testing-library/dom'
|
||||
import { screen, waitFor } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import DownloadMenu from '../../../../../frontend/js/features/editor-left-menu/components/download-menu'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { screen } from '@testing-library/dom'
|
||||
import { screen } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import HelpMenu from '../../../../../frontend/js/features/editor-left-menu/components/help-menu'
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsAutoCloseBrackets from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-auto-close-brackets'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsAutoCloseBrackets />', function () {
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsAutoComplete from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-auto-complete'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsAutoComplete />', function () {
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsCompiler from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-compiler'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsCompiler />', function () {
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { fireEvent, screen, within } from '@testing-library/dom'
|
||||
import { fireEvent, screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import SettingsDictionary from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-dictionary'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsDictionary />', function () {
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsDocument from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-document'
|
||||
import { Folder } from '../../../../../../types/folder'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsDocument />', function () {
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsEditorTheme from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-editor-theme'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsEditorTheme />', function () {
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsFontFamily from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-font-family'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsFontFamily />', function () {
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsFontSize from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-font-size'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsFontSize />', function () {
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsImageName from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-image-name'
|
||||
import type { AllowedImageName } from '../../../../../../types/project-settings'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
|
||||
describe('<SettingsImageName />', function () {
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsKeybindings from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-keybindings'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsLineHeight from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-line-height'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsMathPreview from '@/features/editor-left-menu/components/settings/settings-math-preview'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsOverallTheme from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-overall-theme'
|
||||
import type { OverallThemeMeta } from '../../../../../../types/project-settings'
|
||||
import getMeta from '@/utils/meta'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsPdfViewer from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-pdf-viewer'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsSpellCheckLanguage from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language'
|
||||
import type { SpellCheckLanguage } from '../../../../../../types/project-settings'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { screen, within } from '@testing-library/dom'
|
||||
import { screen, within, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import SettingsSyntaxValidation from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-syntax-validation'
|
||||
import { render } from '@testing-library/react'
|
||||
import { EditorProviders } from '../../../../helpers/editor-providers'
|
||||
import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/dom'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import LoadMore from '../../../../../frontend/js/features/project-list/components/load-more'
|
||||
|
||||
@@ -137,8 +137,6 @@ describe('<UserNotifications />', function () {
|
||||
|
||||
expect(joinBtn.disabled).to.be.true
|
||||
|
||||
screen.debug()
|
||||
|
||||
await waitForElementToBeRemoved(() => screen.getByText('Loading'))
|
||||
|
||||
expect(acceptMock.called()).to.be.true
|
||||
|
||||
+1
-1
@@ -1138,7 +1138,7 @@ describe('<ProjectListRoot />', function () {
|
||||
|
||||
const yourProjectFilter = screen.getAllByText('Your Projects')[0]
|
||||
fireEvent.click(yourProjectFilter)
|
||||
screen.findByText(copiedProjectName)
|
||||
await screen.findByText(copiedProjectName)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
+3
-3
@@ -92,7 +92,7 @@ describe('email actions - make primary', function () {
|
||||
name: /make primary/i,
|
||||
})) as HTMLButtonElement
|
||||
|
||||
userEvent.hover(button.parentElement!)
|
||||
await userEvent.hover(button.parentElement!)
|
||||
|
||||
await screen.findByText(
|
||||
/Please confirm your affiliation before making this the primary/i
|
||||
@@ -109,7 +109,7 @@ describe('email actions - make primary', function () {
|
||||
name: /make primary/i,
|
||||
})) as HTMLButtonElement
|
||||
|
||||
userEvent.hover(button.parentElement!)
|
||||
await userEvent.hover(button.parentElement!)
|
||||
|
||||
await screen.findByText('Make this the primary email, used to log in', {
|
||||
exact: false,
|
||||
@@ -150,7 +150,7 @@ describe('email actions - make primary', function () {
|
||||
name: /make primary/i,
|
||||
})) as HTMLButtonElement[]
|
||||
|
||||
userEvent.hover(buttons[1].parentElement!)
|
||||
await userEvent.hover(buttons[1].parentElement!)
|
||||
|
||||
await screen.findByText(
|
||||
'Please confirm your email by linking to your institutional account before making it the primary email',
|
||||
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { screen, fireEvent, render, waitFor } from '@testing-library/react'
|
||||
import { screen, fireEvent, render } from '@testing-library/react'
|
||||
import { IntegrationLinkingWidget } from '../../../../../../frontend/js/features/settings/components/linking/integration-widget'
|
||||
import * as eventTracking from '@/infrastructure/event-tracking'
|
||||
|
||||
@@ -104,9 +104,7 @@ describe('<IntegrationLinkingWidgetTest/>', function () {
|
||||
hidden: false,
|
||||
})
|
||||
fireEvent.click(cancelBtn)
|
||||
await waitFor(() =>
|
||||
screen.getByRole('button', { name: 'Cancel', hidden: true })
|
||||
)
|
||||
await screen.findByRole('button', { name: 'Cancel', hidden: true })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -61,9 +61,7 @@ describe('<SSOLinkingWidget />', function () {
|
||||
hidden: false,
|
||||
})
|
||||
fireEvent.click(cancelBtn)
|
||||
await waitFor(() =>
|
||||
screen.getByRole('button', { name: 'Cancel', hidden: true })
|
||||
)
|
||||
await screen.findByRole('button', { name: 'Cancel', hidden: true })
|
||||
expect(unlinkFunction).not.to.have.been.called
|
||||
})
|
||||
})
|
||||
@@ -119,13 +117,11 @@ describe('<SSOLinkingWidget />', function () {
|
||||
})
|
||||
|
||||
it('should display an error message ', async function () {
|
||||
await waitFor(() =>
|
||||
screen.getByText('Something went wrong. Please try again.')
|
||||
)
|
||||
await screen.findByText('Something went wrong. Please try again.')
|
||||
})
|
||||
|
||||
it('should display the unlink button ', async function () {
|
||||
await waitFor(() => screen.getByRole('button', { name: 'Unlink' }))
|
||||
await screen.findByRole('button', { name: 'Unlink' })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user