HongzeFu commited on
Commit
d1f67eb
·
1 Parent(s): 0581606

loading font

Browse files
gradio-web/test/test_ui_native_layout_contract.py CHANGED
@@ -36,6 +36,8 @@ def test_native_ui_css_uses_configured_global_font_size_variables(reload_module)
36
  assert f"--button-large-text-size: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
37
  assert f"--section-header-text-size: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
38
  assert f"--text-md: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
 
 
39
 
40
 
41
  def test_native_ui_css_excludes_header_title_from_global_font_size(reload_module):
@@ -163,7 +165,11 @@ def test_native_ui_config_contains_phase_machine_and_precheck_chain(reload_modul
163
  ]
164
  assert all("_anchor" not in str(v) for v in values)
165
  assert any(
166
- "Logging in and setting up environment... Please wait." in str(v)
 
 
 
 
167
  for v in values
168
  )
169
  assert all("Loading environment, please wait..." not in str(v) for v in values)
 
36
  assert f"--button-large-text-size: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
37
  assert f"--section-header-text-size: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
38
  assert f"--text-md: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
39
+ assert "#loading_overlay_group h3" in css
40
+ assert f"font-size: {config.UI_GLOBAL_FONT_SIZE} !important;" in css
41
 
42
 
43
  def test_native_ui_css_excludes_header_title_from_global_font_size(reload_module):
 
165
  ]
166
  assert all("_anchor" not in str(v) for v in values)
167
  assert any(
168
+ "The episode is loading..." in str(v)
169
+ for v in values
170
+ )
171
+ assert all(
172
+ "Logging in and setting up environment... Please wait." not in str(v)
173
  for v in values
174
  )
175
  assert all("Loading environment, please wait..." not in str(v) for v in values)
gradio-web/test/test_ui_phase_machine_runtime_e2e.py CHANGED
@@ -1032,10 +1032,13 @@ def test_demo_video_stop_event_transitions_and_hides_button(phase_machine_ui_url
1032
 
1033
 
1034
  def test_unified_loading_overlay_init_flow(monkeypatch):
 
 
1035
  ui_layout = importlib.reload(importlib.import_module("ui_layout"))
1036
 
1037
- canonical_copy = "Logging in and setting up environment... Please wait."
1038
  legacy_copy = "Loading environment, please wait..."
 
1039
  fake_obs = np.zeros((24, 24, 3), dtype=np.uint8)
1040
  fake_obs_img = Image.fromarray(fake_obs)
1041
  calls = {"init": 0}
@@ -1076,15 +1079,17 @@ def test_unified_loading_overlay_init_flow(monkeypatch):
1076
 
1077
  port = _free_port()
1078
  host = "127.0.0.1"
1079
- root_url = f"http://{host}:{port}/"
1080
-
1081
- app = FastAPI(title="native-unified-loading-overlay-test")
1082
- app = gr.mount_gradio_app(app, demo, path="/")
1083
-
1084
- config = uvicorn.Config(app, host=host, port=port, log_level="error")
1085
- server = uvicorn.Server(config)
1086
- thread = threading.Thread(target=server.run, daemon=True)
1087
- thread.start()
 
 
1088
  _wait_http_ready(root_url)
1089
 
1090
  try:
@@ -1101,7 +1106,15 @@ def test_unified_loading_overlay_init_flow(monkeypatch):
1101
  return el ? (el.textContent || '') : '';
1102
  }"""
1103
  )
 
 
 
 
 
 
 
1104
  assert canonical_copy in overlay_text
 
1105
  assert legacy_copy not in page.content()
1106
 
1107
  page.wait_for_selector("#loading_overlay_group", state="hidden", timeout=15000)
@@ -1109,17 +1122,20 @@ def test_unified_loading_overlay_init_flow(monkeypatch):
1109
  page.wait_for_function(
1110
  """() => {
1111
  const root = document.getElementById('header_task');
1112
- const input = root ? root.querySelector('input') : null;
1113
- return !!input && input.value.trim() === 'PickXtimes';
 
 
 
 
 
1114
  }""",
1115
- timeout=5000,
1116
  )
1117
  assert _read_header_task_value(page) == "PickXtimes"
1118
 
1119
  browser.close()
1120
  finally:
1121
- server.should_exit = True
1122
- thread.join(timeout=10)
1123
  demo.close()
1124
 
1125
  assert calls["init"] >= 1
 
1032
 
1033
 
1034
  def test_unified_loading_overlay_init_flow(monkeypatch):
1035
+ config_module = importlib.reload(importlib.import_module("config"))
1036
+ monkeypatch.setattr(config_module, "UI_GLOBAL_FONT_SIZE", "32px")
1037
  ui_layout = importlib.reload(importlib.import_module("ui_layout"))
1038
 
1039
+ canonical_copy = "The episode is loading..."
1040
  legacy_copy = "Loading environment, please wait..."
1041
+ superseded_copy = "Logging in and setting up environment... Please wait."
1042
  fake_obs = np.zeros((24, 24, 3), dtype=np.uint8)
1043
  fake_obs_img = Image.fromarray(fake_obs)
1044
  calls = {"init": 0}
 
1079
 
1080
  port = _free_port()
1081
  host = "127.0.0.1"
1082
+ _app, root_url, _share_url = demo.launch(
1083
+ server_name=host,
1084
+ server_port=port,
1085
+ prevent_thread_lock=True,
1086
+ quiet=True,
1087
+ show_error=True,
1088
+ ssr_mode=False,
1089
+ theme=ui_layout.APP_THEME,
1090
+ css=ui_layout.CSS,
1091
+ head=ui_layout.THEME_LOCK_HEAD,
1092
+ )
1093
  _wait_http_ready(root_url)
1094
 
1095
  try:
 
1106
  return el ? (el.textContent || '') : '';
1107
  }"""
