mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-10-02 22:43:22 +00:00
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
|
|
"""Tests for the App Home tab (about page + What's New)."""
|
||
|
|
|
||
|
|
from shared.blocks import build_home_view
|
||
|
|
|
||
|
|
|
||
|
|
def _headers(view):
|
||
|
|
return [b["text"]["text"] for b in view["blocks"] if b["type"] == "header"]
|
||
|
|
|
||
|
|
|
||
|
|
class TestBuildHomeView:
|
||
|
|
def test_includes_about_and_commands(self):
|
||
|
|
view = build_home_view()
|
||
|
|
assert view["type"] == "home"
|
||
|
|
assert "After-Hours Shift Manager" in _headers(view)
|
||
|
|
assert "/oncall" in str(view["blocks"])
|
||
|
|
|
||
|
|
def test_omits_whats_new_without_version(self):
|
||
|
|
view = build_home_view()
|
||
|
|
assert all("What's New" not in h for h in _headers(view))
|
||
|
|
|
||
|
|
def test_includes_whats_new_with_version(self):
|
||
|
|
view = build_home_view(
|
||
|
|
"1.10.0", "**Self-announcing** releases.", "June 11, 2026"
|
||
|
|
)
|
||
|
|
assert "What's New in v1.10.0" in _headers(view)
|
||
|
|
# Notes are converted from Markdown to Slack mrkdwn.
|
||
|
|
assert "*Self-announcing*" in str(view["blocks"])
|
||
|
|
assert any(b.get("type") == "context" for b in view["blocks"])
|
||
|
|
|
||
|
|
|
||
|
|
def test_publish_home_publishes_latest_entry(slackbot_app, client):
|
||
|
|
text = "## v1.10.0 — June 11, 2026\n\n**New stuff.**\n\n## v1.9.2 — June 1, 2026\n\nOld.\n"
|
||
|
|
slackbot_app.publish_home(client, "U_ALICE", text)
|
||
|
|
|
||
|
|
client.views_publish.assert_called_once()
|
||
|
|
kwargs = client.views_publish.call_args.kwargs
|
||
|
|
assert kwargs["user_id"] == "U_ALICE"
|
||
|
|
assert kwargs["view"]["type"] == "home"
|
||
|
|
assert "What's New in v1.10.0" in str(kwargs["view"])
|
||
|
|
assert "v1.9.2" not in str(kwargs["view"]) # only the newest entry
|
||
|
|
|
||
|
|
|
||
|
|
def test_publish_home_degrades_without_changelog(slackbot_app, client):
|
||
|
|
slackbot_app.publish_home(client, "U_BOB", "")
|
||
|
|
view = client.views_publish.call_args.kwargs["view"]
|
||
|
|
assert all("What's New" not in str(b) for b in view["blocks"])
|