Skip to content

Commit 32e526e

Browse files
committed
Fix: Keep original text when mentee is claimed in mentors-intenral
1 parent f532dd4 commit 32e526e

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

pybot/endpoints/slack/message_templates/mentor_request.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def __init__(
178178
super().__init__(raw_action)
179179
self.slack = slack
180180
self.airtable = airtable
181+
self.text = raw_action["original_message"]["text"]
181182
self.attachment = raw_action["original_message"]["attachments"][0]
182183
self.should_update = True
183184

@@ -256,6 +257,7 @@ async def update_message(self):
256257
response = {
257258
"channel": self["channel"]["id"],
258259
"ts": self["message_ts"],
260+
"text": self.text,
259261
"attachments": self["original_message"]["attachments"],
260262
}
261263
await self.slack.query(methods.CHAT_UPDATE, response)

tests/test_slack_actions.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
async def test_claim_mentee_response_attachment_is_list(
66
action: dict, aiohttp_client, bot: SirBot
77
):
8+
client, slack_mock = await create_mocks(aiohttp_client, bot)
9+
10+
await client.post("/slack/actions", data=action)
11+
assert isinstance(slack_mock.call_args[0][1]["attachments"], list)
12+
13+
14+
async def test_claim_mentee_response_contains_original_text(
15+
action: dict, aiohttp_client, bot: SirBot
16+
):
17+
client, slack_mock = await create_mocks(aiohttp_client, bot)
18+
await client.post("/slack/actions", data=action)
19+
request_payload = slack_mock.call_args[0][1]
20+
assert request_payload["text"] is not None
21+
22+
23+
async def create_mocks(aiohttp_client, bot):
824
slack_mock = CoroutineMock(
925
return_value={"user": {"profile": {"email": "email@email.com"}}}
1026
)
@@ -14,7 +30,5 @@ async def test_claim_mentee_response_attachment_is_list(
1430
bot["plugins"]["airtable"].api.update_request = airtable_mock
1531
bot["plugins"]["airtable"].api.get_name_from_record_id = airtable_mock
1632
bot["plugins"]["airtable"].api.get_row_from_record_id = airtable_mock
17-
1833
client = await aiohttp_client(bot)
19-
await client.post("/slack/actions", data=action)
20-
assert isinstance(slack_mock.call_args[0][1]["attachments"], list)
34+
return client, slack_mock

0 commit comments

Comments
 (0)