fix(ui): isolate BOM reports and keep target workspace usable
This commit is contained in:
1 parent
2fdbe3acb3
commit
d0125f8f59
12 files changed
+232
-52
No files matched your search
@@ -173,7 +173,8 @@ def test_batch_rules_and_target_plan_are_above_project_summary(qtbot, tmp_path):
|
||||
qtbot.waitUntil(lambda: not window._loading and not window._context_query.busy)
|
||||
qtbot.waitExposed(window)
|
||||
assert window.mapping_tabs.objectName() == 'batchPlanTabs'
|
||||
assert window.mapping_tabs.geometry().top() < window.project_summary.geometry().top()
|
||||
from PySide6.QtCore import QPoint
|
||||
assert window.mapping_tabs.mapTo(window, QPoint()).y() < window.project_summary.mapTo(window, QPoint()).y()
|
||||
assert window.mapping_tabs.tabText(0) == '本批料号规则'
|
||||
assert window.mapping_tabs.tabText(1) == '本批位号计划'
|
||||
window.close(); store.close()
|
||||
@@ -83,6 +83,9 @@ def test_all_steps_survive_reopening_completed_task(qtbot, tmp_path):
|
||||
window = TrialTaskCenterWindow(service); qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda: not window._loading and not window._context_query.busy)
|
||||
# Reopening a completed task preserves the plan workspace; logs are on demand.
|
||||
assert not window.run_panel.toggle_log_button.isChecked()
|
||||
window._show_task_log()
|
||||
qtbot.waitUntil(lambda: not window._log_presenter.query.busy)
|
||||
assert window.run_panel.toggle_log_button.isChecked()
|
||||
text = window.run_panel.log_view.toPlainText()
|
||||
|
||||
@@ -75,3 +75,21 @@ def test_target_table_find_next_selects_next_matching_row(qtbot):
|
||||
assert table.find_next() == 1
|
||||
assert table.find_next() == 2
|
||||
assert table.find_next() == 0
|
||||
|
||||
|
||||
def test_header_sort_edit_and_bulk_actions_keep_uid_binding(qtbot):
|
||||
table = TargetTable()
|
||||
qtbot.addWidget(table)
|
||||
rows = tuple(TargetPlanRow(ComponentTarget(Path('board.prj'), 'MAIN', '1', uid, ref, 'OLD', 'V'), enabled=True)
|
||||
for uid, ref in [('u2', 'R2'), ('u1', 'R1')])
|
||||
table.populate(rows)
|
||||
assert table.isSortingEnabled()
|
||||
table.sortByColumn(3, Qt.SortOrder.AscendingOrder)
|
||||
assert table.item(0, 3).text() == 'R1'
|
||||
table.item(0, 6).setText('NEW-R1')
|
||||
table.selectRow(1)
|
||||
table.apply_to_selected('NEW-R2')
|
||||
assert {r.target.uid: r.new_part_number for r in table.rows()} == {'u1': 'NEW-R1', 'u2': 'NEW-R2'}
|
||||
table.set_find_text('R1')
|
||||
table.select_all_targets(False)
|
||||
assert {r.target.uid: r.enabled for r in table.rows()} == {'u1': False, 'u2': True}
|
||||
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
|
||||
|
||||
from dataclasses import replace
|
||||
from types import SimpleNamespace
|
||||
|
||||
from dx_productivity.trial_task_center.bom_import_report import BomImportReport, BomRowResult
|
||||
from dx_productivity.trial_task_center.ui.project_plan import ProjectPlanPanel
|
||||
from test_ui_remediation import window
|
||||
|
||||
|
||||
def test_bom_report_follows_batch_and_restores_for_sibling(qtbot):
|
||||
owner = SimpleNamespace(_known_task_groups={'a': 'batch1', 'b': 'batch1', 'c': 'batch2'},
|
||||
_update_gates=lambda: None, service=SimpleNamespace(target_plan=lambda _: ()))
|
||||
panel = ProjectPlanPanel(owner)
|
||||
qtbot.addWidget(panel)
|
||||
panel.bind_task('a')
|
||||
report = BomImportReport((BomRowResult(2, '/a', 'Board A', 'failed', 'missing part'),), ())
|
||||
panel._received_bom_report(report)
|
||||
assert panel.last_bom_report is report
|
||||
panel.bind_task('c')
|
||||
assert panel.last_bom_report is None
|
||||
assert not panel.bom_report.toPlainText()
|
||||
panel.bind_task('b')
|
||||
assert panel.last_bom_report is report
|
||||
assert 'Board A' in panel.bom_report.toPlainText()
|
||||
|
||||
|
||||
def test_narrow_window_keeps_plan_visible_with_report_and_logs(window, qtbot):
|
||||
task = window.service.create_task('Long path board')
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda: not window._loading and not window._context_query.busy)
|
||||
window.project_summary.path.setText('F:/' + 'long-project-folder/' * 30 + 'board.prj')
|
||||
report = BomImportReport((BomRowResult(2, '/a', 'Board A', 'failed', 'missing part'),), ())
|
||||
window.plan_panel._received_bom_report(report)
|
||||
window.mapping_tabs.setCurrentIndex(1)
|
||||
window.run_panel.toggle_log_button.setChecked(True)
|
||||
window.show()
|
||||
window.resize(980, 700)
|
||||
qtbot.wait(50)
|
||||
assert window.width() == 980 and window.height() == 700
|
||||
assert window.plan_panel.table.viewport().height() >= 100
|
||||
table = window.plan_panel.table
|
||||
assert table.geometry().bottom() < window.plan_panel.select_all.geometry().top()
|
||||
assert window.run_panel.quick_run_button.isVisible()
|
||||
assert window.plan_panel.export_bom_button.isVisible()
|
||||
|
||||
|
||||
def test_completed_context_does_not_force_log_open(window):
|
||||
from dx_productivity.trial_task_center.models import TaskStatus
|
||||
task = window.service.create_task('Done')
|
||||
context = window.service.task_context(task.task_id)
|
||||
window._task_id = task.task_id
|
||||
context = replace(context, task=replace(context.task, status=TaskStatus.COMPLETED), phase='complete')
|
||||
window._apply_task_context(context)
|
||||
assert not window.run_panel.toggle_log_button.isChecked()
|
||||
Reference in new issue
Block a user