Rebuild workspace widgets and behavioral graph views

This commit is contained in:
2026-03-13 16:48:24 +00:00
parent f8a6d1d41c
commit 57269770b5
47 changed files with 2951 additions and 1077 deletions

View File

@@ -7,6 +7,7 @@ from django.test import TestCase
from django.urls import reverse
from core.models import ChatSession, Message, Person, PersonIdentifier, User
from core.views.compose import COMPOSE_ASSET_VERSION
class ComposeSendCapabilityTests(TestCase):
@@ -77,11 +78,26 @@ class ComposeSendCapabilityTests(TestCase):
self.assertEqual(200, response.status_code)
content = response.content.decode("utf-8")
self.assertIn("compose-panel.css", content)
self.assertIn("compose-panel-core.js", content)
self.assertIn("compose-panel-thread.js", content)
self.assertIn("compose-panel-send.js", content)
self.assertIn("compose-panel.js", content)
self.assertIn(
f"/static/css/compose-panel.css?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel-core.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel-thread.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel-send.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertNotIn("const initialTyping = JSON.parse(", content)
self.assertNotIn("data-drafts-url=", content)
self.assertNotIn("data-summary-url=", content)
@@ -104,14 +120,43 @@ class ComposeSendCapabilityTests(TestCase):
self.assertEqual(200, response.status_code)
content = response.content.decode("utf-8")
self.assertIn("data-gia-style-hrefs=", content)
self.assertIn("/static/css/compose-panel.css", content)
self.assertIn(
f"/static/css/compose-panel.css?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn("data-gia-script-srcs=", content)
self.assertIn("/static/js/compose-panel-core.js", content)
self.assertIn("/static/js/compose-panel-thread.js", content)
self.assertIn("/static/js/compose-panel-send.js", content)
self.assertIn("/static/js/compose-panel.js", content)
self.assertIn(
f"/static/js/compose-panel-core.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel-thread.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel-send.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn(
f"/static/js/compose-panel.js?v={COMPOSE_ASSET_VERSION}",
content,
)
self.assertIn('gs-id="widget-compose-widget-', content)
self.assertNotIn("<script defer src=\"/static/js/compose-panel.js\">", content)
self.assertNotIn("<link rel=\"stylesheet\" href=\"/static/css/compose-panel.css\">", content)
self.assertNotIn('data-gia-action="lock"', content)
self.assertIn('data-gia-action="snap-top"', content)
self.assertIn('data-gia-action="snap-bottom"', content)
def test_compose_workspace_history_widget_uses_shared_shell(self):
response = self.client.get(reverse("compose_workspace_history_widget"))
self.assertEqual(200, response.status_code)
content = response.content.decode("utf-8")
self.assertIn('gs-id="widget-compose-workspace-history"', content)
self.assertNotIn('data-gia-action="lock"', content)
self.assertIn('data-gia-action="snap-top"', content)
self.assertIn('data-gia-action="snap-bottom"', content)
def test_compose_contacts_dropdown_includes_workspace_link(self):
response = self.client.get(reverse("compose_contacts_dropdown"))
@@ -119,6 +164,11 @@ class ComposeSendCapabilityTests(TestCase):
self.assertEqual(200, response.status_code)
self.assertContains(response, reverse("compose_workspace"))
def test_removed_compose_quick_insights_endpoint_returns_404(self):
response = self.client.get("/compose/quick-insights/")
self.assertEqual(404, response.status_code)
@patch("core.views.compose._recent_manual_contacts")
def test_compose_contact_options_use_compact_service_map(self, mocked_recent_contacts):
mocked_recent_contacts.return_value = [
@@ -196,6 +246,57 @@ class ComposeSendCapabilityTests(TestCase):
self.assertIn("compose-row", str(payload.get("messages_html") or ""))
self.assertIn("Rendered thread row", str(payload.get("messages_html") or ""))
def test_compose_thread_before_ts_returns_older_window(self):
person = Person.objects.create(user=self.user, name="Older Contact")
identifier = PersonIdentifier.objects.create(
user=self.user,
person=person,
service="signal",
identifier="+15550001111",
)
session = ChatSession.objects.create(user=self.user, identifier=identifier)
oldest = Message.objects.create(
user=self.user,
session=session,
sender_uuid="contact",
text="Oldest message",
ts=1710000000000,
custom_author="CONTACT",
)
middle = Message.objects.create(
user=self.user,
session=session,
sender_uuid="contact",
text="Middle message",
ts=1710000001000,
custom_author="CONTACT",
)
Message.objects.create(
user=self.user,
session=session,
sender_uuid="contact",
text="Newest message",
ts=1710000002000,
custom_author="CONTACT",
)
response = self.client.get(
reverse("compose_thread"),
{
"service": "signal",
"identifier": "+15550001111",
"before_ts": middle.ts,
},
)
self.assertEqual(200, response.status_code)
payload = response.json()
html = str(payload.get("messages_html") or "")
self.assertIn("Oldest message", html)
self.assertNotIn("Middle message", html)
self.assertFalse(payload.get("has_older"))
self.assertEqual(str(oldest.ts), str(payload["messages"][0]["ts"]))
def test_compose_thread_payload_renders_reply_link_text_server_side(self):
person = Person.objects.create(user=self.user, name="Reply Contact")
identifier = PersonIdentifier.objects.create(