mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-29 07:20:43 +00:00
- generate-og.mjs records the hash of each card's page and image in scripts/og.json as it draws, and e2e/unit/cards.spec.ts fails on an image or a word that moved without a redraw. - The card test refuses any name e2e/gates/backing's BACKING lists, so a lab cannot sit on a card even apart from Enso, Zen or Kai. - The default card is drawn straight to public/og-image.png; the unused copy in public/og/ goes. - The sign-in card says one account covers Chat, Dev, the console and your API keys. Co-authored-by: Hanzo Dev <[email protected]>
86 lines
3.5 KiB
TypeScript
86 lines
3.5 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { createHash } from 'node:crypto'
|
|
import { readFileSync } from 'node:fs'
|
|
import { getOgImageUrl, OG_IMAGE, OG_IMAGES_BY_PATH } from '../../lib/constants/og'
|
|
import { BACKING, scan } from '../gates/backing'
|
|
import { CARDS, MANIFEST, file, renderHtml } from '../../scripts/generate-og.mjs'
|
|
|
|
/**
|
|
* A SHARE CARD SAYS ONLY WHAT CAN BE CHECKED.
|
|
*
|
|
* Every card is drawn by scripts/generate-og.mjs, its words and its visuals
|
|
* alike, so this reads the whole generator. A card states what a page, the
|
|
* plan catalog (GET /v1/billing/plans), the model catalog (GET /v1/models) or
|
|
* /trust already states; it never names what backs Enso, Zen or Kai. A redrawn
|
|
* card takes a new address, because a share preview is cached by its address.
|
|
* Each image is held to the words it was drawn from by the hashes the
|
|
* generator records in scripts/og.json when it draws.
|
|
*/
|
|
|
|
const source = readFileSync(new URL('../../scripts/generate-og.mjs', import.meta.url), 'utf8')
|
|
|
|
/** Claims no page or catalog backs, and the made-up model names and scores the cards once drew. */
|
|
const UNBACKED = [
|
|
/zero retention/i,
|
|
/enterprise[- ]grade/i,
|
|
/SOC ?2/i,
|
|
/HIPAA/i,
|
|
/ISO ?27001/i,
|
|
/99\.9/,
|
|
/AES-256/i,
|
|
/in seconds/i,
|
|
/passkey/i,
|
|
/latency/i,
|
|
/\b\d+ ?ms\b/i,
|
|
/hidden fees/i,
|
|
/unlimited scale/i,
|
|
/peer[- ]reviewed/i,
|
|
/reproducible science/i,
|
|
/state[- ]of[- ]the[- ]art/i,
|
|
/most popular/i,
|
|
/\b\d+\+ (?:open |frontier )?models/i,
|
|
/zen[- ]?5[- ]ultra/i,
|
|
/enso[- ]?3/i,
|
|
/\b\d+\.\d+%/,
|
|
/claude|anthropic|deepseek|gemini|llama|mistral|openrouter/i,
|
|
/silicon/i,
|
|
/competitive equity/i,
|
|
/frontier hardware/i,
|
|
/decentralized/i,
|
|
/foundation for applied ai/i,
|
|
]
|
|
|
|
test('no card claims what nothing backs', () => {
|
|
for (const claim of UNBACKED) expect(source, String(claim)).not.toMatch(claim)
|
|
})
|
|
|
|
test('no card says what backs Enso, Zen or Kai, or names a lab that could', () => {
|
|
expect(scan(source, '.js')).toEqual([])
|
|
expect(source.match(BACKING)?.[0]).toBeUndefined()
|
|
})
|
|
|
|
const sha = (bytes: string | Buffer) => createHash('sha256').update(bytes).digest('hex')
|
|
|
|
test('every image is the one its words drew', () => {
|
|
const drawn = JSON.parse(readFileSync(MANIFEST, 'utf8')) as Record<string, { html: string; png: string }>
|
|
expect(Object.keys(drawn).sort()).toEqual(CARDS.map((c) => c.name).sort())
|
|
for (const card of CARDS) {
|
|
const redraw = `node scripts/generate-og.mjs ${card.name}`
|
|
expect(sha(renderHtml(card)), `${card.name}'s words changed after it was drawn: ${redraw}`).toBe(drawn[card.name].html)
|
|
expect(sha(readFileSync(new URL(`../../${file(card.name)}`, import.meta.url))), `${file(card.name)} is not the image drawn: ${redraw}`).toBe(drawn[card.name].png)
|
|
}
|
|
})
|
|
|
|
test('every card takes the same new address', () => {
|
|
const version = OG_IMAGE.url.match(/\?v=(\d+)$/)?.[1]
|
|
expect(Number(version)).toBeGreaterThanOrEqual(3)
|
|
for (const [path, url] of Object.entries(OG_IMAGES_BY_PATH)) expect(url, path).toMatch(new RegExp(`^/og/[a-z-]+\\.png\\?v=${version}$`))
|
|
// /contact has no card of its own, so it shares the default one.
|
|
expect(getOgImageUrl('/contact')).toBe(OG_IMAGE.url)
|
|
})
|
|
|
|
test('every card the pages name is one the generator draws', () => {
|
|
const drawn = new Set(CARDS.map((c) => `/${file(c.name).replace(/^public\//, '')}`))
|
|
for (const url of [OG_IMAGE.url, ...Object.values(OG_IMAGES_BY_PATH)]) expect(drawn.has(url.replace(/\?.*$/, '')), `${url} is drawn by scripts/generate-og.mjs`).toBe(true)
|
|
})
|