feat: simplify secondary pages with contextual controls and advanced options
This commit is contained in:
1 parent
d6df3f99fb
commit
717129c844
8 files changed
+350
-161
No files matched your search
@@ -15,21 +15,28 @@ def _controller(qtbot, tmp_path, snapshot):
|
||||
return controller, page, paths
|
||||
|
||||
|
||||
def _run_check(page, kind):
|
||||
index = page.check_type_combo.findData(kind)
|
||||
assert index >= 0
|
||||
page.check_type_combo.setCurrentIndex(index)
|
||||
page.run_button.click()
|
||||
|
||||
|
||||
def test_network_buttons_and_cross_page_rows_publish_location_without_writes(
|
||||
qtbot, tmp_path, snapshot_factory
|
||||
):
|
||||
snapshot = snapshot_factory(nets=(NetRecord("N1", (1,)), NetRecord("N2", (1, 2))))
|
||||
controller, page, paths = _controller(qtbot, tmp_path, snapshot)
|
||||
|
||||
page.solitary_button.click()
|
||||
_run_check(page, "solitary")
|
||||
assert page.model.rowCount() == 1
|
||||
assert page.model.item(0, 1).text() == "N1"
|
||||
page.table.doubleClicked.emit(page.model.index(0, 1))
|
||||
assert paths.locate.read_text(encoding="utf-8") == "net|N1|1\n"
|
||||
page.net_list_button.click()
|
||||
_run_check(page, "list")
|
||||
assert page.model.rowCount() == 2
|
||||
page.net_name_edit.setText(" n2 ")
|
||||
page.cross_page_button.click()
|
||||
_run_check(page, "cross")
|
||||
assert page.model.rowCount() == 2
|
||||
assert page.model.item(1, 2).text() == "2"
|
||||
page.table.doubleClicked.emit(page.model.index(1, 1))
|
||||
@@ -38,21 +45,19 @@ def test_network_buttons_and_cross_page_rows_publish_location_without_writes(
|
||||
assert not paths.apply_request.exists()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("button_name,attribute_name", [
|
||||
("value_miss_button", "Value"), ("value1_miss_button", "Value1"),
|
||||
])
|
||||
@pytest.mark.parametrize("attribute_name", ["Value", "Value1"])
|
||||
def test_attribute_omission_buttons_and_include_missing_filter(
|
||||
qtbot, tmp_path, component_factory, snapshot_factory, button_name, attribute_name
|
||||
qtbot, tmp_path, component_factory, snapshot_factory, attribute_name
|
||||
):
|
||||
empty = component_factory(refdes="R1", attributes=(AttributeRecord(attribute_name, "", True),))
|
||||
absent = component_factory(bridge_id="c0002", stable_uid="uid-c2", full_path="ROOT\\C2", refdes="C1")
|
||||
controller, page, paths = _controller(qtbot, tmp_path, snapshot_factory(components=(empty, absent)))
|
||||
|
||||
getattr(page, button_name).click()
|
||||
_run_check(page, attribute_name)
|
||||
assert page.model.rowCount() == 1
|
||||
assert page.model.item(0, 1).text() == f"R1 {attribute_name}"
|
||||
page.include_missing_checkbox.setChecked(True)
|
||||
getattr(page, button_name).click()
|
||||
_run_check(page, attribute_name)
|
||||
assert page.model.rowCount() == 2
|
||||
page.table.doubleClicked.emit(page.model.index(1, 1))
|
||||
assert paths.locate.read_text(encoding="utf-8") == "c0002\n"
|
||||
@@ -61,13 +66,13 @@ def test_attribute_omission_buttons_and_include_missing_filter(
|
||||
|
||||
def test_cross_page_empty_and_unknown_query_clear_old_results(qtbot, tmp_path, snapshot_factory):
|
||||
controller, page, paths = _controller(qtbot, tmp_path, snapshot_factory(nets=(NetRecord("N2", (1, 2)),)))
|
||||
page.net_list_button.click()
|
||||
_run_check(page, "list")
|
||||
|
||||
page.cross_page_button.click()
|
||||
_run_check(page, "cross")
|
||||
assert page.model.rowCount() == 0
|
||||
assert "请输入" in page.summary_label.text()
|
||||
page.net_name_edit.setText("missing")
|
||||
page.cross_page_button.click()
|
||||
_run_check(page, "cross")
|
||||
assert page.model.rowCount() == 0
|
||||
assert "missing" in page.summary_label.text()
|
||||
|
||||
@@ -75,7 +80,7 @@ def test_cross_page_empty_and_unknown_query_clear_old_results(qtbot, tmp_path, s
|
||||
def test_missing_network_data_reports_limitation(qtbot, tmp_path, snapshot_factory):
|
||||
controller, page, paths = _controller(qtbot, tmp_path, snapshot_factory())
|
||||
|
||||
page.solitary_button.click()
|
||||
_run_check(page, "solitary")
|
||||
|
||||
assert page.model.rowCount() == 0
|
||||
assert "未包含网络数据" in page.summary_label.text()
|
||||
@@ -87,13 +92,15 @@ def test_inspection_actions_wait_for_a_design_snapshot(qtbot, snapshot_factory):
|
||||
qtbot.addWidget(page)
|
||||
controller = InspectionController(page)
|
||||
|
||||
assert not page.solitary_button.isEnabled()
|
||||
assert not page.value_miss_button.isEnabled()
|
||||
assert not page.cross_page_button.isEnabled()
|
||||
assert not page.run_button.isEnabled()
|
||||
assert not page.check_type_combo.isEnabled()
|
||||
assert not page.net_name_edit.isEnabled()
|
||||
assert not page.include_missing_checkbox.isEnabled()
|
||||
controller.load_snapshot(snapshot_factory())
|
||||
assert page.solitary_button.isEnabled()
|
||||
assert page.value_miss_button.isEnabled()
|
||||
assert page.cross_page_button.isEnabled()
|
||||
assert page.run_button.isEnabled()
|
||||
assert page.check_type_combo.isEnabled()
|
||||
assert page.net_name_edit.isEnabled()
|
||||
assert page.include_missing_checkbox.isEnabled()
|
||||
|
||||
|
||||
def test_network_navigation_has_live_list_and_locator(qtbot, tmp_path, fixture_path, monkeypatch):
|
||||
@@ -112,11 +119,11 @@ def test_network_navigation_has_live_list_and_locator(qtbot, tmp_path, fixture_p
|
||||
page = window.pages.currentWidget()
|
||||
assert isinstance(page, InspectionPage)
|
||||
assert page.model.rowCount() == 2
|
||||
assert page.value_miss_button.isHidden()
|
||||
page.solitary_button.click()
|
||||
assert page.check_type_combo.findData("Value") == -1
|
||||
_run_check(page, "solitary")
|
||||
assert page.model.rowCount() == 1
|
||||
page.net_name_edit.setText("N2")
|
||||
page.cross_page_button.click()
|
||||
_run_check(page, "cross")
|
||||
assert page.model.rowCount() == 2
|
||||
page.table.doubleClicked.emit(page.model.index(1, 1))
|
||||
assert (tmp_path / "locate.tsv").read_text(encoding="utf-8") == "net|N2|2\n"
|
||||
@@ -125,7 +132,7 @@ def test_network_navigation_has_live_list_and_locator(qtbot, tmp_path, fixture_p
|
||||
|
||||
def test_refresh_recomputes_the_visible_inspection(qtbot, tmp_path, snapshot_factory):
|
||||
controller, page, paths = _controller(qtbot, tmp_path, snapshot_factory(nets=(NetRecord("old", (1,)),)))
|
||||
page.net_list_button.click()
|
||||
_run_check(page, "list")
|
||||
|
||||
controller.load_snapshot(snapshot_factory(snapshot_id="new", nets=(NetRecord("new", (2,)),)))
|
||||
|
||||
|
||||
Reference in new issue
Block a user