1108
  )
1109
+ page.wait_for_function(
1110
+ """() => {
1111
+ const heading = document.querySelector('#loading_overlay_group h3');
1112
+ return !!heading && getComputedStyle(heading).fontSize === '32px';
1113
+ }""",
1114
+ timeout=5000,
1115
+ )
1116
  assert canonical_copy in overlay_text
1117
+ assert superseded_copy not in overlay_text
1118
  assert legacy_copy not in page.content()
1119
 
1120
  page.wait_for_selector("#loading_overlay_group", state="hidden", timeout=15000)
 
1122
  page.wait_for_function(
1123
  """() => {
1124
  const root = document.getElementById('header_task');
1125
+ if (!root) return false;
1126
+ const input = root.querySelector('input');
1127
+ if (input && typeof input.value === 'string' && input.value.trim() === 'PickXtimes') {
1128
+ return true;
1129
+ }
1130
+ const selected = root.querySelector('.single-select');
1131
+ return !!selected && (selected.textContent || '').trim() === 'PickXtimes';
1132
  }""",
1133
+ timeout=15000,
1134
  )
1135
  assert _read_header_task_value(page) == "PickXtimes"
1136
 
1137
  browser.close()
1138
  finally:
 
 
1139
  demo.close()
1140
 
1141
  assert calls["init"] >= 1
gradio-web/ui_layout.py CHANGED
@@ -369,6 +369,7 @@ CSS = f"""
369
 
370
  #loading_overlay_group h3 {{
371
  margin: 0 !important;
 
372
  }}
373
 
374
  #reference_action_btn button:not(:disabled),
@@ -581,7 +582,7 @@ def create_ui_blocks():
581
  )
582
 
583
  with gr.Column(visible=True, elem_id="loading_overlay_group") as loading_overlay:
584
- gr.Markdown("### Logging in and setting up environment... Please wait.")
585
 
586
  uid_state = gr.State(value=None)
587
  ui_phase_state = gr.State(value=PHASE_INIT)
 
369
 
370
  #loading_overlay_group h3 {{
371
  margin: 0 !important;
372
+ font-size: {UI_GLOBAL_FONT_SIZE} !important;
373
  }}
374
 
375
  #reference_action_btn button:not(:disabled),
 
582
  )
583
 
584
  with gr.Column(visible=True, elem_id="loading_overlay_group") as loading_overlay:
585
+ gr.Markdown("### The episode is loading...")
586
 
587
  uid_state = gr.State(value=None)
588
  ui_phase_state = gr.State(value=PHASE_INIT)