@testdriverai/agent 7.11.250-test → 7.11.251-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads a file through Chrome's real file picker dialog on a public practice page
|
|
3
|
+
* and checks the page confirms the upload.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
7
|
+
|
|
8
|
+
describe("File upload (Playwright alternative)", () => {
|
|
9
|
+
it("uploads a file through the browser's file picker", async (context) => {
|
|
10
|
+
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP });
|
|
11
|
+
|
|
12
|
+
// Create the file to upload inside the sandbox.
|
|
13
|
+
await testdriver.exec("sh", 'echo "Uploaded by a TestDriver test" > /tmp/testdriver-upload.txt', 30000);
|
|
14
|
+
|
|
15
|
+
// Open the practice upload page in Chrome.
|
|
16
|
+
await testdriver.provision.chrome({ url: "https://the-internet.herokuapp.com/upload" });
|
|
17
|
+
|
|
18
|
+
// Open the file picker the user would see.
|
|
19
|
+
await testdriver.find("the Choose File button in the File Uploader form", { timeout: 30000 }).click();
|
|
20
|
+
|
|
21
|
+
// Wait for the dialog, then type the file's path and confirm.
|
|
22
|
+
await testdriver.find("the Open File dialog title at the top of the file picker window", { timeout: 15000 });
|
|
23
|
+
await testdriver.pressKeys(["ctrl", "l"]);
|
|
24
|
+
await testdriver.type("/tmp/testdriver-upload.txt");
|
|
25
|
+
await testdriver.pressKeys(["enter"]);
|
|
26
|
+
|
|
27
|
+
// Submit the form.
|
|
28
|
+
await testdriver.find("the Upload button below the Choose File button").click();
|
|
29
|
+
|
|
30
|
+
// Wait for the result page, then check the file name.
|
|
31
|
+
await testdriver.find("the File Uploaded! heading", { timeout: 15000 });
|
|
32
|
+
const result = await testdriver.assert(
|
|
33
|
+
"the page shows the File Uploaded! heading with testdriver-upload.txt listed as the uploaded file",
|
|
34
|
+
);
|
|
35
|
+
expect(result).toBeTruthy();
|
|
36
|
+
|
|
37
|
+
// Hold the final screen so the end of the replay shows the result.
|
|
38
|
+
await testdriver.wait(3000);
|
|
39
|
+
});
|
|
40
|
+
});
|