Improve spell check when dictionary is edited (#22635)

GitOrigin-RevId: 20d36cb987d014809423240a46c7c577781dfde6
This commit is contained in:
Alf Eaton
2025-01-14 09:05:03 +00:00
committed by Copybot
parent 47af13c8a8
commit cffa9c1a28
16 changed files with 218 additions and 375 deletions
@@ -1,21 +1,26 @@
import DictionaryModal from '@/features/dictionary/components/dictionary-modal'
import { EditorProviders } from '../../../helpers/editor-providers'
import { learnedWords } from '@/features/source-editor/extensions/spelling/learned-words'
describe('<DictionaryModalContent />', function () {
let originalLearnedWords
beforeEach(function () {
cy.then(() => {
originalLearnedWords = learnedWords.global
})
cy.interceptCompile()
})
afterEach(function () {
cy.window().then(win => {
win.dispatchEvent(new CustomEvent('learnedWords:doreset'))
cy.then(() => {
learnedWords.global = originalLearnedWords
})
})
it('list words', function () {
cy.window().then(win => {
win.metaAttributesCache.set('ol-learnedWords', ['foo', 'bar'])
win.dispatchEvent(new CustomEvent('learnedWords:doreset'))
cy.then(win => {
learnedWords.global = new Set(['foo', 'bar'])
})
cy.mount(
@@ -29,9 +34,8 @@ describe('<DictionaryModalContent />', function () {
})
it('shows message when empty', function () {
cy.window().then(win => {
win.metaAttributesCache.set('ol-learnedWords', [])
win.dispatchEvent(new CustomEvent('learnedWords:doreset'))
cy.then(win => {
learnedWords.global = new Set([])
})
cy.mount(
@@ -46,9 +50,8 @@ describe('<DictionaryModalContent />', function () {
it('removes words', function () {
cy.intercept('/spelling/unlearn', { statusCode: 200 })
cy.window().then(win => {
win.metaAttributesCache.set('ol-learnedWords', ['Foo', 'bar'])
win.dispatchEvent(new CustomEvent('learnedWords:doreset'))
cy.then(win => {
learnedWords.global = new Set(['Foo', 'bar'])
})
cy.mount(
@@ -73,9 +76,8 @@ describe('<DictionaryModalContent />', function () {
it('handles errors', function () {
cy.intercept('/spelling/unlearn', { statusCode: 500 }).as('unlearn')
cy.window().then(win => {
win.metaAttributesCache.set('ol-learnedWords', ['foo'])
win.dispatchEvent(new CustomEvent('learnedWords:doreset'))
cy.then(win => {
learnedWords.global = new Set(['foo'])
})
cy.mount(