mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-30 14:58:08 +00:00
lib/data/zen.json is @zenlm/models read through lib/upstream at prebuild (scripts/zen.mjs); no page or client chunk imports the package. The Flash command finds its files by quantization, so no loader name ships. Co-authored-by: Hanzo Dev <[email protected]>
57 lines
2.4 KiB
TypeScript
57 lines
2.4 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { readdirSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
import { NAMED } from '../../lib/upstream'
|
|
import { OUT, serveExport } from './export'
|
|
|
|
/**
|
|
* ZEN IS NAMED AS ZEN.
|
|
*
|
|
* No Zen page names the checkpoint a Zen model descends from: not its reading
|
|
* copy, not a fine print, not a loader command, not its meta. The names are
|
|
* lib/upstream's, the one list.
|
|
*
|
|
* Read in a browser over the export, with the gateway shut off: /zen/models
|
|
* draws its rows after hydration from lib/data/zen.json, so every row is
|
|
* opened and the whole page is read.
|
|
*/
|
|
const FAMILY = ['/zen', '/zen/models', '/research-access']
|
|
|
|
/** Every Zen model's own page in the export. */
|
|
const models = () =>
|
|
readdirSync(join(OUT, 'models', 'hanzo'))
|
|
.filter((f) => /^zen[^/]*\.html$/.test(f))
|
|
.map((f) => `/models/hanzo/${f.replace(/\.html$/, '')}`)
|
|
|
|
test('no Zen page names an upstream checkpoint', async ({ page }) => {
|
|
// Two dozen pages, read in turn. A static page's copy is in its HTML, so
|
|
// each waits for the document, not for every script and image under it.
|
|
test.setTimeout(600_000)
|
|
const site = await serveExport()
|
|
const MODELS = models()
|
|
try {
|
|
await page.route(/api\.hanzo\.ai/, (route) => route.abort())
|
|
const found: string[] = []
|
|
for (const path of [...FAMILY, ...MODELS]) {
|
|
await page.goto(site.url + path, { waitUntil: 'domcontentloaded' })
|
|
if (path === '/zen/models') {
|
|
await page.locator('tr[data-slot="cell"]').first().waitFor({ timeout: 20_000 })
|
|
for (const row of await page.locator('tr[data-slot="cell"]').all()) await row.click()
|
|
}
|
|
const text = await page.evaluate(() => {
|
|
const meta = [...document.querySelectorAll('title, meta[name="description"], meta[property^="og:"], meta[name^="twitter:"]')].map(
|
|
(m) => m.getAttribute('content') ?? m.textContent ?? '',
|
|
)
|
|
const alt = [...document.querySelectorAll('[alt]')].map((el) => el.getAttribute('alt') ?? '')
|
|
return [document.body.innerText, ...meta, ...alt].join('\n')
|
|
})
|
|
const at = text.search(NAMED)
|
|
if (at >= 0) found.push(`${path}: …${text.slice(Math.max(0, at - 40), at + 40).replace(/\s+/g, ' ')}…`)
|
|
}
|
|
expect(MODELS.length, 'the export has Zen model pages to read').toBeGreaterThan(0)
|
|
expect(found).toEqual([])
|
|
} finally {
|
|
await site.close()
|
|
}
|
|
})
|