Daryl Lim Claude Sonnet 4.6 commited on
Commit
57a1d31
·
1 Parent(s): facc74d

feat: replace English label with static dropdown for visual symmetry

Browse files
Files changed (2) hide show
  1. app.py +6 -1
  2. tests/test_app.py +15 -5
app.py CHANGED
@@ -95,7 +95,12 @@ def _build_demo() -> gr.Blocks:
95
  with gr.Blocks(title="MADLAD-400 Translation") as demo:
96
  with gr.Row(equal_height=True):
97
  with gr.Column():
98
- gr.Markdown("**English**")
 
 
 
 
 
99
  input_text = gr.Textbox(
100
  placeholder="Enter English text here",
101
  lines=4,
 
95
  with gr.Blocks(title="MADLAD-400 Translation") as demo:
96
  with gr.Row(equal_height=True):
97
  with gr.Column():
98
+ gr.Dropdown(
99
+ choices=["English"],
100
+ value="English",
101
+ show_label=False,
102
+ interactive=False,
103
+ )
104
  input_text = gr.Textbox(
105
  placeholder="Enter English text here",
106
  lines=4,
tests/test_app.py CHANGED
@@ -88,16 +88,24 @@ def test_demo_has_no_sliders(demo):
88
  assert len(sliders) == 0, f"Expected no sliders, found {len(sliders)}"
89
 
90
 
 
 
 
 
 
 
 
91
  def test_demo_has_dropdown(demo):
92
- """UI should have a language dropdown."""
93
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
94
- assert len(dropdowns) == 1, f"Expected 1 dropdown, found {len(dropdowns)}"
95
 
96
 
97
  def test_dropdown_default_is_french(demo):
98
  """Default dropdown value should be French (fr)."""
99
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
100
- assert dropdowns[0].value == "French (fr)"
 
101
 
102
 
103
  def test_demo_has_two_textboxes(demo):
@@ -159,14 +167,16 @@ def test_no_title(demo):
159
  def test_dropdown_is_filterable(demo):
160
  """Dropdown should be filterable/searchable."""
161
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
162
- assert dropdowns[0].filterable is True
 
163
 
164
 
165
  def test_dropdown_choices_include_locale_codes(demo):
166
  """Dropdown choices should include locale codes like 'French (fr)'."""
167
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
 
168
  # Gradio stores choices as (label, value) tuples
169
- labels = [c[0] if isinstance(c, tuple) else c for c in dropdowns[0].choices]
170
  assert all("(" in label and ")" in label for label in labels), f"Expected locale codes in choices: {labels}"
171
 
172
 
 
88
  assert len(sliders) == 0, f"Expected no sliders, found {len(sliders)}"
89
 
90
 
91
+ def test_demo_has_english_dropdown(demo):
92
+ """UI should have a non-interactive English dropdown."""
93
+ dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
94
+ english = [d for d in dropdowns if d.interactive is False and d.value == "English"]
95
+ assert len(english) == 1, "Expected exactly one non-interactive English dropdown"
96
+
97
+
98
  def test_demo_has_dropdown(demo):
99
+ """UI should have two dropdowns (English + target language)."""
100
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
101
+ assert len(dropdowns) == 2, f"Expected 2 dropdowns, found {len(dropdowns)}"
102
 
103
 
104
  def test_dropdown_default_is_french(demo):
105
  """Default dropdown value should be French (fr)."""
106
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
107
+ interactive = [d for d in dropdowns if d.interactive is not False]
108
+ assert interactive[0].value == "French (fr)"
109
 
110
 
111
  def test_demo_has_two_textboxes(demo):
 
167
  def test_dropdown_is_filterable(demo):
168
  """Dropdown should be filterable/searchable."""
169
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
170
+ interactive = [d for d in dropdowns if d.interactive is not False]
171
+ assert interactive[0].filterable is True
172
 
173
 
174
  def test_dropdown_choices_include_locale_codes(demo):
175
  """Dropdown choices should include locale codes like 'French (fr)'."""
176
  dropdowns = [b for b in demo.blocks.values() if type(b).__name__ == "Dropdown"]
177
+ interactive = [d for d in dropdowns if d.interactive is not False]
178
  # Gradio stores choices as (label, value) tuples
179
+ labels = [c[0] if isinstance(c, tuple) else c for c in interactive[0].choices]
180
  assert all("(" in label and ")" in label for label in labels), f"Expected locale codes in choices: {labels}"
181
 
182