Files
upstream-zulip/zerver/webhooks/groove/tests.py
upstream-mirror 64898b2c79
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

125 lines
4.4 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class GrooveHookTests(WebhookTestCase):
# This test simulates the condition when a new ticket comes.
def test_groove_ticket_started(self) -> None:
expected_topic_name = "notifications"
expected_message = """
Test Name submitted new ticket [#9: Test Subject](https://ghostfox.groovehq.com/groove_client/tickets/68659446):
``` quote
The content of the body goes here.
```
""".strip()
self.check_webhook(
"ticket_started",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket
# is assigned to an agent.
def test_groove_ticket_assigned_agent_only(self) -> None:
expected_topic_name = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com."
self.check_webhook(
"ticket_assigned__agent_only",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket
# is assigned to an agent in a group.
def test_groove_ticket_assigned_agent_and_group(self) -> None:
expected_topic_name = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com from group2."
self.check_webhook(
"ticket_assigned__agent_and_group",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket
# is assigned to a group.
def test_groove_ticket_assigned_group_only(self) -> None:
expected_topic_name = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (pending) assigned to group2."
self.check_webhook(
"ticket_assigned__group_only",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket
# is assigned to no one.
def test_groove_ticket_assigned_no_one(self) -> None:
self.subscribe(self.test_user, self.channel_name)
result = self.client_post(
self.url,
self.get_body("ticket_assigned__no_one"),
content_type="application/x-www-form-urlencoded",
HTTP_X_GROOVE_EVENT="ticket_assigned",
)
self.assert_json_success(result)
# This simulates the notification when an agent replied to a ticket.
def test_groove_agent_replied(self) -> None:
expected_topic_name = "notifications"
expected_message = """
agent@example.com replied to [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295):
``` quote
Hello , This is a reply from an agent to a ticket
```
""".strip()
self.check_webhook(
"agent_replied",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a customer replied to a ticket.
def test_groove_customer_replied(self) -> None:
expected_topic_name = "notifications"
expected_message = """
rambo@example.com replied to [ticket #440](https://ghostfox.groovehq.com/groove_client/tickets/68666538):
``` quote
Hello agent, thanks for getting back. This is how a reply from customer looks like.
```
""".strip()
self.check_webhook(
"customer_replied",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when an agent left a note.
def test_groove_note_added(self) -> None:
expected_topic_name = "notifications"
expected_message = """
anotheragent@example.com left a note on [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295):
``` quote
This is a note added to a ticket
```
""".strip()
self.check_webhook(
"note_added",
expected_topic_name,
expected_message,
content_type="application/x-ww-form-urlencoded",
)