test: file input triggers input event only once (#20306)

#20079
This commit is contained in:
Yury Semikhatsky 2023-01-23 17:56:02 -08:00 committed by GitHub
parent 147bb6b292
commit 7fcec1a06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -548,3 +548,26 @@ it('should trigger listener added before navigation', async ({ page, server, bro
expect(chooser).toBeTruthy();
});
it('input should trigger events when files changed second time', async ({ page, asset, browserName }) => {
it.fixme(browserName === 'webkit');
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20079' });
await page.setContent(`<input type=file multiple=true/>`);
const input = page.locator('input');
const events = await input.evaluateHandle(e => {
const events = [];
e.addEventListener('input', () => events.push('input'));
e.addEventListener('change', () => events.push('change'));
return events;
});
await input.setInputFiles(asset('file-to-upload.txt'));
expect(await input.evaluate(e => (e as HTMLInputElement).files[0].name)).toBe('file-to-upload.txt');
expect(await events.evaluate(e => e)).toEqual(['input', 'change']);
await events.evaluate(e => e.length = 0);
await input.setInputFiles(asset('pptr.png'));
expect(await input.evaluate(e => (e as HTMLInputElement).files[0].name)).toBe('pptr.png');
expect(await events.evaluate(e => e)).toEqual(['input', 'change']);
});