Add PHPUnit test suite, Gitea CI, and fix broken URL pattern
All checks were successful
CI / test (push) Successful in 1m41s

- Add 22 unit tests covering feed parsing, thread rendering, facets,
  needsRefetch staleness windows, and handleConfigureAction
- Add FreshRSS class stubs so tests run without a full FreshRSS install
- Add RSS feed fixture (hockeyviz.com snapshot) and thread API fixture
  for post 3mhtk7awhrp26 (1 root + 2 replies)
- Add Gitea Actions workflow (.gitea/workflows/ci.yml) running on PHP 8.2
- Fix POST_URL_PATTERN: using '#' as PCRE delimiter with '#' inside a
  character class caused PHP to close the pattern early, so no Bluesky
  URL ever matched; switch delimiter to '~'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-26 15:41:07 -03:00
parent ac3b584d66
commit 932d7a5f0e
11 changed files with 2443 additions and 1 deletions

107
tests/fixtures/hockeyviz_feed.xml vendored Normal file
View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Snapshot of https://bsky.app/profile/did:plc:d4324t32vfi5xzydqbh2qdj3/rss fetched 2026-03-26 -->
<rss version="2.0">
<channel>
<description>Math, hockey, viz, apocrypha</description>
<link>https://bsky.app/profile/hockeyviz.com</link>
<title>@hockeyviz.com - Micah McCurdy</title>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhxruphxfz2q</link>
<description>No possible eliminations or qualifications today, will be a few days lull I expect.</description>
<pubDate>26 Mar 2026 14:11 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhxruphxfz2q</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhxnes7zvw2k</link>
<description>Yesterday&#x27;s games:</description>
<pubDate>26 Mar 2026 12:50 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhxnes7zvw2k</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhxidqqzwc26</link>
<description>The New York Rangers are the second team to be eliminated from playoff contention.</description>
<pubDate>26 Mar 2026 11:20 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhxidqqzwc26</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhw7rraxo72t</link>
<description>The site being so old is weird to me now because the old charts are annoying to me spiritually.</description>
<pubDate>25 Mar 2026 23:14 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhw7rraxo72t</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhvymqtksm2l</link>
<pubDate>25 Mar 2026 21:06 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhvymqtksm2l</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhvo7humyx2j</link>
<description>hockey viz dot com snubbed again&#xA;&#xA;[contains quote post or other embedded content]</description>
<pubDate>25 Mar 2026 18:00 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhvo7humyx2j</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhv7532iwp2p</link>
<description>If Toronto beat New York tonight in any fashion, then the Rangers will be eliminated from playoff contention.</description>
<pubDate>25 Mar 2026 13:30 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhv7532iwp2p</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhuuvbngrc2g</link>
<description>Yesterday&#x27;s games:</description>
<pubDate>25 Mar 2026 10:27 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhuuvbngrc2g</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhtt6lqhsk2b</link>
<description>Moms in the crowd smiling when their kids score their first goal &gt;&gt;&gt;</description>
<pubDate>25 Mar 2026 00:24 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhtt6lqhsk2b</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhtq6pbhwn2p</link>
<description>Little-known HockeyViz feature that&#x27;s fun on nights with lots of games.</description>
<pubDate>24 Mar 2026 23:30 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhtq6pbhwn2p</guid>
</item>
<!-- This is the thread post with 2 replies used in rendering tests -->
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhtk7awhrp26</link>
<description>Discussion about Gold Drafting always focusses on tanking, but really eliminating tanking discourse is a (very real) side-benefit.&#xA;&#xA;[contains quote post or other embedded content]</description>
<pubDate>24 Mar 2026 21:43 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhtk7awhrp26</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhtjo3rtkn26</link>
<description>The NHL, and many other leagues, would be improved by adopting Gold drafting. #GoldRace</description>
<pubDate>24 Mar 2026 21:33 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhtjo3rtkn26</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhpqxoumjl2b</link>
<description>The Vancouver Canucks are the first team to be eliminated from playoff contention this season.</description>
<pubDate>23 Mar 2026 09:33 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhpqxoumjl2b</guid>
</item>
<item>
<link>https://bsky.app/profile/hockeyviz.com/post/3mhpqwxte4n2l</link>
<description>The Dallas Stars are the second team to qualify for the 2025-2026 playoffs.</description>
<pubDate>23 Mar 2026 09:33 +0000</pubDate>
<guid isPermaLink="false">at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhpqwxte4n2l</guid>
</item>
</channel>
</rss>

