From 3921daccf9e7ec9579a86d32664bb9bb69f3e3e1 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 18 Dec 2024 11:00:37 +0100 Subject: [PATCH 1/2] test: do not create stray files when running tests --- .../microsoft/playwright/TestPageSetInputFiles.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java b/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java index a96de9ab8..6efe92792 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java @@ -471,10 +471,10 @@ void shouldUploadAFolder(@TempDir Path tmpDir) throws IOException { } @Test - void shouldUploadAFolderAndThrowForMultipleDirectories() throws IOException { + void shouldUploadAFolderAndThrowForMultipleDirectories(@TempDir Path tmpDir) throws IOException { page.navigate(server.PREFIX + "/input/folderupload.html"); Locator input = page.locator("input[name=\"file1\"]"); - Path dir = Paths.get("file-upload-test"); // Adjust path as necessary + Path dir = tmpDir.resolve("file-upload-test"); // Adjust path as necessary Files.createDirectories(dir.resolve("folder1")); writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content"); Files.createDirectories(dir.resolve("folder2")); @@ -485,11 +485,11 @@ void shouldUploadAFolderAndThrowForMultipleDirectories() throws IOException { } @Test - void shouldThrowIfADirectoryAndFilesArePassed() throws IOException { + void shouldThrowIfADirectoryAndFilesArePassed(@TempDir Path tmpDir) throws IOException { // Skipping conditions based on environment not directly translatable to Java; needs custom implementation page.navigate(server.PREFIX + "/input/folderupload.html"); Locator input = page.locator("input[name=\"file1\"]"); - Path dir = Paths.get("file-upload-test"); // Adjust path as necessary + Path dir = tmpDir.resolve("file-upload-test"); Files.createDirectories(dir.resolve("folder1")); writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content"); PlaywrightException e = assertThrows(PlaywrightException.class, @@ -498,10 +498,10 @@ void shouldThrowIfADirectoryAndFilesArePassed() throws IOException { } @Test - void shouldThrowWhenUploadingAFolderInANormalFileUploadInput() throws IOException { + void shouldThrowWhenUploadingAFolderInANormalFileUploadInput(@TempDir Path tmpDir) throws IOException { page.navigate(server.PREFIX + "/input/fileupload.html"); Locator input = page.locator("input[name=\"file1\"]"); - Path dir = Paths.get("file-upload-test"); // Adjust path as necessary + Path dir = tmpDir.resolve("file-upload-test"); Files.createDirectories(dir); writeFile(dir.resolve("file1.txt"), "file1 content"); PlaywrightException e = assertThrows(PlaywrightException.class, From 33a8715193c14321e0ca7fefc5eea89a033e045c Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 18 Dec 2024 11:10:32 +0100 Subject: [PATCH 2/2] Update playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java --- .../java/com/microsoft/playwright/TestPageSetInputFiles.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java b/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java index 6efe92792..ef2b6b710 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java @@ -474,7 +474,7 @@ void shouldUploadAFolder(@TempDir Path tmpDir) throws IOException { void shouldUploadAFolderAndThrowForMultipleDirectories(@TempDir Path tmpDir) throws IOException { page.navigate(server.PREFIX + "/input/folderupload.html"); Locator input = page.locator("input[name=\"file1\"]"); - Path dir = tmpDir.resolve("file-upload-test"); // Adjust path as necessary + Path dir = tmpDir.resolve("file-upload-test"); Files.createDirectories(dir.resolve("folder1")); writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content"); Files.createDirectories(dir.resolve("folder2"));