import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import { describe, it } from 'node:test' import { ART_FILES } from './art-assets.ts' import { artFileName, artResponse, decodeArtBase64 } from './art.ts' import { lineageManifest } from './manifest.ts' describe('Lineage install artwork', () => { it('serves the compressed PNG and JPEG icons used by the manifest', async () => { assert.deepEqual(Object.keys(ART_FILES).sort(), [ 'apple-touch-icon.png', 'favicon.png', 'og-image.jpg', 'pwa-192.png', 'pwa-512-maskable.png', 'pwa-512.png', ]) for (const [name, file] of Object.entries(ART_FILES)) { const onDisk = await readFile(new URL(`./art/${name}`, import.meta.url)) assert.equal(file.base64, onDisk.toString('base64')) assert.ok(decodeArtBase64(file.base64).byteLength > 100) const response = artResponse(`/${name}`) assert.ok(response) assert.equal(response.headers.get('Content-Type'), file.type) } assert.equal(artFileName('/missing.png'), null) }) it('declares separate any and maskable PNG icons like kody.video', () => { const manifest = lineageManifest('/packages/lineage') assert.deepEqual( manifest.icons.map((icon) => `${icon.sizes}:${icon.purpose}`), ['192x192:any', '512x512:any', '512x512:maskable'], ) assert.ok(manifest.icons.every((icon) => icon.type === 'image/png')) assert.doesNotMatch(JSON.stringify(manifest.icons), /icon\.svg/) assert.equal(manifest.display, 'standalone') assert.equal(manifest.prefer_related_applications, false) assert.equal(manifest.start_url, '/packages/lineage/') }) it('uses the Lineage mark as the community listing icon', async () => { const icon = await readFile(new URL('../../community-icon.png', import.meta.url)) const mark = await readFile(new URL('./art/pwa-512.png', import.meta.url)) assert.deepEqual(icon, mark) await assert.rejects(() => readFile(new URL('../../community-icon.svg', import.meta.url))) }) })