mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-10-06 22:52:05 +00:00
fix(portal): address review feedback
This commit is contained in:
parent
17dcc0b264
commit
903b0f4985
3 changed files with 26 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ from shared.blocks import (
|
||||||
build_holiday_added_blocks,
|
build_holiday_added_blocks,
|
||||||
build_pickup_request_blocks,
|
build_pickup_request_blocks,
|
||||||
build_shift_change_message,
|
build_shift_change_message,
|
||||||
|
_mrkdwn_text,
|
||||||
build_swap_request_blocks,
|
build_swap_request_blocks,
|
||||||
build_week_schedule,
|
build_week_schedule,
|
||||||
)
|
)
|
||||||
|
|
@ -278,7 +279,7 @@ def dm_swap_request(
|
||||||
return False
|
return False
|
||||||
text = f"{requester_name} wants to swap you the {date_str} shift"
|
text = f"{requester_name} wants to swap you the {date_str} shift"
|
||||||
if note:
|
if note:
|
||||||
text += f"\nNote: {note}"
|
text += f"\nNote: {_mrkdwn_text(note)}"
|
||||||
return slack_call(
|
return slack_call(
|
||||||
"chat.postMessage",
|
"chat.postMessage",
|
||||||
token,
|
token,
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,29 @@ class TestBuildSwapRequestBlocks:
|
||||||
assert ids == ["swap_accept_2026-06-03", "swap_decline_2026-06-03"]
|
assert ids == ["swap_accept_2026-06-03", "swap_decline_2026-06-03"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_dm_swap_fallback_escapes_the_note(monkeypatch):
|
||||||
|
from shared import side_effects as effects
|
||||||
|
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_slack_call(_method, _token, **kwargs):
|
||||||
|
captured.update(kwargs)
|
||||||
|
return True
|
||||||
|
|
||||||
|
monkeypatch.setattr(effects, "slack_call", fake_slack_call)
|
||||||
|
assert effects.dm_swap_request(
|
||||||
|
"tok",
|
||||||
|
"U_REQ",
|
||||||
|
"U_TGT",
|
||||||
|
"2026-06-03",
|
||||||
|
"night",
|
||||||
|
"Alice",
|
||||||
|
note="ping <@U_ADMIN>",
|
||||||
|
)
|
||||||
|
assert "Note: ping <@U_ADMIN>" in captured["text"]
|
||||||
|
assert "<@U_ADMIN>" not in captured["text"]
|
||||||
|
|
||||||
|
|
||||||
class TestBuildSwapResolvedBlocks:
|
class TestBuildSwapResolvedBlocks:
|
||||||
def test_renders_text_no_buttons(self):
|
def test_renders_text_no_buttons(self):
|
||||||
blocks = build_swap_resolved_blocks("All done.")
|
blocks = build_swap_resolved_blocks("All done.")
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ def test_swap_rejects_non_string_note(schedule, seed, quiet_slack):
|
||||||
with pytest.raises(ActionError) as err:
|
with pytest.raises(ActionError) as err:
|
||||||
swap(schedule, employee, "2026-06-12", "115", "night", note=12)
|
swap(schedule, employee, "2026-06-12", "115", "night", note=12)
|
||||||
assert err.value.code == "INVALID_NOTE"
|
assert err.value.code == "INVALID_NOTE"
|
||||||
|
assert schedule.get_swap("2026-06-12", "night") is None
|
||||||
|
|
||||||
|
|
||||||
def test_late_pickup_creates_request(schedule, seed, quiet_slack):
|
def test_late_pickup_creates_request(schedule, seed, quiet_slack):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue