@gradio/file 0.14.5 → 0.14.7
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.
- package/CHANGELOG.md +17 -0
- package/File.test.ts +53 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @gradio/file
|
|
2
2
|
|
|
3
|
+
## 0.14.7
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/atoms@0.23.1
|
|
8
|
+
- @gradio/statustracker@0.14.0
|
|
9
|
+
- @gradio/client@2.2.0
|
|
10
|
+
|
|
11
|
+
## 0.14.6
|
|
12
|
+
|
|
13
|
+
### Dependency updates
|
|
14
|
+
|
|
15
|
+
- @gradio/utils@0.12.2
|
|
16
|
+
- @gradio/atoms@0.23.0
|
|
17
|
+
- @gradio/statustracker@0.13.1
|
|
18
|
+
- @gradio/upload@0.17.8
|
|
19
|
+
|
|
3
20
|
## 0.14.5
|
|
4
21
|
|
|
5
22
|
### Dependency updates
|
package/File.test.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, test, expect, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
render,
|
|
4
|
+
download_file,
|
|
5
|
+
upload_file,
|
|
6
|
+
drop_file,
|
|
7
|
+
mock_client,
|
|
8
|
+
TEST_TXT
|
|
9
|
+
} from "@self/tootils/render";
|
|
10
|
+
import File from "./Index.svelte";
|
|
11
|
+
|
|
12
|
+
const default_props = {
|
|
13
|
+
interactive: true,
|
|
14
|
+
label: "Test File",
|
|
15
|
+
show_label: true,
|
|
16
|
+
value: null,
|
|
17
|
+
file_count: "single",
|
|
18
|
+
file_types: null,
|
|
19
|
+
root: "http://localhost:7860",
|
|
20
|
+
client: mock_client()
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe("File", () => {
|
|
24
|
+
test("download link triggers a real file download with correct content", async () => {
|
|
25
|
+
await render(File, {
|
|
26
|
+
...default_props,
|
|
27
|
+
value: [TEST_TXT]
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { suggested_filename, content } = await download_file("a[download]");
|
|
31
|
+
|
|
32
|
+
expect(suggested_filename).toBe("alphabet.txt");
|
|
33
|
+
expect(content).toBe("abcdefghijklmnopqrstuvwxyz");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("upload_file sets a file on the file input", async () => {
|
|
37
|
+
const { listen } = await render(File, default_props);
|
|
38
|
+
|
|
39
|
+
const upload = listen("upload");
|
|
40
|
+
await upload_file(TEST_TXT);
|
|
41
|
+
|
|
42
|
+
await vi.waitFor(() => expect(upload).toHaveBeenCalled());
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("drop_file simulates drag-and-drop onto the upload area", async () => {
|
|
46
|
+
const { listen } = await render(File, default_props);
|
|
47
|
+
|
|
48
|
+
const upload = listen("upload");
|
|
49
|
+
await drop_file(TEST_TXT, "[aria-label='Click to upload or drop files']");
|
|
50
|
+
|
|
51
|
+
await vi.waitFor(() => expect(upload).toHaveBeenCalled());
|
|
52
|
+
});
|
|
53
|
+
});
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/file",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"private": false,
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@gradio/atoms": "^0.
|
|
11
|
-
"@gradio/client": "^2.1.0",
|
|
10
|
+
"@gradio/atoms": "^0.23.1",
|
|
12
11
|
"@gradio/icons": "^0.15.1",
|
|
13
|
-
"@gradio/
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/
|
|
12
|
+
"@gradio/client": "^2.2.0",
|
|
13
|
+
"@gradio/statustracker": "^0.14.0",
|
|
14
|
+
"@gradio/utils": "^0.12.2",
|
|
15
|
+
"@gradio/upload": "^0.17.8"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@gradio/preview": "^0.16.
|
|
18
|
+
"@gradio/preview": "^0.16.2"
|
|
19
19
|
},
|
|
20
20
|
"main": "./Index.svelte",
|
|
21
21
|
"main_changeset": true,
|