Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596// The dataset is optional and third-party: a failed read hides the row, a// malformed one is treated the same way, and the two lookups only answer about// the exact publication or account asked for.
import { beforeEach, describe, expect, it, vi } from 'vitest'
const requestJson = vi.fn()
vi.mock('./http', () => ({ requestJson: (...args: unknown[]) => requestJson(...args),}))vi.mock('./cache', () => ({ cached: async (_key: unknown, load: () => Promise<unknown>) => load(),}))
const { accountStanding, fetchPanoptiblog, publicationStanding } = await import('./panoptiblog')
const PUB_URI = 'at://did:plc:abc/site.standard.publication/self'const DID = 'did:plc:abc'
const DATA = { generatedAt: '2026-10-26T00:00:00.000Z', totals: {}, publications: [ { uri: PUB_URI, did: DID, name: 'Writer’s Blog', rank: 7, wordCount: 1200, docCount: 3, subscribers: 4, recommends: 1, score: 2.5, }, ], accounts: [ { did: DID, handle: 'writer.test', rank: 3, publicationCount: 2, wordCount: 1200, labels: ['multiple-blogs', 'blogged-recently'], score: 4, }, ],}
beforeEach(() => { requestJson.mockReset()})
describe('fetchPanoptiblog', () => { it('returns a well-shaped dataset', async () => { requestJson.mockResolvedValue(DATA) expect(await fetchPanoptiblog()).toEqual(DATA) expect(requestJson).toHaveBeenCalledWith( 'https://substandard.blog/panoptiblog/data.json', expect.anything(), ) })
it('returns null when the read fails', async () => { requestJson.mockRejectedValue(new Error('offline')) expect(await fetchPanoptiblog()).toBeNull() })
it('returns null rather than a dataset missing its tables', async () => { requestJson.mockResolvedValue({ generatedAt: 'x', totals: {} }) expect(await fetchPanoptiblog()).toBeNull() })})
describe('standings', () => { it('finds a publication by its exact at-uri', () => { expect(publicationStanding(DATA, PUB_URI)?.rank).toBe(7) expect(publicationStanding(DATA, 'at://did:plc:other/site.standard.publication/self')).toBe( undefined, ) })
it('finds an account by its exact DID', () => { expect(accountStanding(DATA, DID)?.labels).toEqual([ 'multiple-blogs', 'blogged-recently', ]) expect(accountStanding(DATA, 'did:plc:other')).toBeUndefined() })
it('answers nothing for a missing dataset', () => { expect(publicationStanding(null, PUB_URI)).toBeUndefined() expect(accountStanding(null, DID)).toBeUndefined() })})