|
1 | 1 | import { expect } from '@vaadin/chai-plugins'; |
| 2 | +import { sendKeys } from '@vaadin/test-runner-commands'; |
2 | 3 | import { enter, fixtureSync, nextRender, nextUpdate, tap } from '@vaadin/testing-helpers'; |
3 | 4 | import sinon from 'sinon'; |
4 | 5 | import '../src/vaadin-login-form.js'; |
@@ -251,6 +252,33 @@ describe('no autofocus', () => { |
251 | 252 | }); |
252 | 253 | }); |
253 | 254 |
|
| 255 | +describe('Enter key default action', () => { |
| 256 | + let login, button, vaadinLoginPassword; |
| 257 | + |
| 258 | + beforeEach(async () => { |
| 259 | + const wrapper = fixtureSync(` |
| 260 | + <div> |
| 261 | + <vaadin-login-form no-autofocus></vaadin-login-form> |
| 262 | + <button></button> |
| 263 | + </div> |
| 264 | + `); |
| 265 | + [login, button] = wrapper.children; |
| 266 | + await nextRender(); |
| 267 | + vaadinLoginPassword = fillUsernameAndPassword(login).vaadinLoginPassword; |
| 268 | + }); |
| 269 | + |
| 270 | + it('should not activate an element focused while handling Enter keydown', async () => { |
| 271 | + const clickSpy = sinon.spy(); |
| 272 | + button.addEventListener('click', clickSpy); |
| 273 | + login.addEventListener('login', () => button.focus()); |
| 274 | + |
| 275 | + vaadinLoginPassword.focus(); |
| 276 | + await sendKeys({ press: 'Enter' }); |
| 277 | + |
| 278 | + expect(clickSpy).to.be.not.called; |
| 279 | + }); |
| 280 | +}); |
| 281 | + |
254 | 282 | describe('error message', () => { |
255 | 283 | let login, formWrapper; |
256 | 284 |
|
|
0 commit comments