更新
This commit is contained in:
@@ -303,10 +303,17 @@ def test_issued_page_sends_exact_filter_dto_and_row_guards(
|
||||
page._selection_changed()
|
||||
|
||||
assert page.table.columnCount() == 11
|
||||
assert page.table.horizontalHeaderItem(10).text() == "操作"
|
||||
assert page.table.horizontalHeaderItem(2).text() == "操作"
|
||||
assert page.table.cellWidget(0, 2) is not None
|
||||
assert page.table.cellWidget(0, 5) is not None
|
||||
assert page.table.cellWidget(0, 10) is not None
|
||||
assert page.table.cellWidget(0, 3) is not None
|
||||
assert page.table.cellWidget(0, 6) is not None
|
||||
row_edit = next(
|
||||
button
|
||||
for button in page.table.cellWidget(0, 2).findChildren(QPushButton)
|
||||
if button.accessibleName() == "编辑处方"
|
||||
)
|
||||
assert row_edit.text() == "编辑"
|
||||
assert row_edit.isEnabled()
|
||||
|
||||
assert calls == [
|
||||
{
|
||||
@@ -343,6 +350,88 @@ def test_issued_page_sends_exact_filter_dto_and_row_guards(
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_issued_row_edit_targets_clicked_prescription_without_checkbox(
|
||||
application: QApplication,
|
||||
immediate_async: None,
|
||||
) -> None:
|
||||
requested: list[int] = []
|
||||
opened: list[dict[str, Any]] = []
|
||||
callbacks: list[str] = []
|
||||
rows = [
|
||||
{
|
||||
"id": 11,
|
||||
"sn": "CF-11",
|
||||
"patient_name": "患者甲",
|
||||
"audit_status": 0,
|
||||
"void_status": 0,
|
||||
"creator_id": 7,
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"sn": "CF-22",
|
||||
"patient_name": "患者乙",
|
||||
"audit_status": 0,
|
||||
"void_status": 0,
|
||||
"creator_id": 7,
|
||||
},
|
||||
]
|
||||
|
||||
class Repository:
|
||||
def list_diagnosis_doctors(self) -> list[dict[str, Any]]:
|
||||
return []
|
||||
|
||||
def list_prescriptions(self, **_filters: Any) -> dict[str, Any]:
|
||||
return {"lists": rows, "count": len(rows)}
|
||||
|
||||
def get_prescription(self, prescription_id: int) -> dict[str, Any]:
|
||||
requested.append(prescription_id)
|
||||
return {
|
||||
**next(row for row in rows if row["id"] == prescription_id),
|
||||
"clinical_diagnosis": "脾气虚",
|
||||
}
|
||||
|
||||
page = PrescriptionsPage(
|
||||
Repository(),
|
||||
PermissionSet(["cf.prescription/edit"]),
|
||||
SimpleNamespace(id=7, name="周医生"),
|
||||
)
|
||||
page.refresh()
|
||||
page._open_editor = lambda detail: opened.append(detail) # type: ignore[method-assign]
|
||||
|
||||
assert page.table.current_data()["id"] == 11
|
||||
assert all(
|
||||
page.table.item(row_index, 0).checkState() == Qt.CheckState.Unchecked
|
||||
for row_index in range(page.table.rowCount())
|
||||
)
|
||||
second_actions = page.table.cellWidget(1, 2)
|
||||
assert second_actions is not None
|
||||
second_edit = next(
|
||||
button
|
||||
for button in second_actions.findChildren(QPushButton)
|
||||
if button.accessibleName() == "编辑处方"
|
||||
)
|
||||
|
||||
second_edit.click()
|
||||
application.processEvents()
|
||||
|
||||
assert requested == [22]
|
||||
assert [detail["id"] for detail in opened] == [22]
|
||||
assert page.table.current_data()["id"] == 22
|
||||
assert all(
|
||||
page.table.item(row_index, 0).checkState() == Qt.CheckState.Unchecked
|
||||
for row_index in range(page.table.rowCount())
|
||||
)
|
||||
|
||||
page._run_row_action({"id": 999}, lambda: callbacks.append("stale"))
|
||||
assert callbacks == []
|
||||
page._set_mutation_pending(True)
|
||||
assert not second_edit.isEnabled()
|
||||
page._set_mutation_pending(False)
|
||||
assert second_edit.isEnabled()
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_editor_builds_complete_add_payload(
|
||||
application: QApplication,
|
||||
immediate_async: None,
|
||||
|
||||
Reference in New Issue
Block a user