fix-ui-restore-task-status-categories
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 16s
Core regression / JavaScript syntax (pull_request) Successful in 4s

This commit is contained in:
阿白叔 committed 2026-11-03 11:02:27 +08:00
1 parent ba1d50cdfc
commit 63835afba8
6 files changed
+137 -7

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
from dataclasses import replace
from datetime import datetime, timezone
from pathlib import Path
import pytest
from PySide6.QtCore import Qt
from dx_productivity.trial_task_center.models import TaskRecord, TaskStatus
from dx_productivity.trial_task_center.ui.task_list import TaskList
@pytest.fixture
def navigation(qtbot):
opened=[]
panel=TaskList(opened.append)
qtbot.addWidget(panel)
now=datetime.now(timezone.utc)
tasks=tuple(TaskRecord(status.value, 'Board '+status.value, 'audio', Path('F:/Projects'),
status, now, now, group_id='batch', group_position=index)
for index,status in enumerate(TaskStatus) if status is not TaskStatus.DELETED)
panel.populate(tasks,selected_task_id='ready')
panel.show()
return panel,tasks,opened
def visible_ids(panel):
return [panel.list.item(index).data(Qt.ItemDataRole.UserRole) for index in range(panel.list.count())]
@pytest.mark.parametrize(('category','expected'),[
('all',['draft','ready','running','paused','completed','failed']),
('unfinished',['draft','ready','running','paused','failed']),
('completed',['completed']),
('failed',['failed']),
])
def test_visible_status_category_filters_task_list(navigation,category,expected):
panel,tasks,opened=navigation
assert panel.filter.isVisible()
index=panel.filter.findData(category)
assert index>=0
panel.filter.setCurrentIndex(index)
assert visible_ids(panel)==expected
assert panel._tasks==tasks
assert opened==[]
def test_category_and_search_combine_and_refresh_tracks_new_status(navigation):
panel,tasks,opened=navigation
panel.filter.setCurrentIndex(panel.filter.findData('unfinished'))
panel.search.setText('Board ready')
assert visible_ids(panel)==['ready']
updated=tuple(replace(task,status=TaskStatus.COMPLETED) if task.task_id=='ready' else task for task in tasks)
panel.populate(updated,selected_task_id='ready')
assert visible_ids(panel)==[]
assert '当前任务已隐藏' in panel.count.text()
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
assert visible_ids(panel)==['ready']
assert panel.current_task_id()=='ready'
assert opened==[]
def test_category_is_local_and_never_changes_batch_scope(ui,monkeypatch):
window=ui.window
before=window._tasks
def unexpected_read(**kwargs):
raise AssertionError('Category changes must use cached tasks')
monkeypatch.setattr(ui.service,'tasks',unexpected_read)
panel=window.task_list
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
assert panel.list.count()==0
assert window._tasks==before
assert window._task_id==ui.tasks[0].task_id
assert not panel.up_button.isEnabled()
assert not panel.down_button.isEnabled()
panel.filter.setCurrentIndex(panel.filter.findData('all'))
assert panel.list.count()==len(before)
def test_recycle_bin_ignores_active_status_category(ui):
panel=ui.window.task_list
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
ui.service.delete_task(ui.tasks[1].task_id)
panel.recycle_button.setChecked(True)
ui.settle()
assert not panel.filter.isEnabled()
assert visible_ids(panel)==[ui.tasks[1].task_id]
panel.recycle_button.setChecked(False)
ui.settle()
assert panel.filter.isEnabled()
assert panel.filter.currentData()=='completed'
assert visible_ids(panel)==[]
+1 -1
View File
@@ -11,7 +11,7 @@ def test_shell_has_stable_automation_controls_and_current_navigation(ui):
'boundProjectPath','exportBomTemplate','importBomPlan','toggleLogButton'):
assert w.findChild(QWidget,name) is not None,name
assert w.windowTitle()==f'DxDesigner 器件替换 · {VERSION}'
assert not w.task_list.filter.isVisible()
assert w.task_list.filter.isVisible()
assert w.workspace_splitter.orientation()==Qt.Orientation.Horizontal
assert not w.workspace_splitter.childrenCollapsible()
assert w.detail_splitter.count()==2