Skip to content

Commit

Permalink
fix(kmodal): update test [KHCP-15048]
Browse files Browse the repository at this point in the history
  • Loading branch information
arashsheyda committed Feb 10, 2025
1 parent a682db0 commit 044b9b3
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/components/KModal/KModal.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,27 @@ describe('KModal', () => {
},
})

cy.get('[data-testid="modal-text"]')
.trigger('mousedown')
.trigger('mousemove', { clientX: 100, clientY: 100 })
.trigger('mouseup')
// select text
cy.get('[data-testid="modal-text"]').then(($el) => {
const doc = $el[0].ownerDocument
const range = doc.createRange()
range.selectNodeContents($el[0])
const selection = doc.getSelection()
selection?.removeAllRanges()
selection?.addRange(range)
})


cy.get('.k-modal .modal-backdrop').click('topRight')
// check if text is selected
cy.document().then((doc) => {
const selectedText = doc.getSelection()?.toString()
expect(selectedText).to.equal('Select this text to test')
})


cy.wrap(Cypress.vueWrapper.emitted()).should('not.have.property', 'cancel')
cy.get('.k-modal .modal-backdrop').click('topRight').then(() => {
cy.wrap(Cypress.vueWrapper.emitted()).should('not.have.property', 'cancel')
})
})

it('sets focus on first input field when inputAutofocus is true', () => {
Expand Down

0 comments on commit 044b9b3

Please sign in to comment.