Files
阿白叔 f8f07d30d2
Core regression / Python core, intervention UI and release configuration (push) Failing after 2m42s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Canceled after 1m17s
Core regression / JavaScript syntax (pull_request) Canceled after 0s
merge(main): resolve PR19 review conflicts and run intervention regressions in CI
2026-11-09 11:35:29 +08:00

79 lines
3.7 KiB
Python

"""Current one-project UI fixtures; queries must settle before assertions."""
import os
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
from types import SimpleNamespace
from pathlib import Path
import subprocess
import pytest
from shiboken6 import isValid
from dx_productivity.trial_task_center.logging_setup import configure_logging
from dx_productivity.trial_task_center.store import TaskStore
from dx_productivity.trial_task_center.service import TaskCenterService
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
@pytest.fixture(autouse=True)
def controlled_error_dialogs(monkeypatch):
from PySide6.QtWidgets import QMessageBox
monkeypatch.setattr(QMessageBox, 'warning', lambda *args, **kwargs: QMessageBox.StandardButton.Ok)
@pytest.fixture
def ai_ready(monkeypatch):
"""AI flow tests supply readiness explicitly; normal fixtures remain unconfigured."""
from dx_productivity.trial_task_center.ui import dsh_status
monkeypatch.setattr(dsh_status, 'check_availability', lambda root:
{'available': True, 'code': 'available', 'message': 'Controlled configured model'})
@pytest.fixture
def ui(qtbot, tmp_path):
root = tmp_path/'projects'
for name in ('Board-A','Board-B'):
project=root/name/'board.prj';project.parent.mkdir(parents=True)
project.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n')
data=tmp_path/'data'
calls=[]
def worker(command, timeout):
queue=Path(command[3]);job=command[-1];calls.append(job)
with (queue/'status.tsv').open('a',encoding='utf-8') as stream:
stream.write(f'{job}\tno_match\tbatch_closed\tNo matching components\n')
return subprocess.CompletedProcess(command,0,'','')
preparer=QuickRunPreparer(data,process_runner=worker,
cscript_resolver=lambda:Path('cscript.exe'),sheet_discoverer=lambda _path:(('MAIN','1'),))
store=TaskStore(tmp_path/'tasks.db')
service=TaskCenterService(store,configure_logging(data),quick_run_preparer=preparer)
tasks=service.create_project_tasks(root)
service.add_rule(tasks[0].task_id,'OLD','NEW')
window=TrialTaskCenterWindow(service)
qtbot.addWidget(window);window.show()
def settle():
if not isValid(window) or window._closed:
return
qtbot.waitUntil(lambda:not window._workers and not window._task_query.busy
and not window._context_query.busy and not window._feedback_query.busy
and not window._log_presenter.query.busy and not window._resource_status.busy
and not window._dsh_operations.worker,timeout=5000)
def open_task(task):
window.open_task(task.task_id)
qtbot.waitUntil(lambda:not window._context_query.busy and not window._loading,timeout=5000)
assert window._context and window._context.task.task_id==task.task_id
open_task(tasks[0])
yield SimpleNamespace(window=window,service=service,store=store,tasks=tasks,
calls=calls,settle=settle,open=open_task,data=data)
if isValid(window):
settle()
if isValid(window):
window.plan_panel.discard_all()
window.close()
qtbot.waitUntil(lambda: not isValid(window) or window._closed, timeout=5000)
from PySide6.QtCore import QThreadPool
QThreadPool.globalInstance().waitForDone(5000)
for name in ('_dsh_status', '_dsh_operations', '_dsh_lifecycle', '_dsh_automation'):
controller = getattr(window, name, None)
pool = getattr(controller, '_read_pool', None) or getattr(controller, '_pool', None)
if pool is not None:
assert pool.waitForDone(5000), 'Controlled AI reads must finish before closing the fixture store'
store.close()