fix(subscribestar): initial feed GET is a navigation, not XHR (first-run drift)
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 33s
CI / integration (push) Successful in 3m14s

First live run (cheunart) tripped the drift guard: "no posts and no recognizable
feed container". The browser-saved page was normal (6 posts + posts_container-list),
so the parser was fine — our live HTTP fetch got a different response. Cause: the
client set X-Requested-With: XMLHttpRequest (+ a JSON Accept) session-wide, so the
initial creator-page GET was sent as an XHR. SubscribeStar (Rails) content-
negotiates an XHR full-page request to a non-HTML body → no container → drift.

Fix: the session now uses browser-like navigation headers (Accept: html, NO
X-Requested-With); the XHR header + JSON Accept are applied PER-REQUEST only on
the "load more" endpoint (which is a genuine XHR). Drift message now reports the
response length + a JSON hint so a recurrence is self-explaining. Regression test
pins the header split (navigation initial GET, XHR load-more).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 14:25:40 -04:00
parent d526447496
commit 78a3977f8a
2 changed files with 52 additions and 11 deletions
+27
View File
@@ -77,6 +77,33 @@ def test_parse_ss_datetime_variants():
assert _parse_ss_datetime("nonsense") is None
# -- client: request headers (regression: live-fetch drift) -----------------
def test_initial_fetch_is_navigation_loadmore_is_xhr(monkeypatch):
# The initial creator-page GET must NOT be flagged XHR (Rails content-
# negotiates an XHR full-page request to a non-HTML body → drift; first live
# run, cheunart 2026-06-17). Only the "load more" endpoint is a real XHR.
client = SubscribeStarClient(None)
seen = []
class _R:
status_code = 200
text = '<div data-role="posts_container-list"></div>'
def json(self):
return {"html": ""}
def fake_get(url, *, headers=None):
seen.append(headers)
return _R()
monkeypatch.setattr(client, "_get", fake_get)
client._feed_html("https://subscribestar.adult/x")
client._loadmore_html("https://subscribestar.adult/posts?page=2")
assert seen[0] is None # navigation — no per-request XHR header
assert seen[1]["X-Requested-With"] == "XMLHttpRequest"
# -- client: iteration + pagination -----------------------------------------
def test_iter_posts_parses_and_paginates(monkeypatch):