Skip to content
← Public packages

@kody/kody-factory

Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.

FollowFork

Files

icon.test.ts

30 lines · 1.5 KB · TypeScript
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { test } from 'node:test'
import { APP_MARK_SVG, renderShell } from './ui.ts'

const pub = (f: string) => new URL(`../../public/${f}`, import.meta.url)

test('favicon.svg is the same self-contained mark as the rail logo', () => {
	const fav = readFileSync(pub('favicon.svg'), 'utf8').trim()
	assert.match(fav, /viewBox="0 0 32 32"/)
	assert.doesNotMatch(fav, /https?:\/\/(?!www\.w3\.org)/, 'no external references')
	const norm = (s: string) =>
		s.replace(/ xmlns="[^"]+"/, '').replace(/ aria-hidden="true"/, '').replace(/kf-(favicon|mark)-grad/g, 'G')
	assert.equal(norm(fav), norm(APP_MARK_SVG))
})

test('apple-touch-icon.png is a 180x180 PNG', () => {
	const png = readFileSync(pub('apple-touch-icon.png'))
	assert.equal(png.subarray(1, 4).toString('latin1'), 'PNG')
	assert.equal(png.readUInt32BE(16), 180)
	assert.equal(png.readUInt32BE(20), 180)
})

test('shell head links the icons under the app base path', () => {
	const html = renderShell({ basePath: '/kody-factory', view: 'overview', title: 'Overview' })
	assert.ok(html.includes('<link rel="icon" type="image/svg+xml" href="/kody-factory/_assets/favicon.svg"/>'))
	assert.ok(html.includes('<link rel="apple-touch-icon" href="/kody-factory/_assets/apple-touch-icon.png"/>'))
	assert.ok(html.includes('<meta name="theme-color" content="#111827"/>'))
	assert.equal(html.split('id="kf-mark-grad"').length - 1, 1, 'gradient id is unique on the page')
})