From ea5b521882fd45ff14050183196d9e8583d9a94f Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Wed, 30 Oct 2024 09:15:04 +0000 Subject: [PATCH] Remove spell check split tests (#21382) GitOrigin-RevId: 819fc94f55dc1d73e4f58e36dd594a5019c68439 --- .../Features/Editor/EditorHttpController.js | 66 ++------------ .../src/Features/Project/ProjectController.js | 2 - .../cypress/support/shared/commands/index.ts | 3 - .../support/shared/commands/spelling.ts | 3 - .../settings-spell-check-language.tsx | 23 +---- .../extensions/spelling/backend.ts | 26 +----- .../extensions/spelling/spellchecker.ts | 11 --- .../spelling-suggestions-feedback.tsx | 28 ++---- .../spelling/spelling-suggestions.tsx | 7 +- .../source-editor/hooks/use-hunspell.ts | 32 ++++--- .../editor-left-menu.spec.tsx | 2 + .../settings-spell-check-language.test.tsx | 2 + .../review-panel/review-panel.spec.tsx | 1 - .../codemirror-editor-autocomplete.spec.tsx | 1 - .../codemirror-editor-close-brackets.spec.tsx | 1 - .../codemirror-editor-cursor.spec.tsx | 1 - .../codemirror-editor-figure-modal.spec.tsx | 2 +- .../codemirror-editor-fundamentals.spec.tsx | 1 - .../codemirror-editor-shortcuts.spec.tsx | 3 - ...mirror-editor-spellchecker-client.spec.tsx | 8 -- .../codemirror-editor-spellchecker.spec.tsx | 86 ------------------- ...codemirror-editor-table-generator.spec.tsx | 2 +- ...ror-editor-visual-command-tooltip.spec.tsx | 1 - .../codemirror-editor-visual-floats.spec.tsx | 1 - .../codemirror-editor-visual-list.spec.tsx | 1 - ...demirror-editor-visual-paste-html.spec.tsx | 1 - ...codemirror-editor-visual-readonly.spec.tsx | 1 - .../codemirror-editor-visual-toolbar.spec.tsx | 1 - ...codemirror-editor-visual-tooltips.spec.tsx | 1 - .../codemirror-editor-visual.spec.tsx | 1 - .../components/codemirror-editor.spec.tsx | 1 - 31 files changed, 46 insertions(+), 274 deletions(-) delete mode 100644 services/web/cypress/support/shared/commands/spelling.ts delete mode 100644 services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx diff --git a/services/web/app/src/Features/Editor/EditorHttpController.js b/services/web/app/src/Features/Editor/EditorHttpController.js index 65a8323070..45c9b2427a 100644 --- a/services/web/app/src/Features/Editor/EditorHttpController.js +++ b/services/web/app/src/Features/Editor/EditorHttpController.js @@ -14,7 +14,6 @@ const DocstoreManager = require('../Docstore/DocstoreManager') const logger = require('@overleaf/logger') const { expressify } = require('@overleaf/promise-utils') const Settings = require('@overleaf/settings') -const SplitTestHandler = require('../SplitTests/SplitTestHandler') module.exports = { joinProject: expressify(joinProject), @@ -57,33 +56,9 @@ async function joinProject(req, res, next) { await ProjectDeleter.promises.unmarkAsDeletedByExternalSource(projectId) } - let spellCheckClient - try { - const assignment = await SplitTestHandler.promises.getAssignmentForUser( - userId, - 'spell-check-client' - ) - spellCheckClient = assignment?.variant === 'enabled' - } catch { - spellCheckClient = false - } - - let spellCheckNoServer - try { - const assignment = await SplitTestHandler.promises.getAssignmentForUser( - userId, - 'spell-check-no-server' - ) - spellCheckNoServer = assignment?.variant === 'enabled' - } catch { - spellCheckNoServer = false - } - if (project.spellCheckLanguage) { project.spellCheckLanguage = await chooseSpellCheckLanguage( - project.spellCheckLanguage, - spellCheckClient, - spellCheckNoServer + project.spellCheckLanguage ) } @@ -289,43 +264,20 @@ async function deleteEntity(req, res, next) { res.sendStatus(204) } -async function chooseSpellCheckLanguage( - spellCheckLanguage, - spellCheckClient = false, - spellCheckNoServer = false -) { - const supportedSpellCheckLanguages = new Set( - Settings.languages - // optionally only include languages which support client-side spell checking - .filter(language => { - if (!spellCheckClient) { - // only include spell-check languages that are available on the server - return language.server !== false - } - - if (spellCheckNoServer) { - // only include spell-check languages that are available in the client - return language.dic !== undefined - } - - return true - }) - .map(language => language.code) - ) +const supportedSpellCheckLanguages = new Set( + Settings.languages + // only include spell-check languages that are available in the client + .filter(language => language.dic !== undefined) + .map(language => language.code) +) +async function chooseSpellCheckLanguage(spellCheckLanguage) { if (supportedSpellCheckLanguages.has(spellCheckLanguage)) { return spellCheckLanguage } - // Disable spell checking for currently unsupported spell check languages. // Preserve the value in the database so they can use it again once we add back support. - - // existing behaviour: map all unsupported languages to "off" - if (!spellCheckNoServer) { - return '' - } - - // new behaviour: map some server-only languages to a specific variant + // Map some server-only languages to a specific variant, or disable spell checking for currently unsupported spell check languages. switch (spellCheckLanguage) { case 'en': // map "English" to "English (American)" diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index cd7da90629..23f7e09df2 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -348,8 +348,6 @@ const _ProjectController = { 'write-and-cite-ars', 'default-visual-for-beginners', 'hotjar', - 'spell-check-client', - 'spell-check-no-server', ].filter(Boolean) const getUserValues = async userId => diff --git a/services/web/cypress/support/shared/commands/index.ts b/services/web/cypress/support/shared/commands/index.ts index 1a7989c380..cd39f8f5d1 100644 --- a/services/web/cypress/support/shared/commands/index.ts +++ b/services/web/cypress/support/shared/commands/index.ts @@ -5,7 +5,6 @@ import { interceptDeferredCompile, } from './compile' import { interceptEvents } from './events' -import { interceptSpelling } from './spelling' import { interceptAsync } from './intercept-async' import { interceptFileUpload } from './upload' import { interceptProjectListing } from './project-list' @@ -24,7 +23,6 @@ declare global { interceptCompile: typeof interceptCompile interceptEvents: typeof interceptEvents interceptMetadata: typeof interceptMetadata - interceptSpelling: typeof interceptSpelling waitForCompile: typeof waitForCompile interceptDeferredCompile: typeof interceptDeferredCompile interceptFileUpload: typeof interceptFileUpload @@ -40,7 +38,6 @@ Cypress.Commands.add('interceptAsync', interceptAsync) Cypress.Commands.add('interceptCompile', interceptCompile) Cypress.Commands.add('interceptEvents', interceptEvents) Cypress.Commands.add('interceptMetadata', interceptMetadata) -Cypress.Commands.add('interceptSpelling', interceptSpelling) Cypress.Commands.add('waitForCompile', waitForCompile) Cypress.Commands.add('interceptDeferredCompile', interceptDeferredCompile) Cypress.Commands.add('interceptFileUpload', interceptFileUpload) diff --git a/services/web/cypress/support/shared/commands/spelling.ts b/services/web/cypress/support/shared/commands/spelling.ts deleted file mode 100644 index 3a50d1b7f9..0000000000 --- a/services/web/cypress/support/shared/commands/spelling.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const interceptSpelling = () => { - cy.intercept('POST', '/spelling/check', []) -} diff --git a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx index 64430f413c..83e5b40ed5 100644 --- a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx +++ b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx @@ -4,34 +4,19 @@ import getMeta from '../../../../utils/meta' import { useProjectSettingsContext } from '../../context/project-settings-context' import SettingsMenuSelect from './settings-menu-select' import type { Optgroup } from './settings-menu-select' -import { useFeatureFlag } from '@/shared/context/split-test-context' import { useEditorContext } from '@/shared/context/editor-context' export default function SettingsSpellCheckLanguage() { const { t } = useTranslation() - const languages = getMeta('ol-languages') - - const spellCheckClientEnabled = useFeatureFlag('spell-check-client') - const spellCheckNoServer = useFeatureFlag('spell-check-no-server') const { spellCheckLanguage, setSpellCheckLanguage } = useProjectSettingsContext() const { permissionsLevel } = useEditorContext() const optgroup: Optgroup = useMemo(() => { - const options = (languages ?? []).filter(language => { - if (!spellCheckClientEnabled) { - // only include spell-check languages that are available on the server - return language.server !== false - } - - if (spellCheckNoServer) { - // only include spell-check languages that are available in the client - return language.dic !== undefined - } - - return true - }) + const options = (getMeta('ol-languages') ?? []) + // only include spell-check languages that are available in the client + .filter(language => language.dic !== undefined) return { label: 'Language', @@ -40,7 +25,7 @@ export default function SettingsSpellCheckLanguage() { label: language.name, })), } - }, [languages, spellCheckClientEnabled, spellCheckNoServer]) + }, []) return ( { - return `/spelling${path}` -} - export async function learnWordRequest(word?: Word) { if (!word || !word.text) { throw new Error(`Invalid word supplied: ${word}`) } - return await postJSON(apiUrl('/learn'), { + return await postJSON('/spelling/learn', { body: { word: word.text, }, }) } - -export function spellCheckRequest( - language: string, - words: Word[], - controller: AbortController -) { - const signal = controller.signal - const textWords = words.map(w => w.text) - return postJSON<{ - misspellings: { index: number; suggestions: string[] }[] - }>(apiUrl('/check'), { - body: { - language, - words: textWords, - }, - signal, - }) -} diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/spellchecker.ts b/services/web/frontend/js/features/source-editor/extensions/spelling/spellchecker.ts index 8bbeafca84..a88661d8b2 100644 --- a/services/web/frontend/js/features/source-editor/extensions/spelling/spellchecker.ts +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/spellchecker.ts @@ -3,7 +3,6 @@ import { ignoredWordsField, resetSpellChecker } from './ignored-words' import { cacheField, addWordToCache, WordCacheValue } from './cache' import { WORD_REGEX } from './helpers' import OError from '@overleaf/o-error' -import { spellCheckRequest } from './backend' import { EditorView, ViewUpdate } from '@codemirror/view' import { ChangeSet, Line, Range, RangeValue } from '@codemirror/state' import { IgnoredWords } from '../../../dictionary/ignored-words' @@ -158,16 +157,6 @@ export class SpellChecker { } } ) - } else { - spellCheckRequest(this.language, unknownWords, this.abortController) - .then(result => { - this.abortController = null - return processResult(result.misspellings) - }) - .catch(error => { - this.abortController = null - debugConsole.error(error) - }) } } } diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx index ccbacd65ef..c9f6528303 100644 --- a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx @@ -1,7 +1,5 @@ import { FC, memo } from 'react' import { useTranslation } from 'react-i18next' -import { useSplitTest } from '@/shared/context/split-test-context' -import { chooseBadgeClass } from '@/shared/components/beta-badge' import OLTooltip from '@/features/ui/components/ol/ol-tooltip' import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher' import classnames from 'classnames' @@ -9,46 +7,36 @@ import MaterialIcon from '@/shared/components/material-icon' const SpellingSuggestionsFeedback: FC = () => { const { t } = useTranslation() - const { info } = useSplitTest('spell-check-client') - - if (!info) { - return null - } - - const { tooltipText, url } = info.badgeInfo ?? {} - const badgeClass = chooseBadgeClass(info.phase) return ( - We are testing an updated spellchecker. -
- Click to give feedback - - ) + <> + The spell-checker has been updated. +
+ Click to give feedback + } tooltipProps={{ className: 'split-test-badge-tooltip' }} overlayProps={{ placement: 'bottom', delay: 100 }} > } bs5={ } /> diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx index 7567775168..596bafa205 100644 --- a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx @@ -10,7 +10,6 @@ import { SpellChecker, Word } from './spellchecker' import { useTranslation } from 'react-i18next' import getMeta from '@/utils/meta' import classnames from 'classnames' -import { useFeatureFlag } from '@/shared/context/split-test-context' import { sendMB } from '@/infrastructure/event-tracking' import SpellingSuggestionsFeedback from './spelling-suggestions-feedback' import { SpellingSuggestionsLanguage } from './spelling-suggestions-language' @@ -76,14 +75,12 @@ export const SpellingSuggestions: FC<{ const language = useMemo(() => { if (spellCheckLanguage) { - return getMeta('ol-languages').find( + return (getMeta('ol-languages') ?? []).find( item => item.code === spellCheckLanguage ) } }, [spellCheckLanguage]) - const spellCheckClientEnabled = useFeatureFlag('spell-check-client') - if (!language) { return null } @@ -146,7 +143,7 @@ export const SpellingSuggestions: FC<{ /> - {spellCheckClientEnabled && language.dic && ( + {getMeta('ol-isSaas') && ( <>
  • diff --git a/services/web/frontend/js/features/source-editor/hooks/use-hunspell.ts b/services/web/frontend/js/features/source-editor/hooks/use-hunspell.ts index 5a10b1dfcb..027f3291d5 100644 --- a/services/web/frontend/js/features/source-editor/hooks/use-hunspell.ts +++ b/services/web/frontend/js/features/source-editor/hooks/use-hunspell.ts @@ -1,4 +1,3 @@ -import { isSplitTestEnabled } from '@/utils/splitTestUtils' import { useEffect, useState } from 'react' import getMeta from '@/utils/meta' import { globalLearnedWords } from '@/features/dictionary/ignored-words' @@ -9,24 +8,23 @@ export const useHunspell = (spellCheckLanguage: string | null) => { const [hunspellManager, setHunspellManager] = useState() useEffect(() => { - if (isSplitTestEnabled('spell-check-client')) { - if (spellCheckLanguage) { - const languages = getMeta('ol-languages') - const lang = languages.find(item => item.code === spellCheckLanguage) - if (lang?.dic) { - const hunspellManager = new HunspellManager(lang.dic, [ - ...globalLearnedWords, - ...getMeta('ol-learnedWords'), - ]) - setHunspellManager(hunspellManager) - debugConsole.log(spellCheckLanguage, hunspellManager) + if (spellCheckLanguage) { + const lang = (getMeta('ol-languages') ?? []).find( + item => item.code === spellCheckLanguage + ) + if (lang?.dic) { + const hunspellManager = new HunspellManager(lang.dic, [ + ...globalLearnedWords, + ...getMeta('ol-learnedWords'), + ]) + setHunspellManager(hunspellManager) + debugConsole.log(spellCheckLanguage, hunspellManager) - return () => { - hunspellManager.destroy() - } - } else { - setHunspellManager(undefined) + return () => { + hunspellManager.destroy() } + } else { + setHunspellManager(undefined) } } }, [spellCheckLanguage]) diff --git a/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx b/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx index c361a93ce5..56eedfc462 100644 --- a/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx +++ b/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx @@ -441,10 +441,12 @@ describe('', function () { { name: 'Lang 1', code: 'lang-1', + dic: 'lang_1', }, { name: 'Lang 2', code: 'lang-2', + dic: 'lang_2', }, ] diff --git a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-spell-check-language.test.tsx b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-spell-check-language.test.tsx index 222d5ca43a..1deb408db5 100644 --- a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-spell-check-language.test.tsx +++ b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-spell-check-language.test.tsx @@ -10,10 +10,12 @@ describe('', function () { { name: 'Lang 1', code: 'lang-1', + dic: 'lang_1', }, { name: 'Lang 2', code: 'lang-2', + dic: 'lang_2', }, ] diff --git a/services/web/test/frontend/features/review-panel/review-panel.spec.tsx b/services/web/test/frontend/features/review-panel/review-panel.spec.tsx index ccd6f3aa1a..d36bdced05 100644 --- a/services/web/test/frontend/features/review-panel/review-panel.spec.tsx +++ b/services/web/test/frontend/features/review-panel/review-panel.spec.tsx @@ -9,7 +9,6 @@ describe('', function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() const scope = mockScope('') scope.editor.showVisual = true diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx index eb0f2bc7a4..a6ddf0866e 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx @@ -16,7 +16,6 @@ describe('autocomplete', { scrollBehavior: false }, function () { window.metaAttributesCache.set('ol-showSymbolPalette', true) cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() }) it('opens autocomplete on matched text', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx index 7b8f4482c5..25487d7b19 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx @@ -8,7 +8,6 @@ describe('close brackets', { scrollBehavior: false }, function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() const scope = mockScope() diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx index 67c59db308..839a96de86 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx @@ -21,7 +21,6 @@ ${'long line '.repeat(200)}` beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() const scope = mockScope(content) diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx index 12827414a3..35a2eccfaa 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx @@ -74,7 +74,7 @@ describe('', function () { cy.interceptMathJax() cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() + mount() }) diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx index 08413216a2..37389e11a4 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx @@ -11,7 +11,6 @@ test beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() const scope = mockScope(content) diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx index aae9b594c3..3ff720ebe7 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx @@ -14,7 +14,6 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() const scope = mockScope() @@ -127,7 +126,6 @@ describe('emacs keybindings', { scrollBehavior: false }, function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() const shortDoc = ` \\documentclass{article} @@ -229,7 +227,6 @@ describe('vim keybindings', { scrollBehavior: false }, function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() // Make a short doc that will fit entirely into the dom tree, so that // index() corresponds to line number - 1 diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker-client.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker-client.spec.tsx index a9f5514317..f6cb4e78fa 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker-client.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker-client.spec.tsx @@ -114,14 +114,6 @@ forEach(Object.keys(suggestions)).describe( beforeEach(function () { cy.window().then(win => { win.metaAttributesCache.set('ol-preventCompileOnLoad', true) - win.metaAttributesCache.set('ol-splitTestVariants', { - 'spell-check-client': 'enabled', - 'spell-check-no-server': 'enabled', - }) - win.metaAttributesCache.set('ol-splitTestInfo', { - 'spell-check-client': { phase: 'release' }, - 'spell-check-no-server': { phase: 'release' }, - }) win.metaAttributesCache.set('ol-learnedWords', ['baz']) win.metaAttributesCache.set( 'ol-dictionariesRoot', diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx deleted file mode 100644 index effca6af26..0000000000 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import '../../../helpers/bootstrap-3' -import { mockScope } from '../helpers/mock-scope' -import { EditorProviders } from '../../../helpers/editor-providers' -import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' -import { TestContainer } from '../helpers/test-container' - -describe('Spellchecker', function () { - const content = ` -\\documentclass{} - -\\title{} -\\author{} - -\\begin{document} -\\maketitle - -\\begin{abstract} -\\end{abstract} - -\\section{} - -\\end{document}` - - beforeEach(function () { - window.metaAttributesCache.set('ol-preventCompileOnLoad', true) - cy.interceptEvents() - - const scope = mockScope(content) - - cy.mount( - - - - - - ) - - cy.get('.cm-line').eq(13).as('line') - cy.get('@line').click() - }) - - it('makes initial spellcheck request', function () { - cy.intercept('POST', '/spelling/check').as('spellCheckRequest') - cy.get('@line').type('wombat') - cy.wait('@spellCheckRequest') - }) - - it('makes only one spellcheck request for multiple typed characters', function () { - let spellCheckRequestCount = 0 - cy.intercept('POST', '/spelling/check', req => { - ++spellCheckRequestCount - if (spellCheckRequestCount > 1) { - throw new Error('No more than one request was expected') - } - req.reply({ - misspellings: [], - }) - }).as('spellCheckRequest') - - cy.get('@line').type('wombat') - cy.wait('@spellCheckRequest') - }) - - it('shows red underline for misspelled word', function () { - cy.intercept('POST', '/spelling/check', { - misspellings: [ - { - index: 0, - suggestions: [ - 'noncombat', - 'wombat', - 'nutmeat', - 'nitwit', - 'steamboat', - 'entombed', - 'tombed', - ], - }, - ], - }).as('spellCheckRequest') - - cy.get('@line').type('notawombat') - cy.wait('@spellCheckRequest') - cy.get('@line').get('.ol-cm-spelling-error').contains('notawombat') - }) -}) diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx index 2740c32187..f20c7948a7 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx @@ -107,7 +107,7 @@ function checkBordersWithNoMultiColumn( describe(' Table editor', function () { beforeEach(function () { cy.interceptEvents() - cy.interceptSpelling() + cy.interceptMathJax() cy.interceptCompile('compile', Number.MAX_SAFE_INTEGER) window.metaAttributesCache.set('ol-preventCompileOnLoad', true) diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx index 7d2ac0ddff..a8655cd005 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx @@ -25,7 +25,6 @@ describe(' command tooltip in Visual mode', function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() }) it('shows a tooltip for \\href', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx index a93b8568de..6911c8f46e 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx @@ -24,7 +24,6 @@ describe(' floats', function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() }) it('decorates a caption', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx index f066a936ed..2f75fb35af 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx @@ -26,7 +26,6 @@ describe(' lists in Rich Text mode', function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() }) it('creates a nested list inside an unindented list', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx index c268686fff..3ccf6ed0a7 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx @@ -25,7 +25,6 @@ describe(' paste HTML in Visual mode', function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() }) it('handles paste', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx index 89165870e1..b571e594e9 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx @@ -62,7 +62,6 @@ describe(' in Visual mode with read-only permission', functio cy.interceptMathJax() cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() }) it('decorates footnote content', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx index 9191187f7f..631b4a6c50 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx @@ -39,7 +39,6 @@ describe(' toolbar in Rich Text mode', function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() }) it('should handle Undo and Redo', function () { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx index b7c27525db..c53f33b7a8 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx @@ -10,7 +10,6 @@ describe(' tooltips in Visual mode', function () { cy.interceptMathJax() cy.interceptMetadata() cy.interceptEvents() - cy.interceptSpelling() const scope = mockScope('\n\n\n') scope.editor.showVisual = true diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx index 274494d84c..bd22b23863 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx @@ -14,7 +14,6 @@ describe(' in Visual mode', function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() cy.interceptMetadata() - cy.interceptSpelling() cy.interceptMathJax() // 3 blank lines diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx index 988ad2a8b0..a753734c8c 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx @@ -12,7 +12,6 @@ describe('', { scrollBehavior: false }, function () { beforeEach(function () { window.metaAttributesCache.set('ol-preventCompileOnLoad', true) cy.interceptEvents() - cy.interceptSpelling() }) it('deletes selected text on Backspace', function () {