2016-12-24 15:50:28 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2016-12-24 15:50:28 +01:00
|
|
|
class DelightedHookTests(WebhookTestCase):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "delighted"
|
2016-12-24 15:50:28 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/delighted?stream={stream}&api_key={api_key}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "delighted"
|
2016-12-24 15:50:28 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_feedback_message_promoter(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Survey response"
|
2019-04-12 05:10:20 +02:00
|
|
|
expected_message = """
|
|
|
|
Kudos! You have a new promoter. Score of 9/10 from charlie_gravis@example.com:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Your service is fast and flawless!
|
|
|
|
```
|
|
|
|
""".strip()
|
2016-12-24 15:50:28 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"survey_response_updated_promoter",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|
2016-12-24 15:50:28 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_feedback_message_non_promoter(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Survey response"
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message = (
|
|
|
|
"Great! You have new feedback.\n"
|
|
|
|
">Score of 5/10 from paul_gravis@example.com"
|
|
|
|
"\n>Your service is slow, but nearly flawless! "
|
|
|
|
"Keep up the good work!"
|
|
|
|
)
|
2019-04-12 05:10:20 +02:00
|
|
|
expected_message = """
|
|
|
|
Great! You have new feedback. Score of 5/10 from paul_gravis@example.com:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Your service is slow, but nearly flawless! Keep up the good work!
|
|
|
|
```
|
|
|
|
""".strip()
|
2016-12-24 15:50:28 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"survey_response_updated_non_promoter",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|