ReviewOS

also looking at this

stacks/commshq

fix(seo): ship a robots.txt so the production smoke test passes

#10
Merged glennmichael123 wants to merge fix/robots-txt into main
2 files +46 -0
tests/Unit/RobotsTxt.test.tsadded+22-0
Changes to tests/Unit/RobotsTxt.test.ts
@@ -0,0 +1,22 @@
1import { describe, expect, it } from 'bun:test'
2import { readFileSync } from 'node:fs'
3import { join } from 'node:path'
4
5const robots = readFileSync(join(import.meta.dir, '../../public/robots.txt'), 'utf8')
6
7// scripts/smoke-deployment.ts fetches /robots.txt on production after every
8// deploy and fails the run if it is missing, names the wrong host, or leaks a
9// localhost URL. Checking the same things here keeps that gate from going red
10// only after the code is already live.
11describe('robots.txt', () => {
12 it('names the production host and no local one', () => {
13 expect(robots).toContain('commshq.org')
14 expect(robots).not.toContain('localhost')
15 })
16
17 it('keeps crawlers out of the auth-walled and API routes', () => {
18 for (const path of ['/dashboard', '/login', '/register', '/api/'])
19 expect(robots).toContain(`Disallow: ${path}`)
20 expect(robots).toContain('Allow: /')
21 })
22})