49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
os.environ['QT_QPA_PLATFORM'] = 'offscreen'
|
|
sys.path.insert(0, 'C:/kefu/wechat_rpa')
|
|
import runtime_paths
|
|
profile = Path(__file__).parent / 'render-profile'
|
|
profile.mkdir(exist_ok=True)
|
|
with mock.patch.object(runtime_paths, 'application_data_dir', return_value=profile):
|
|
import wechat_gui_qt as qt
|
|
from PySide6.QtWidgets import QApplication
|
|
from PySide6.QtCore import Qt
|
|
app = QApplication([])
|
|
qt._register_bundled_fonts()
|
|
app.setStyle('Fusion')
|
|
app.setStyleSheet(qt.APP_QSS)
|
|
app.setFont(qt._ui_font(9))
|
|
account = '168800000000001'
|
|
with mock.patch.object(qt.QTimer, 'singleShot'):
|
|
dialog = qt.ReviewAssistantPicker(account, current_recipient_id='M:123456789')
|
|
dialog._serial = 1
|
|
rows = [
|
|
{'id': 'S:168800000000001_168800000001101', 'peer_id': '168800000001101',
|
|
'name': '张助理(门诊)', 'displayName': '张助理(门诊)', 'nameKnown': True,
|
|
'kind': '企业微信客户', 'selectable': True, 'lastTime': '2026-09-18 09:08'},
|
|
{'id': 'S:168800000001102_168800000000001', 'peer_id': '168800000001102',
|
|
'name': '李助理(夜班)', 'displayName': '李助理(夜班)', 'nameKnown': True,
|
|
'kind': '企业微信客户', 'selectable': True, 'lastTime': '2026-09-17 18:08'},
|
|
{'id': 'customer:168800000001103', 'peer_id': '168800000001103',
|
|
'name': '王助理', 'displayName': '王助理', 'nameKnown': True,
|
|
'kind': '我的客户', 'selectable': False, 'lastTime': '',
|
|
'unavailableReason': '尚无可发送的客户单聊,请建立单聊并刷新消息库。'},
|
|
]
|
|
dialog._loaded({'_serial': 1, 'ready': True, 'account_id': account, 'items': rows,
|
|
'total': 3, 'all_total': 3, 'all_selectable_total': 2,
|
|
'all_contact_total': 1, 'has_more': False})
|
|
dialog.show()
|
|
app.processEvents()
|
|
dialog.contacts.setCurrentRow(1)
|
|
app.processEvents()
|
|
assert dialog.choose.isEnabled()
|
|
assert '168800000001102' in dialog.details_identity.text()
|
|
assert dialog.filter_buttons['all'].isChecked()
|
|
assert dialog.grab().save(str(Path(__file__).parent / 'customer-picker-synthetic.png'))
|
|
dialog.reject()
|
|
dialog.deleteLater()
|
|
print('Rendered synthetic customer picker; no real contacts or sends.')
|