test(#4759): guard async harness extraction for sidebar refresh
This commit is contained in:
parent
9cae66a1a0
commit
c071da4f5d
1 changed files with 16 additions and 8 deletions
|
|
@ -101,6 +101,16 @@ def _extract_function(source_text, function_name):
|
|||
raise AssertionError(f"Could not extract {function_name}")
|
||||
|
||||
|
||||
def _ensure_async(function_source, function_name):
|
||||
if function_source.startswith("async function "):
|
||||
return function_source
|
||||
return function_source.replace(
|
||||
f"function {function_name}",
|
||||
f"async function {function_name}",
|
||||
1,
|
||||
)
|
||||
|
||||
|
||||
def _run_node(script):
|
||||
proc = subprocess.run([NODE, "-e", script], capture_output=True, text=True, check=True)
|
||||
return json.loads(proc.stdout)
|
||||
|
|
@ -529,15 +539,13 @@ def test_scope_mismatch_error_path_respects_sidebar_source():
|
|||
requested_source_fn = _extract_function(src, "_requestedSessionSidebarSource")
|
||||
exclude_hidden_fn = _extract_function(src, "_sessionListExcludeHiddenEnabled")
|
||||
query_fn = _extract_function(src, "_sessionListQueryString")
|
||||
fetch_helper_fn = _extract_function(src, "_loadSidebarSessionListPayload").replace(
|
||||
"function _loadSidebarSessionListPayload",
|
||||
"async function _loadSidebarSessionListPayload",
|
||||
1,
|
||||
fetch_helper_fn = _ensure_async(
|
||||
_extract_function(src, "_loadSidebarSessionListPayload"),
|
||||
"_loadSidebarSessionListPayload",
|
||||
)
|
||||
refresh_fn = _extract_function(src, "_runRenderSessionListRefresh").replace(
|
||||
"function _runRenderSessionListRefresh",
|
||||
"async function _runRenderSessionListRefresh",
|
||||
1,
|
||||
refresh_fn = _ensure_async(
|
||||
_extract_function(src, "_runRenderSessionListRefresh"),
|
||||
"_runRenderSessionListRefresh",
|
||||
)
|
||||
script = f"""
|
||||
global.window = {{ _showCliSessions: true }};
|
||||
|
|
|
|||
Loading…
Reference in a new issue