feat(domains): Favicons laden und im Filter anzeigen
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m16s
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>
This commit is contained in:
35
tests/integration/favicons.test.ts
Normal file
35
tests/integration/favicons.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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');
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user