Spaces:
Running on Zero
Running on Zero
Commit ·
f944367
1
Parent(s): 2cf98f7
Hide the download file box until Get Files is clicked
Browse filesIt was defaulting to visible=True, so an empty "Download" file box showed up
on page load even before any translation or download attempt.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- app.py +1 -1
- tests/test_app.py +12 -0
app.py
CHANGED
|
@@ -107,7 +107,7 @@ def build_app() -> gr.Blocks:
|
|
| 107 |
label="Files to include", choices=[], value=[], visible=False, scale=2,
|
| 108 |
)
|
| 109 |
get_files_btn = gr.Button("Get Files", variant="primary", scale=0, min_width=100, visible=False)
|
| 110 |
-
download_zip = gr.File(label="Download", visible=
|
| 111 |
|
| 112 |
slot_groups, slot_sources, slot_targets, slot_translate_btns = [], [], [], []
|
| 113 |
|
|
|
|
| 107 |
label="Files to include", choices=[], value=[], visible=False, scale=2,
|
| 108 |
)
|
| 109 |
get_files_btn = gr.Button("Get Files", variant="primary", scale=0, min_width=100, visible=False)
|
| 110 |
+
download_zip = gr.File(label="Download", visible=False, interactive=False)
|
| 111 |
|
| 112 |
slot_groups, slot_sources, slot_targets, slot_translate_btns = [], [], [], []
|
| 113 |
|
tests/test_app.py
CHANGED
|
@@ -19,3 +19,15 @@ def test_build_app_falls_back_gracefully_if_model_fetch_fails():
|
|
| 19 |
patch("app.DEFAULT_MODEL", "model/a"):
|
| 20 |
demo = build_app()
|
| 21 |
assert demo is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
patch("app.DEFAULT_MODEL", "model/a"):
|
| 20 |
demo = build_app()
|
| 21 |
assert demo is not None
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_download_file_hidden_until_get_files_clicked():
|
| 25 |
+
with patch("app.list_model_choices", return_value=["model/a"]), \
|
| 26 |
+
patch("app.DEFAULT_MODEL", "model/a"):
|
| 27 |
+
demo = build_app()
|
| 28 |
+
download_components = [
|
| 29 |
+
b for b in demo.blocks.values()
|
| 30 |
+
if b.__class__.__name__ == "File" and b.label == "Download"
|
| 31 |
+
]
|
| 32 |
+
assert len(download_components) == 1
|
| 33 |
+
assert download_components[0].visible is False
|