Skip to content

Commit

Permalink
[BUGFIX]: fix UserMultiSelectMenu resolution bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kigsmtua authored Feb 14, 2024
1 parent 045f0d6 commit ba37142
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions slackblocks/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,7 @@ def _resolve(self) -> Dict[str, Any]:
user_multi_select = self._attributes()
user_multi_select["action_id"] = self.action_id
if self.initial_users:
user_multi_select["initial_users"] = [
initial_option._resolve() for initial_option in self.initial_users
]
user_multi_select["initial_users"] = self.initial_users
if self.confirm:
user_multi_select["confirm"] = self.confirm._resolve()
if self.max_selected_items:
Expand Down
12 changes: 12 additions & 0 deletions test/samples/elements/multi_select_user_with_initial_users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "multi_users_select",
"action_id": "multi_users_select",
"initial_users": [
"U064B5H1309",
"U063JR973UP"
],
"placeholder": {
"type": "plain_text",
"text": "Select one or more users"
}
}
10 changes: 10 additions & 0 deletions test/unit/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ def test_multi_select_user() -> None:
multi_select_user
)

def test_multi_select_user_with_initial_users() -> None:
multi_select_user = UserMultiSelectMenu(
action_id="multi_users_select",
placeholder=Text("Select one or more users", type_=TextType.PLAINTEXT),
initial_users= ["U064B5H1309", "U063JR973UP"],
)
assert fetch_sample(path="test/samples/elements/multi_select_user_with_initial_users.json") == repr(
multi_select_user
)


def test_number_input_basic() -> None:
number_input = NumberInput(action_id="number_input", is_decimal_allowed=False)
Expand Down

0 comments on commit ba37142

Please sign in to comment.