mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 06:33:12 +00:00
fix(menu): address review feedback
Use the form deadline in the Monday Slack post, and compare that message exactly so CodeQL does not treat the test as URL sanitization.
This commit is contained in:
parent
265d12b890
commit
5f4ca3e7ef
2 changed files with 8 additions and 7 deletions
|
|
@ -16,9 +16,6 @@ DEFAULT_DEADLINE = "Thursday at 11:59 PM"
|
||||||
FORM_BUCKET_PARAM = "/meal-order-manager/deploy/form-bucket"
|
FORM_BUCKET_PARAM = "/meal-order-manager/deploy/form-bucket"
|
||||||
DISTRIBUTION_ID_PARAM = "/meal-order-manager/deploy/distribution-id"
|
DISTRIBUTION_ID_PARAM = "/meal-order-manager/deploy/distribution-id"
|
||||||
|
|
||||||
# Same announcement the GitHub weekly-menu workflow posted.
|
|
||||||
_SLACK_TEXT = "This week's meal order is open! Deadline: Thursday 6pm."
|
|
||||||
|
|
||||||
|
|
||||||
def lambda_handler(event, context):
|
def lambda_handler(event, context):
|
||||||
del event, context
|
del event, context
|
||||||
|
|
@ -113,6 +110,7 @@ def _invalidate(distribution_id: str, week: str, scraped_at: str) -> None:
|
||||||
def _notify(form_url: str) -> None:
|
def _notify(form_url: str) -> None:
|
||||||
from shared.slack import post_channel_message
|
from shared.slack import post_channel_message
|
||||||
|
|
||||||
|
text = f"This week's meal order is open! Deadline: {DEFAULT_DEADLINE}."
|
||||||
blocks = [
|
blocks = [
|
||||||
{
|
{
|
||||||
"type": "header",
|
"type": "header",
|
||||||
|
|
@ -123,11 +121,11 @@ def _notify(form_url: str) -> None:
|
||||||
"text": {
|
"text": {
|
||||||
"type": "mrkdwn",
|
"type": "mrkdwn",
|
||||||
"text": (
|
"text": (
|
||||||
f"*<{form_url}|Place your order>*\n\n*Deadline:* Thursday 6pm\n"
|
f"*<{form_url}|Place your order>*\n\n*Deadline:* {DEFAULT_DEADLINE}\n"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
result = post_channel_message(_SLACK_TEXT, blocks)
|
result = post_channel_message(text, blocks)
|
||||||
if not result.get("ok"):
|
if not result.get("ok"):
|
||||||
raise RuntimeError(f"Slack API error: {result.get('error')}")
|
raise RuntimeError(f"Slack API error: {result.get('error')}")
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,11 @@ def test_publish_menu_uploads_after_the_menu_write(
|
||||||
assert invalidation["DistributionId"] == "E123"
|
assert invalidation["DistributionId"] == "E123"
|
||||||
assert invalidation["InvalidationBatch"]["Paths"]["Items"] == ["/index.html"]
|
assert invalidation["InvalidationBatch"]["Paths"]["Items"] == ["/index.html"]
|
||||||
mock_slack.assert_called_once()
|
mock_slack.assert_called_once()
|
||||||
assert (
|
assert mock_slack.call_args.args[0] == (
|
||||||
"https://orders.seahaven.com" in mock_slack.call_args.args[1][1]["text"]["text"]
|
"This week's meal order is open! Deadline: Thursday at 11:59 PM."
|
||||||
|
)
|
||||||
|
assert mock_slack.call_args.args[1][1]["text"]["text"] == (
|
||||||
|
f"*<{ENV['FORM_URL']}|Place your order>*\n\n*Deadline:* Thursday at 11:59 PM\n"
|
||||||
)
|
)
|
||||||
assert order == [
|
assert order == [
|
||||||
"menu",
|
"menu",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue