From b10a3afb80b3477d9df91357b90bb949ac168f52 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 19 Feb 2024 17:09:22 +0100 Subject: Only reset foreground color in with_color function The with_color helper is usually used to set only the foreground color (currently all usages), so by only reseting the foreground we keep any existing background color. This fixes the default background on the current buffer in the buflist for muted conversations. --- tests/conftest.py | 2 +- tests/test_render_attachments.py | 14 +++++++------- tests/test_render_blocks.py | 6 +++--- tests/test_render_reactions.py | 14 +++++++------- tests/test_unfurl.py | 10 +++++----- 5 files changed, 23 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index cda1833..e86afaa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -144,7 +144,7 @@ shared.standard_emojis = load_standard_emojis() color_channel_mention = "<[color:<[config_color:channel_mention]>]>" color_user_mention = "<[color:<[config_color:user_mention]>]>" color_usergroup_mention = "<[color:<[config_color:usergroup_mention]>]>" -color_reset = "<[color:reset]>" +color_default = "<[color:default]>" workspace_id = "T0FC8BFQR" diff --git a/tests/test_render_attachments.py b/tests/test_render_attachments.py index 9e47449..3718427 100644 --- a/tests/test_render_attachments.py +++ b/tests/test_render_attachments.py @@ -8,7 +8,7 @@ from slack.shared import shared from slack.slack_message import SlackMessage from tests.conftest import ( channel_public_id, - color_reset, + color_default, color_user_mention, resolve_pending_message_item, user_test1_id, @@ -425,7 +425,7 @@ cases: List[Case] = [ "input_text_before": "", "output": "\n".join( [ - "<[color:16711680]>|<[color:reset]> Title", + f"<[color:16711680]>|{color_default} Title", ] ), }, @@ -441,7 +441,7 @@ cases: List[Case] = [ "input_text_before": "", "output": "\n".join( [ - "<[color:16711680]>|<[color:reset]> Title", + f"<[color:16711680]>|{color_default} Title", ] ), }, @@ -560,13 +560,13 @@ cases: List[Case] = [ "| text & ", "| (https://image.url/?x=&z=z)", "| field title & : field value & ", - f"| field title mention <@{user_test1_id}>: field value mention {color_user_mention}@Test_1{color_reset}", + f"| field title mention <@{user_test1_id}>: field value mention {color_user_mention}@Test_1{color_default}", "| footer & | Oct 16, 2023", "| ```", "| block rich_text_preformatted & ", "| ```", "| block rich_text_section & `https://block.link?x=&z=z`", - f"| {color_user_mention}@Test_1{color_reset}: <@ASD>", + f"| {color_user_mention}@Test_1{color_default}: <@ASD>", ] ), }, @@ -595,7 +595,7 @@ cases: List[Case] = [ [ "| (https://from.url)", "| Author name: text", - "| Posted in <[color:chat_channel]>#channel1<[color:reset]> | Oct 15, 2023", + f"| Posted in <[color:chat_channel]>#channel1{color_default} | Oct 15, 2023", ] ), }, @@ -625,7 +625,7 @@ cases: List[Case] = [ [ "| (https://from.url)", "| Author name: text", - "| From a thread in <[color:chat_channel]>#channel1<[color:reset]> | Oct 15, 2023", + f"| From a thread in <[color:chat_channel]>#channel1{color_default} | Oct 15, 2023", ] ), }, diff --git a/tests/test_render_blocks.py b/tests/test_render_blocks.py index 63e4df5..fb61199 100644 --- a/tests/test_render_blocks.py +++ b/tests/test_render_blocks.py @@ -7,7 +7,7 @@ import pytest from slack.shared import shared from slack.slack_message import SlackMessage from tests.conftest import ( - color_reset, + color_default, color_user_mention, resolve_pending_message_item, user_test1_id, @@ -139,7 +139,7 @@ cases: List[Case] = [ "block code", "more code", "```", - f"{color_user_mention}@Test_1{color_reset}: 😮", + f"{color_user_mention}@Test_1{color_default}: 😮", ], }, { @@ -442,7 +442,7 @@ cases: List[Case] = [ ], } ], - "rendered": ["#FFAA00 <[color:16755200]>■<[color:reset]>"], + "rendered": [f"#FFAA00 <[color:16755200]>■{color_default}"], }, ] diff --git a/tests/test_render_reactions.py b/tests/test_render_reactions.py index dad9696..108c600 100644 --- a/tests/test_render_reactions.py +++ b/tests/test_render_reactions.py @@ -7,7 +7,7 @@ import pytest from slack.shared import shared from slack.slack_message import SlackMessage from tests.conftest import ( - color_reset, + color_default, user_test1_id, user_test2_id, ) @@ -31,32 +31,32 @@ color_reaction_self_suffix = "<[color:<[config_color:reaction_self_suffix]>]>" cases: List[Case] = [ { "reactions": [{"name": "custom", "users": [user_test2_id], "count": 1}], - "rendered": f" {color_reaction_suffix}[:custom:1]{color_reset}", + "rendered": f" {color_reaction_suffix}[:custom:1]{color_default}", "display_reaction_nicks": False, }, { "reactions": [{"name": "custom", "users": [user_test1_id], "count": 1}], - "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1{color_reaction_suffix}]{color_reset}", + "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1{color_reaction_suffix}]{color_default}", "display_reaction_nicks": False, }, { "reactions": [{"name": "custom", "users": [user_test2_id], "count": 1}], - "rendered": f" {color_reaction_suffix}[:custom:1(Test_2)]{color_reset}", + "rendered": f" {color_reaction_suffix}[:custom:1(Test_2)]{color_default}", "display_reaction_nicks": True, }, { "reactions": [{"name": "custom", "users": [user_test1_id], "count": 1}], - "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1(Test_1){color_reaction_suffix}]{color_reset}", + "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1(Test_1){color_reaction_suffix}]{color_default}", "display_reaction_nicks": True, }, { "reactions": [{"name": "custom", "users": [user_test2_id], "count": 2}], - "rendered": f" {color_reaction_suffix}[:custom:2]{color_reset}", + "rendered": f" {color_reaction_suffix}[:custom:2]{color_default}", "display_reaction_nicks": False, }, { "reactions": [{"name": "custom", "users": [user_test2_id], "count": 2}], - "rendered": f" {color_reaction_suffix}[:custom:2(Test_2, and others)]{color_reset}", + "rendered": f" {color_reaction_suffix}[:custom:2(Test_2, and others)]{color_default}", "display_reaction_nicks": True, }, ] diff --git a/tests/test_unfurl.py b/tests/test_unfurl.py index aeb5e5a..15c7ad1 100644 --- a/tests/test_unfurl.py +++ b/tests/test_unfurl.py @@ -8,7 +8,7 @@ from slack.slack_message import SlackMessage from tests.conftest import ( channel_public_id, color_channel_mention, - color_reset, + color_default, color_user_mention, color_usergroup_mention, resolve_pending_message_item, @@ -33,19 +33,19 @@ cases: List[Case] = [ }, { "input": "", - "output": f"{color_usergroup_mention}@channel{color_reset}", + "output": f"{color_usergroup_mention}@channel{color_default}", }, { "input": "", - "output": f"{color_usergroup_mention}@here{color_reset}", + "output": f"{color_usergroup_mention}@here{color_default}", }, { "input": f"<@{user_test1_id}|@othernick>: foo", - "output": f"{color_user_mention}@Test_1{color_reset}: foo", + "output": f"{color_user_mention}@Test_1{color_default}: foo", }, { "input": f"foo <#{channel_public_id}|otherchannel> bar", - "output": f"foo {color_channel_mention}#channel1{color_reset} bar", + "output": f"foo {color_channel_mention}#channel1{color_default} bar", }, ] -- cgit