fix: improve maintenance and synchronize live conversations

This commit is contained in:
WangShen007 committed 2026-10-29 09:46:21 +08:00
1 parent bb541bd212
commit ef86a5d3af
297 files changed
+2983 -1274

No files matched your search

+33 -6
View File
@@ -27,13 +27,10 @@ from app.repositories.widget import WidgetRepository
from app.models.schemas.widget import WidgetCreate
from app.core.security import encrypt_api_key
from uuid import UUID, uuid4
from tests.conftest import engine, TestingSessionLocal, create_tables, Base
from app.models.session_to_agent import SessionStatus, SessionToAgent
from app.repositories.chat import ChatRepository
from app.models.workflow import Workflow
from app.models.workflow_node import WorkflowNode, NodeType
from app.models.workflow_connection import WorkflowConnection
from app.models.rating import Rating
import datetime
from socketio.exceptions import ConnectionRefusedError as SocketRefused
@@ -563,7 +560,7 @@ async def test_agent_message(db, test_widget, test_customer, test_user, mock_sio
# Create a test session
from app.repositories.session_to_agent import SessionToAgentRepository
session_repo = SessionToAgentRepository(db)
session = session_repo.create_session(
session_repo.create_session(
session_id=session_id,
agent_id=test_widget.agent_id,
customer_id=test_customer.id,
@@ -706,6 +703,36 @@ class TestUtilityFunctions:
assert validate_form_field(number_config, "101") == "Age must not exceed 100"
assert validate_form_field(number_config, "invalid") == "Age must be a valid number"
assert validate_form_field(number_config, "25") is None
# The client shares these accepted values: trim text/email input, reject
# parseFloat-only suffixes, and preserve numeric zero bounds and values.
assert validate_form_field(text_config, " A ") == "Name must be at least 2 characters"
assert validate_form_field(text_config, " AB ") is None
assert validate_form_field(
{"name": "name", "label": "Name", "type": "text", "minLength": 2}, "🙂"
) == "Name must be at least 2 characters"
assert validate_form_field(
{"name": "name", "label": "Name", "type": "text", "maxLength": 1}, "🙂"
) is None
assert validate_form_field(number_config, "12abc") == "Age must be a valid number"
assert validate_form_field(
{"name": "amount", "label": "Amount", "type": "number", "maxLength": 0}, "1"
) == "Amount must not exceed 0"
assert validate_form_field(
{"name": "amount", "label": "Amount", "type": "number", "maxLength": 0}, 0
) is None
assert validate_form_field(
{"name": "amount", "label": "Amount", "type": "number"}, "3."
) is None
assert validate_form_field(
{"name": "amount", "label": "Amount", "type": "number"}, "1.e3"
) is None
assert validate_form_field(
{
"name": "amount", "label": "Amount", "type": "number",
"minLength": None, "maxLength": None,
}, "-1"
) is None
def test_validate_form_data(self):
"""Test validate_form_data function"""
@@ -1563,7 +1590,7 @@ class TestComplexScenarios:
session_id = uuid4()
from app.repositories.session_to_agent import SessionToAgentRepository
session_repo = SessionToAgentRepository(db)
session = session_repo.create_session(
session_repo.create_session(
session_id=session_id,
agent_id=test_widget.agent_id,
customer_id=test_customer.id,
@@ -1621,7 +1648,7 @@ class TestComplexScenarios:
session_id = uuid4()
from app.repositories.session_to_agent import SessionToAgentRepository
session_repo = SessionToAgentRepository(db)
session = session_repo.create_session(
session_repo.create_session(
session_id=session_id,
agent_id=test_widget.agent_id,
customer_id=test_customer.id,