aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-25 01:17:39 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2023-10-25 01:17:39 +0200
commit6b388cd9aea6b091e16bdd22d0a28d9f1931b284 (patch)
tree64c73dac45b8307372235731cf73527e5eaaab82 /_pytest
parentcf244bb2b9571b64bdd9b9e9ec3ac4e74a213190 (diff)
downloadwee-slack-6b388cd9aea6b091e16bdd22d0a28d9f1931b284.tar.gz
Correctly show reactions with more than 50 users
If a reaction has more than 50 users, the list of users will be cropped to just 50 users. This made the counts wrong since we used the number of users rather than the count property. Fix it by using the count property instead and adding "and others" to the list of users if show_reaction_nicks is enabled (the same as the Slack client shows when you hover over the reaction).
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/test_render_message.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/_pytest/test_render_message.py b/_pytest/test_render_message.py
index 12b654d..f336a05 100644
--- a/_pytest/test_render_message.py
+++ b/_pytest/test_render_message.py
@@ -91,6 +91,29 @@ import wee_slack
},
{
"input_message": {
+ "text": "test",
+ "reactions": [{"name": "custom", "users": ["U01E8P3JKM1"], "count": 2}],
+ },
+ "rendered": "test <[color darkgray]>[:custom:2]<[color reset]>",
+ },
+ {
+ "input_message": {
+ "text": "test",
+ "reactions": [{"name": "custom", "users": ["U407ABLLW"], "count": 1}],
+ },
+ "rendered": "test <[color darkgray]>[:custom:(@alice)]<[color reset]>",
+ "show_reaction_nicks": True,
+ },
+ {
+ "input_message": {
+ "text": "test",
+ "reactions": [{"name": "custom", "users": ["U407ABLLW"], "count": 2}],
+ },
+ "rendered": "test <[color darkgray]>[:custom:(@alice, and others)]<[color reset]>",
+ "show_reaction_nicks": True,
+ },
+ {
+ "input_message": {
"blocks": [
{
"type": "rich_text",
@@ -144,6 +167,7 @@ import wee_slack
def test_render_message(case, channel_general):
wee_slack.EMOJI, wee_slack.EMOJI_WITH_SKIN_TONES_REVERSE = wee_slack.load_emoji()
wee_slack.config.render_emoji_as_string = case.get("render_emoji_as_string")
+ wee_slack.config.show_reaction_nicks = case.get("show_reaction_nicks", False)
message_json = {"ts": str(wee_slack.SlackTS()), **case["input_message"]}
message = wee_slack.SlackMessage("normal", message_json, channel_general)
result = message.render()