This repository was archived by the owner on Jan 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo_tests
More file actions
28 lines (22 loc) · 2.41 KB
/
todo_tests
File metadata and controls
28 lines (22 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Надо написать тесты для проекта. Вот примерный план:
**Backend:**
4. **WebSocket Event Tests (using Flask-SocketIO test client):**
* Test the `join` event (`joinChatRoom`): Simulate a client joining, verify server-side state (e.g., user added to room), and check if `user_joined` (`socket.on("user_joined")`) is broadcast correctly.
* Test the `send_message` event (`sendMessage`): Simulate sending a message, verify it's saved to the database (`ChatMessage`), and check if it's broadcast to the correct room.
* Test the `update_username` event (`updateUsername`): Simulate a username update, verify the change in the database (`User`), and check for any related broadcasts.
* Test disconnection handling: Simulate a client disconnecting and verify that `user_left` (`socket.on("user_left")`) is broadcast.
**Frontend (JavaScript - potentially using Jest, Cypress, or similar in tests or a dedicated frontend test folder):**
1. **WebSocket Connection & Chat Join:**
* Verify that the socket connects successfully on page load (`socket.on('connect')`).
* Ensure the `join` event is emitted with the correct `chatId` when the chat page loads (`joinChatRoom`).
2. **Message Handling:**
* Test `loadPreviousMessages` to ensure it fetches and displays messages from the API correctly.
* Test `sendMessage`: Mock the socket emit, verify the input is cleared, and the correct data is sent.
* Test receiving messages: Mock incoming `message` events and verify they are added to the chat display (`addMessage`).
* Test receiving system messages (`user_joined`, `user_left`) and verify they are displayed correctly (`addMessage`).
3. **UI Interaction:**
* Test clicking the send button triggers `sendMessage`.
* Test pressing Enter in the message input triggers `sendMessage`.
* Test the username update functionality (`updateUsername`).
Consider starting with unit tests for backend logic (models, helpers) and then adding integration tests for API endpoints and WebSocket events. For the frontend, component tests or end-to-end tests using a tool like Cypress can cover user interactions and WebSocket communication effectively.
Надо написать CI/CD pipeline для автоматизации тестирования и деплоя. Добавить pre-commit который будет форматировать/линтить код