feat: support beforeinput event.#8411
Conversation
|
Thanks for taking the time to open a PR!
|
packages/driver/src/cy/keyboard.ts
Outdated
| let eventConstructor = 'KeyboardEvent' | ||
| let cancelable = true | ||
| let addModifiers = true | ||
| let inputType = '' |
There was a problem hiding this comment.
I think this will add the inputType to every event since it's not initialized as undefined. Since we don't test for extra properties we should add a test for that.
I'll take a look
There was a problem hiding this comment.
You're right. It should be written in that way.
| .type(testString, { noUpdate: true }) | ||
|
|
||
| cy.contains('[data-slate-string="true"]', testString) | ||
| .should('be.visible') | ||
|
|
||
| cy.get('[data-slate-editor="true"]') | ||
| .type('{ctrl}{shift}{backspace}', { release: false, noUpdate: true }) |
There was a problem hiding this comment.
I tried removing the noUpdate options here and the test still passed, is there a test case that fails w/o the option?
There was a problem hiding this comment.
You're right. noUpdate isn't necessary.
I added it because there were some cases when cy.type() breaks the html structure inside slatejs. It seems that it was because beforeinput part was buggy.
There was a problem hiding this comment.
the reason you previously needed noUpdate was due to the event not being set as cancelable https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event, fixed now so we will respect a cancelled event and not perform the default action
5c228b6 to
a0b70ab
Compare
…einput cancelable
|
made changes, I added tests in type_spec for beforeinput and verified it passes the slate spec before removing it, since the event tests cover it. |
sainthkh
left a comment
There was a problem hiding this comment.
LGTM. I only did some minor changes.
- Fixed the test failures.
- Removed console.log comments.
|
beforeInputevent / does not work with slate.js #7088User facing changelog
beforeinputevent to solve slate.js issue.Additional details
Why was this change necessary?
Cypress cannot be used to test some applications that use
beforeinputevents like slate.jsWhat is affected by this change?
N/A
Any implementation details to explain?
inputTypeto decide what to do. So, I had to decide it based on the key combo and the spec.noUpdateoption had to be introduced tocy.type(). Because slatejs handles its own state and the text updated by Cypress causes errors.How has the user experience changed?
You can test slatejs with Cypress.
PR Tasks
cypress-documentation? => coming soon after the approvaltype definitions?cypress.schema.json?