fix: root files answer 503 while the backend has not answered

- rootFileTargets gives robots.txt, sitemap.xml and llms.txt their backend
  target also in state unknown without a last answer, so the failing fetch
  answers 503 with Retry-After: 60 instead of the app's 404 (L4 WR-08)
- an older backend (absent) still passes through; sitemap files and
  verification files still need a site answer
- expect-seo-down.txt expects the 503s and states the staging reason
This commit is contained in:
Jakub Zych
2026-11-04 22:49:40 +01:00
parent a651de4675
commit 8cdf35929a
5 changed files with 51 additions and 24 deletions

View File

@@ -15,11 +15,23 @@ test('rootFileTargets: robots.txt, sitemap.xml, llms.txt and sitemap files go to
assert.deepEqual(rootFileTargets('/sitemap-posts-1.xml', ok, B, A), [{ kind: 'sitemap', url: `${B}/_sitemap/files/sitemap-posts-1.xml` }])
})
test('rootFileTargets: without a site answer (older backend, or never reached) nothing is served, as in v0.1.1', () => {
for (const state of [{ state: 'absent' }, { state: 'unknown' }] as SeoSiteState[]) {
for (const p of ['/robots.txt', '/sitemap.xml', '/llms.txt', '/sitemap-posts-1.xml', '/google1234.html']) {
assert.equal(rootFileTargets(p, state, B, A), null, `${state.state} ${p}`)
}
test('rootFileTargets: an older backend (absent) passes every path through, as in v0.1.1', () => {
const absent: SeoSiteState = { state: 'absent' }
for (const p of ['/robots.txt', '/sitemap.xml', '/llms.txt', '/sitemap-posts-1.xml', '/google1234.html']) {
assert.equal(rootFileTargets(p, absent, B, A), null, p)
}
})
test('rootFileTargets: a backend never reached since start (unknown) still owns the fixed root files (L4 WR-08)', () => {
// The fetch then fails and the middleware answers 503 with Retry-After,
// so a crawler never reads the app's 404 as an allow-all robots.txt.
const unknown: SeoSiteState = { state: 'unknown' }
assert.deepEqual(rootFileTargets('/robots.txt', unknown, B, A), [{ kind: 'root', url: `${B}/robots.txt` }])
assert.deepEqual(rootFileTargets('/sitemap.xml?x=1', unknown, B, A), [{ kind: 'root', url: `${B}/sitemap.xml` }])
assert.deepEqual(rootFileTargets('/llms.txt', unknown, B, A), [{ kind: 'root', url: `${B}/llms.txt` }])
// sitemap files and verification files still need a site answer
for (const p of ['/sitemap-posts-1.xml', '/google1234.html', `/${KEY}`, '/random.txt']) {
assert.equal(rootFileTargets(p, unknown, B, A), null, p)
}
})