From af5e06fbfdb0068e077e58e796802948f59daa59 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Tue, 20 Sep 2022 15:58:26 -0400 Subject: [PATCH] test: repro for spaces in filename for input (#17452) --- tests/assets/file to upload.txt | 1 + tests/page/page-set-input-files.spec.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/assets/file to upload.txt diff --git a/tests/assets/file to upload.txt b/tests/assets/file to upload.txt new file mode 100644 index 0000000000..b4ad118489 --- /dev/null +++ b/tests/assets/file to upload.txt @@ -0,0 +1 @@ +contents of the file \ No newline at end of file diff --git a/tests/page/page-set-input-files.spec.ts b/tests/page/page-set-input-files.spec.ts index d987bae577..14ea76fff4 100644 --- a/tests/page/page-set-input-files.spec.ts +++ b/tests/page/page-set-input-files.spec.ts @@ -135,6 +135,22 @@ it('should upload large file with relative path', async ({ page, server, browser await Promise.all([uploadFile, file1.filepath].map(fs.promises.unlink)); }); +it('should upload the file with spaces in name', async ({ page, server, asset }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/17451' }); + await page.goto(server.PREFIX + '/input/fileupload.html'); + const filePath = path.relative(process.cwd(), asset('file to upload.txt')); + const input = await page.$('input'); + await input.setInputFiles(filePath); + expect(await page.evaluate(e => e.files[0].name, input)).toBe('file to upload.txt'); + expect(await page.evaluate(e => { + const reader = new FileReader(); + const promise = new Promise(fulfill => reader.onload = fulfill); + reader.readAsText(e.files[0]); + return promise.then(() => reader.result); + }, input)).toBe('contents of the file'); +}); + + it('should work @smoke', async ({ page, asset }) => { await page.setContent(``); await page.setInputFiles('input', asset('file-to-upload.txt'));