Reimplement compose and add tiling windows
This commit is contained in:
@@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, patch
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from core.models import User
|
||||
from core.models import ChatSession, Message, Person, PersonIdentifier, User
|
||||
|
||||
|
||||
class ComposeSendCapabilityTests(TestCase):
|
||||
@@ -78,6 +78,9 @@ 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.assertNotIn("const initialTyping = JSON.parse(", content)
|
||||
self.assertNotIn("data-drafts-url=", content)
|
||||
@@ -89,6 +92,33 @@ class ComposeSendCapabilityTests(TestCase):
|
||||
self.assertNotIn("compose-ticks", content)
|
||||
self.assertNotIn("compose-receipt-modal", content)
|
||||
|
||||
def test_compose_widget_declares_compose_assets_on_widget_shell(self):
|
||||
response = self.client.get(
|
||||
reverse("compose_widget"),
|
||||
{
|
||||
"service": "signal",
|
||||
"identifier": "+15551230000",
|
||||
},
|
||||
)
|
||||
|
||||
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("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.assertNotIn("<script defer src=\"/static/js/compose-panel.js\">", content)
|
||||
self.assertNotIn("<link rel=\"stylesheet\" href=\"/static/css/compose-panel.css\">", content)
|
||||
|
||||
def test_compose_contacts_dropdown_includes_workspace_link(self):
|
||||
response = self.client.get(reverse("compose_contacts_dropdown"))
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertContains(response, reverse("compose_workspace"))
|
||||
|
||||
@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 = [
|
||||
@@ -129,6 +159,80 @@ class ComposeSendCapabilityTests(TestCase):
|
||||
self.assertEqual(200, response.status_code)
|
||||
payload = response.json()
|
||||
self.assertIn("messages", payload)
|
||||
self.assertIn("messages_html", payload)
|
||||
self.assertIn("typing", payload)
|
||||
self.assertNotIn("availability_slices", payload)
|
||||
self.assertNotIn("availability_summary", payload)
|
||||
|
||||
def test_compose_thread_payload_includes_rendered_message_rows(self):
|
||||
person = Person.objects.create(user=self.user, name="Rendered Contact")
|
||||
identifier = PersonIdentifier.objects.create(
|
||||
user=self.user,
|
||||
person=person,
|
||||
service="signal",
|
||||
identifier="+15551230000",
|
||||
)
|
||||
session = ChatSession.objects.create(user=self.user, identifier=identifier)
|
||||
Message.objects.create(
|
||||
user=self.user,
|
||||
session=session,
|
||||
sender_uuid="contact",
|
||||
text="Rendered thread row",
|
||||
ts=1710000000000,
|
||||
custom_author="CONTACT",
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("compose_thread"),
|
||||
{
|
||||
"service": "signal",
|
||||
"identifier": "+15551230000",
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
payload = response.json()
|
||||
self.assertIsInstance(payload.get("messages_html"), str)
|
||||
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_payload_renders_reply_link_text_server_side(self):
|
||||
person = Person.objects.create(user=self.user, name="Reply Contact")
|
||||
identifier = PersonIdentifier.objects.create(
|
||||
user=self.user,
|
||||
person=person,
|
||||
service="signal",
|
||||
identifier="+15551239999",
|
||||
)
|
||||
session = ChatSession.objects.create(user=self.user, identifier=identifier)
|
||||
anchor = Message.objects.create(
|
||||
user=self.user,
|
||||
session=session,
|
||||
sender_uuid="contact",
|
||||
text="Anchor message for reply preview",
|
||||
ts=1710000000000,
|
||||
custom_author="CONTACT",
|
||||
)
|
||||
Message.objects.create(
|
||||
user=self.user,
|
||||
session=session,
|
||||
sender_uuid="self",
|
||||
text="Reply message",
|
||||
ts=1710000001000,
|
||||
custom_author="USER",
|
||||
reply_to=anchor,
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("compose_thread"),
|
||||
{
|
||||
"service": "signal",
|
||||
"identifier": "+15551239999",
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
payload = response.json()
|
||||
html = str(payload.get("messages_html") or "")
|
||||
self.assertIn("Reply to: Anchor message for reply preview", html)
|
||||
self.assertNotIn("data-reply-preview=", html)
|
||||
|
||||
Reference in New Issue
Block a user