Refactor desktop client codebase

This commit is contained in:
Peter Stockings
2026-03-03 22:50:02 +11:00
parent de0a7172e7
commit bd43cd10f6
4 changed files with 647 additions and 602 deletions

View File

@@ -9,22 +9,22 @@ def test_app_ui_flow(qtbot):
# 1. Test Lobby View
assert app.stacked_widget.currentIndex() == 0
assert not app.create_room_btn.isEnabled()
assert not app.lobby_widget.create_room_btn.isEnabled()
# Fill out the Lobby Form
app.username_input.setText("PyTestUser")
app.lobby_widget.username_input.setText("PyTestUser")
# Mocking file selection instead of opening the native dialog
app.local_file_path = "test_pytest.mkv"
app.local_file_name = "test_pytest.mkv"
app.local_file_size = 1048576
app.check_inputs()
app.lobby_widget.local_file_path = "test_pytest.mkv"
app.lobby_widget.local_file_name = "test_pytest.mkv"
app.lobby_widget.local_file_size = 1048576
app.lobby_widget.check_inputs()
# Button should now be active
assert app.create_room_btn.isEnabled()
assert app.lobby_widget.create_room_btn.isEnabled()
# 2. Test Creating Room matches integration pipeline
qtbot.mouseClick(app.create_room_btn, Qt.MouseButton.LeftButton)
qtbot.mouseClick(app.lobby_widget.create_room_btn, Qt.MouseButton.LeftButton)
# Wait for the WebSocket connected signal, the room_created server response, and UI transition
def check_room_joined():
@@ -35,26 +35,26 @@ def test_app_ui_flow(qtbot):
# 3. Test Chat flow End-to-End
# Type a message
qtbot.keyClicks(app.chat_input, "Automated UI Test Message")
qtbot.keyClicks(app.room_widget.chat_input, "Automated UI Test Message")
# Click Send
qtbot.mouseClick(app.chat_send_btn, Qt.MouseButton.LeftButton)
qtbot.mouseClick(app.room_widget.chat_send_btn, Qt.MouseButton.LeftButton)
# Wait until the Bun server grabs the websocket payload, stores it, and broadcasts it back to the UI!
def check_chat_received():
assert "Automated UI Test Message" in app.chat_messages.text()
assert "Automated UI Test Message" in app.room_widget.chat_messages.toPlainText()
qtbot.waitUntil(check_chat_received, timeout=3000)
# 4. Test Playback Sync (UI updates and internal flags)
assert app.play_btn.text() == ""
assert app.room_widget.play_btn.text() == ""
# Click Play
qtbot.mouseClick(app.play_btn, Qt.MouseButton.LeftButton)
qtbot.mouseClick(app.room_widget.play_btn, Qt.MouseButton.LeftButton)
def check_playback_started():
assert app.play_btn.text() == ""
assert app.room_widget.play_btn.text() == ""
qtbot.waitUntil(check_playback_started, timeout=2000)
# Clean up background threads
app.leave_room()
app._on_room_leave()