All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m16s
Für jede Whitelist-Domain wird das Favicon jetzt einmalig geladen und im image-Verzeichnis abgelegt. SearchFilter zeigt das Icon neben dem Domain-Namen im Filter-Dropdown. - Migration 009: allowed_domain.favicon_path (NULL = noch nicht geladen). - Neues Modul $lib/server/domains/favicons.ts: fetchAndStoreFavicon(domain, imageDir) + ensureFavicons(db, imageDir) für Bulk-Nachzug; 8 parallele Worker mit 3s-Timeout. - Reihenfolge: erst /favicon.ico der Domain, Fallback Google-Service. - GET /api/domains zieht fehlende Favicons auf Abruf nach; POST /api/domains lädt direkt im selben Call. - .ico + .svg jetzt in der /images/[filename]-Route erlaubt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import { mkdtempSync, rmSync, readdirSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { openInMemoryForTest } from '../../src/lib/server/db';
|
|
import { addDomain, listDomains } from '../../src/lib/server/domains/repository';
|
|
import { ensureFavicons } from '../../src/lib/server/domains/favicons';
|
|
|
|
let imageDir: string;
|
|
|
|
beforeEach(() => {
|
|
imageDir = mkdtempSync(join(tmpdir(), 'kochwas-favicon-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
rmSync(imageDir, { recursive: true, force: true });
|
|
});
|
|
|
|
describe('ensureFavicons', () => {
|
|
it('is a no-op when every domain already has a favicon_path', async () => {
|
|
const db = openInMemoryForTest();
|
|
const d = addDomain(db, 'example.com');
|
|
// simulate already-stored favicon
|
|
db.prepare('UPDATE allowed_domain SET favicon_path = ? WHERE id = ?').run(
|
|
'favicon-abc.png',
|
|
d.id
|
|
);
|
|
await ensureFavicons(db, imageDir);
|
|
// No file written, no DB state changed
|
|
expect(readdirSync(imageDir).length).toBe(0);
|
|
const domains = listDomains(db);
|
|
expect(domains[0].favicon_path).toBe('favicon-abc.png');
|
|
});
|
|
|
|
});
|