// The public read-only page at https://pds.7rnx.net/ — "what really shows up", from bsky's side (#80).
import test from 'brittle'
import { renderPublicPage } from '../lib/public.js'
const NOW = 1e12
const WJ = 'did:plc:wj62ebbusln6gxo5azo6ogzo'
function sample () {
return {
version: '0.5.0',
process: { uptimeS: 7300, rss: 280e6, heapUsed: 1, heapTotal: 1 },
roles: { membrane: { up: true }, fediverse: { up: true }, lens: { up: true } },
membrane: { dids: [{ did: WJ, handle: 'p2p.7rnx.net', rev: 'r', fronts: 2, live: 1 }], relay: { emitted: 40269 }, guard: {} },
fediverse: { users: [{ username: 'p2p', primary: true, followers: 1, delivered: 172 }], queue: { pending: 0, dead: 0, failing: [] }, inbound: { count: 1 }, registrations: 2 },
lens: { feeds: [{ id: 'loser-club', feedUri: 'at://did:plc:lc/app.bsky.feed.generator/loser-club', posts: 299, members: 2, unfronted: [], perMember: [] }] },
bsky: {
at: NOW - 60e3,
hostname: 'pds.7rnx.net',
relay: { status: 'active', seq: 40269 },
dids: [{ did: WJ, handle: 'p2p.7rnx.net', inSync: true, plcPds: 'https://pds.7rnx.net', appview: { resolves: true, postsCount: 201, recent: [{ uri: 'at://' + WJ + '/app.bsky.feed.post/3mvks7khp3u6w', text: 'blursed <script>x</script>', createdAt: '2026-09-15T14:05:29Z' }] } }],
feeds: [{ uri: 'at://did:plc:lc/app.bsky.feed.generator/loser-club', posts: [{ uri: 'at://' + WJ + '/app.bsky.feed.post/3mvks7khp3u6w', author: 'p2p.7rnx.net', text: 'blursed', createdAt: '2026-09-15T14:05:29Z' }] }],
problems: []
},
alerts: { lastCheckAt: NOW - 60e3, open: [{ id: 'relay-newer:x', severity: 'critical', title: 'relay holds a newer commit', detail: 'internal detail', fix: 'favela-gateway emit-sync did=x', since: NOW - 7200e3 }], recentlyResolved: [] }
}
}
test('★ a full HTML page with bsky\'s view: relay, accounts, their recent posts, the feed as bsky shows it', (t) => {
const html = renderPublicPage(sample(), { now: NOW })
t.ok(html.startsWith('<!doctype html>'))
for (const s of ['pds.7rnx.net', 'active', 'p2p.7rnx.net', 'in sync', '201 posts', 'loser-club', 'blursed', '1 follower']) t.ok(html.includes(s), s)
t.ok(html.includes('https://bsky.app/profile/' + WJ + '/post/3mvks7khp3u6w'), 'each post links to where bsky shows it')
t.ok(html.includes('https://ap.7rnx.net/timeline'), 'the fediverse side links to its own timeline')
})
test('⛔ public means no internals: alert titles yes, commands and details no; no process stats', (t) => {
const html = renderPublicPage(sample(), { now: NOW })
t.ok(html.includes('relay holds a newer commit'), 'the title of an open problem is public')
t.absent(html.includes('emit-sync'), 'the fix command is not')
t.absent(html.includes('internal detail'), 'nor the detail')
t.absent(/280 MB|rss/i.test(html), 'nor process memory')
})
test('⛔ post text from bsky is escaped', (t) => {
const html = renderPublicPage(sample(), { now: NOW })
t.absent(html.includes('<script>x</script>'))
t.ok(html.includes('<script>'))
})
test('before the first probe the page still renders and says bsky has not been checked yet', (t) => {
const m = sample(); m.bsky = null; m.alerts = null
const html = renderPublicPage(m, { now: NOW })
t.ok(/not been checked yet/.test(html))
})