Skip to content
Prev Previous commit
fix(test): make sure to only get search decorations
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Aug 13, 2024
commit 944fdb4d6917ff1e8f95ef88fadb57ac06e47f6a
14 changes: 7 additions & 7 deletions cypress/component/editor/search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('editor search highlighting', () => {
const searchQuery = 'Lorem ipsum dolor sit amet'
editor.commands.setSearchQuery(searchQuery)

const highlightedElements = document.querySelectorAll('span[data-text-el]')
const highlightedElements = document.querySelectorAll('span[data-text-el="search-decoration"]')
expect(highlightedElements).to.have.lengthOf(1)
verifyHighlights(highlightedElements, searchQuery)
})
Expand All @@ -36,7 +36,7 @@ describe('editor search highlighting', () => {
const searchQuery = 'quod'
editor.commands.setSearchQuery(searchQuery)

const highlightedElements = document.querySelectorAll('span[data-text-el]')
const highlightedElements = document.querySelectorAll('span[data-text-el="search-decoration"]')
expect(highlightedElements).to.have.lengthOf(3)
verifyHighlights(highlightedElements, searchQuery)
})
Expand All @@ -47,7 +47,7 @@ describe('editor search highlighting', () => {

// Highlight only first occurrence
editor.commands.setSearchQuery(searchQuery, false)
highlightedElements = document.querySelectorAll('span[data-text-el]')
highlightedElements = document.querySelectorAll('span[data-text-el="search-decoration"]')

expect(highlightedElements).to.have.lengthOf(1)
verifyHighlights(highlightedElements, searchQuery)
Expand All @@ -57,10 +57,10 @@ describe('editor search highlighting', () => {
const searchQuery = 'quod'

editor.commands.setSearchQuery(searchQuery, true)
const allHighlightedElements = document.querySelectorAll('span[data-text-el]')
const allHighlightedElements = document.querySelectorAll('span[data-text-el="search-decoration"]')

editor.commands.nextMatch()
const currentlyHighlightedElement = document.querySelectorAll('span[data-text-el]')
const currentlyHighlightedElement = document.querySelectorAll('span[data-text-el="search-decoration"]')

expect(currentlyHighlightedElement).to.have.lengthOf(1)
expect(allHighlightedElements[1]).to.deep.equal(currentlyHighlightedElement[0])
Expand All @@ -70,10 +70,10 @@ describe('editor search highlighting', () => {
const searchQuery = 'quod'

editor.commands.setSearchQuery(searchQuery, true)
const allHighlightedElements = document.querySelectorAll('span[data-text-el]')
const allHighlightedElements = document.querySelectorAll('span[data-text-el="search-decoration"]')

editor.commands.previousMatch()
const currentlyHighlightedElement = document.querySelectorAll('span[data-text-el]')
const currentlyHighlightedElement = document.querySelectorAll('span[data-text-el="search-decoration"]')

expect(currentlyHighlightedElement).to.have.lengthOf(1)
expect(allHighlightedElements[0]).to.deep.equal(currentlyHighlightedElement[0])
Expand Down