View File

@@ -0,0 +1,91 @@
{
"thread": {
"$type": "app.bsky.feed.defs#threadViewPost",
"post": {
"uri": "at://did:plc:d4324t32vfi5xzydqbh2qdj3/app.bsky.feed.post/3mhtk7awhrp26",
"cid": "bafyreicfake1",
"author": {
"did": "did:plc:d4324t32vfi5xzydqbh2qdj3",
"handle": "hockeyviz.com",
"displayName": "Micah McCurdy",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:d4324t32vfi5xzydqbh2qdj3/bafkreifake1@jpeg"
},
"record": {
"$type": "app.bsky.feed.post",
"text": "Discussion about Gold Drafting always focusses on tanking, but really eliminating tanking discourse is a (very real) side-benefit. The primary benefit is that fans of bad teams get to enjoy the few late-season wins that they get, without having to add any games to the schedule.",
"createdAt": "2026-03-24T21:43:00.000Z",
"facets": []
},
"embed": {
"$type": "app.bsky.embed.record#view",
"record": {
"$type": "app.bsky.embed.record#viewRecord",
"uri": "at://did:plc:otherfake/app.bsky.feed.post/3mhtjo3rtkn26",
"author": {
"handle": "hockeyviz.com",
"displayName": "Micah McCurdy"
},
"value": {
"text": "The NHL, and many other leagues, would be improved by adopting Gold drafting, which makes the existing schedule more exciting for fans, eliminates tanking discourse, and gives the best draft picks (on average) to the weakest teams, who need them the most. This is the 2025-2026 thread. #GoldRace",
"facets": []
},
"embeds": []
}
},
"replyCount": 2,
"repostCount": 4,
"likeCount": 31,
"indexedAt": "2026-03-24T21:43:01.000Z"
},
"replies": [
{
"$type": "app.bsky.feed.defs#threadViewPost",
"post": {
"uri": "at://did:plc:replier1fake/app.bsky.feed.post/3mhtreplyone",
"cid": "bafyreicfake2",
"author": {
"did": "did:plc:replier1fake",
"handle": "example.bsky.social",
"displayName": "Reply Person One",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:replier1fake/bafkreifake2@jpeg"
},
"record": {
"$type": "app.bsky.feed.post",
"text": "Great point about the side benefits! The tanking argument always dominates but you're right that it's secondary.",
"createdAt": "2026-03-24T21:55:00.000Z",
"facets": []
},
"replyCount": 0,
"repostCount": 1,
"likeCount": 5,
"indexedAt": "2026-03-24T21:55:01.000Z"
},
"replies": []
},
{
"$type": "app.bsky.feed.defs#threadViewPost",
"post": {
"uri": "at://did:plc:replier2fake/app.bsky.feed.post/3mhtreplytwo",
"cid": "bafyreicfake3",
"author": {
"did": "did:plc:replier2fake",
"handle": "hockeyfan.bsky.social",
"displayName": "Hockey Fan",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:replier2fake/bafkreifake3@jpeg"
},
"record": {
"$type": "app.bsky.feed.post",
"text": "The fan experience angle is so underrated. Late-season games for bad teams actually matter under Gold.",
"createdAt": "2026-03-24T22:10:00.000Z",
"facets": []
},
"replyCount": 0,
"repostCount": 0,
"likeCount": 3,
"indexedAt": "2026-03-24T22:10:01.000Z"
},
"replies": []
}
]
}
}