Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests added for feedback messages and common messages #93

Merged
merged 7 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/messages/test_common_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from fyle_slack_app.slack.ui import common_messages

class TestCommonMessages:

def test_get_custom_text_section_block(self):
MESSAGE = "Hi there, I am using fyle"
section_block = common_messages.get_custom_text_section_block(message=MESSAGE)
assert section_block[0]['text']['text'] == MESSAGE

def test_get_updated_approval_notification_message(self):
FAKE_NOTIFICATION_MESSAGES = [{
'type': 'section',
'text': {
'type': 'mrkdwn',
'text': 'Hey there'
}
},
{
'type': 'actions',
'text': {
'type': 'mrkdwn',
'text': 'Hey there'
}
}
]
FAKE_CUSTOM_MESSAGE = 'Hello World'
report_notification_message1 = common_messages.get_updated_approval_notification_message(FAKE_NOTIFICATION_MESSAGES, FAKE_CUSTOM_MESSAGE, True)
report_notification_message2 = common_messages.get_updated_approval_notification_message(FAKE_NOTIFICATION_MESSAGES, FAKE_CUSTOM_MESSAGE, False)
assert report_notification_message1[-1]['text']['text'] == FAKE_CUSTOM_MESSAGE
assert report_notification_message2[-1]['text']['text'] == FAKE_CUSTOM_MESSAGE

for notification_message in report_notification_message2:
if 'type' in notification_message:
assert notification_message['type'] != 'actions'
20 changes: 20 additions & 0 deletions tests/messages/test_feedback_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from fyle_slack_app.slack.ui import feedbacks

class TestFeedbackMessages:

def test_get_user_feedback_message(self):
feedback_trigger = 'fake_feedback_trigger'
feedback_message_blocks = feedbacks.messages.get_user_feedback_message(feedback_trigger)
assert feedback_message_blocks[1]['elements'][0]['value'] == feedback_trigger

def test_get_post_feedback_submission_message(self):
feedback_message_blocks = feedbacks.messages.get_post_feedback_submission_message()
assert feedback_message_blocks[0]['text']['text'] == 'Thanks for submitting the feedback :rainbow:'

def test_get_feedback_dialog(self):
private_metadata = 'fake_private_metadata'
feedback_dialog = feedbacks.messages.get_feedback_dialog(private_metadata)
feedback_rating_options = feedback_dialog['blocks'][2]['element']['options']
for rating in range(10):
assert feedback_rating_options[rating]['text']['text'] == '{} :star:'.format(rating+1)
assert feedback_rating_options[rating]['value'] == str(rating+1)