Keep dependency installs responsive

This commit is contained in:
王鹏
2026-10-09 19:31:21 +08:00
parent 6c79ce0b26
commit 66dd1da2d1
4 changed files with 140 additions and 65 deletions

View File

@@ -962,7 +962,10 @@ class DeployerTests(unittest.TestCase):
[step.kind for step in plan],
["frontend_install", "frontend_start", "deployment_summary"],
)
self.assertEqual(plan[0].command, [npm, "install"])
self.assertEqual(
plan[0].command,
[npm, "install", "--no-audit", "--no-fund", "--progress=false"],
)
self.assertEqual(plan[1].command[1:3], ["run", "serve"])
def test_resolves_windows_cmd_shims_before_starting_process(self):

View File

@@ -18,6 +18,29 @@ class FakeWidget:
self.seen = index
class FakeLogWidget:
def __init__(self):
self.value = ""
self.insert_calls = 0
def configure(self, **options):
pass
def insert(self, index, value):
self.insert_calls += 1
self.value += value
def index(self, index):
return f"{self.value.count(chr(10)) + 1}.0"
def delete(self, start, end):
delete_lines = max(int(end.split('.', 1)[0]) - 1, 0)
self.value = "\n".join(self.value.split("\n")[delete_lines:])
def see(self, index):
pass
class FakeButton:
def __init__(self):
self.state = None
@@ -35,6 +58,22 @@ class FakeVariable:
class GuiNavigationTests(unittest.TestCase):
def test_log_queue_is_rendered_in_batches(self):
app = DeployWorkbench.__new__(DeployWorkbench)
app.ui_queue = queue.Queue()
app.log_text = FakeLogWidget()
scheduled = []
app.after = lambda delay, callback: scheduled.append(delay)
for index in range(100):
app.ui_queue.put(("log", f"line {index}"))
DeployWorkbench._drain_queue(app)
self.assertEqual(app.log_text.insert_calls, 1)
self.assertIn("line 0", app.log_text.value)
self.assertIn("line 99", app.log_text.value)
self.assertEqual(scheduled, [120])
def test_database_name_comes_from_first_sql_filename(self):
from pathlib import Path