mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(snapshot): broken snapshot after use of setInputFiles (#28444)
This commit is contained in:
parent
d296d057d3
commit
f44ef81af7
@ -223,7 +223,9 @@ function snapshotScript(...targetIds: (string | undefined)[]) {
|
|||||||
scrollLefts.push(e);
|
scrollLefts.push(e);
|
||||||
|
|
||||||
for (const element of root.querySelectorAll(`[__playwright_value_]`)) {
|
for (const element of root.querySelectorAll(`[__playwright_value_]`)) {
|
||||||
(element as HTMLInputElement | HTMLTextAreaElement).value = element.getAttribute('__playwright_value_')!;
|
const inputElement = element as HTMLInputElement | HTMLTextAreaElement;
|
||||||
|
if (inputElement.type !== 'file')
|
||||||
|
inputElement.value = inputElement.getAttribute('__playwright_value_')!;
|
||||||
element.removeAttribute('__playwright_value_');
|
element.removeAttribute('__playwright_value_');
|
||||||
}
|
}
|
||||||
for (const element of root.querySelectorAll(`[__playwright_checked_]`)) {
|
for (const element of root.querySelectorAll(`[__playwright_checked_]`)) {
|
||||||
|
|||||||
@ -438,12 +438,13 @@ test('should restore scroll positions', async ({ page, runAndTrace, browserName
|
|||||||
expect(await frame.locator('div').evaluate(div => div.scrollTop)).toBe(136);
|
expect(await frame.locator('div').evaluate(div => div.scrollTop)).toBe(136);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should restore control values', async ({ page, runAndTrace }) => {
|
test('should restore control values', async ({ page, runAndTrace, asset }) => {
|
||||||
const traceViewer = await runAndTrace(async () => {
|
const traceViewer = await runAndTrace(async () => {
|
||||||
await page.setContent(`
|
await page.setContent(`
|
||||||
<input type=text value=old>
|
<input type=text value=old>
|
||||||
<input type=checkbox checked>
|
<input type=checkbox checked>
|
||||||
<input type=radio>
|
<input type=radio>
|
||||||
|
<input type=file>
|
||||||
<textarea>old</textarea>
|
<textarea>old</textarea>
|
||||||
<select multiple>
|
<select multiple>
|
||||||
<option value=opt1>Hi</option>
|
<option value=opt1>Hi</option>
|
||||||
@ -460,6 +461,7 @@ test('should restore control values', async ({ page, runAndTrace }) => {
|
|||||||
document.querySelector('[value=opt3]').selected = true;
|
document.querySelector('[value=opt3]').selected = true;
|
||||||
</script>
|
</script>
|
||||||
`);
|
`);
|
||||||
|
await page.locator('input[type="file"]').setInputFiles(asset('file-to-upload.txt'));
|
||||||
await page.click('input');
|
await page.click('input');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -486,6 +488,8 @@ test('should restore control values', async ({ page, runAndTrace }) => {
|
|||||||
expect(await frame.locator('option >> nth=1').evaluate(o => o.hasAttribute('selected'))).toBe(true);
|
expect(await frame.locator('option >> nth=1').evaluate(o => o.hasAttribute('selected'))).toBe(true);
|
||||||
expect(await frame.locator('option >> nth=2').evaluate(o => o.hasAttribute('selected'))).toBe(false);
|
expect(await frame.locator('option >> nth=2').evaluate(o => o.hasAttribute('selected'))).toBe(false);
|
||||||
await expect(frame.locator('select')).toHaveValues(['opt1', 'opt3']);
|
await expect(frame.locator('select')).toHaveValues(['opt1', 'opt3']);
|
||||||
|
|
||||||
|
await expect(frame.locator('input[type=file]')).toHaveValue('');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with meta CSP', async ({ page, runAndTrace, browserName }) => {
|
test('should work with meta CSP', async ({ page, runAndTrace, browserName }) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user