fix a few multisync issues
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
<span class="input-group-text bg-secondary text-white border-secondary">
|
||||
<i class="bi bi-search"></i>
|
||||
</span>
|
||||
<input type="text" id="multiuserCaseSearch" class="form-control bg-dark text-white border-secondary"
|
||||
<input type="text" id="multiuserCaseSearch" name="q" class="form-control bg-dark text-white border-secondary"
|
||||
placeholder="Search cases to load..."
|
||||
hx-get="{% url 'atlas:multiuser_search_cases' session_id=session.id %}"
|
||||
hx-trigger="input delay:300ms, focus"
|
||||
@@ -161,6 +161,7 @@
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
}
|
||||
window.logDebug = logDebug;
|
||||
|
||||
function clearDebugLogs() {
|
||||
const container = document.getElementById("syncDebugLogsContainer");
|
||||
@@ -264,12 +265,16 @@
|
||||
logDebug("Session WS event received (type=" + data.type + ")", data);
|
||||
|
||||
if (data.type === 'change_case') {
|
||||
{% if not is_manager %}
|
||||
logDebug("Session host changed case to " + data.case_id + ". Fetching new case via HTMX...");
|
||||
// Fetch new case content via HTMX
|
||||
htmx.ajax('GET', "{% url 'atlas:multiuser_case_content_partial' session_id=session.id %}", {
|
||||
target: "#multiuser-case-container",
|
||||
swap: "innerHTML"
|
||||
});
|
||||
{% else %}
|
||||
logDebug("Host ignored change_case broadcast to avoid double-swap");
|
||||
{% endif %}
|
||||
} else if (data.type === 'room_status') {
|
||||
// Update user count
|
||||
const userCount = Object.keys(data.users || {}).length;
|
||||
|
||||
@@ -129,8 +129,23 @@ def test_multiuser_load_case_action(client, make_case):
|
||||
|
||||
# Manager loads case
|
||||
client.force_login(manager)
|
||||
response = client.post(reverse("atlas:multiuser_load_case", kwargs={"session_id": session.id}), data={"case_id": case.pk})
|
||||
assert response.status_code == 200
|
||||
from unittest.mock import patch, MagicMock, AsyncMock
|
||||
with patch("channels.layers.get_channel_layer") as mock_get_channel_layer:
|
||||
mock_layer = MagicMock()
|
||||
mock_layer.group_send = AsyncMock()
|
||||
mock_get_channel_layer.return_value = mock_layer
|
||||
|
||||
response = client.post(reverse("atlas:multiuser_load_case", kwargs={"session_id": session.id}), data={"case_id": case.pk})
|
||||
assert response.status_code == 200
|
||||
|
||||
# Verify Channels group_send was called to notify the group about the case change
|
||||
mock_layer.group_send.assert_called_once_with(
|
||||
f"multiuser_{session.id}",
|
||||
{
|
||||
"type": "change_case",
|
||||
"case_id": case.id
|
||||
}
|
||||
)
|
||||
|
||||
session.refresh_from_db()
|
||||
assert session.active_case == case
|
||||
|
||||
Reference in New Issue
Block a user