feat(ui): light mode and new theming system (#1468)

This commit is contained in:
Alex
2026-05-26 01:07:33 -04:00
committed by GitHub
parent 3211d7818a
commit 22ff6d8e90
131 changed files with 2816 additions and 3391 deletions
@@ -0,0 +1,57 @@
import {describe, expect, it, vi} from 'vitest';
import {FaviconService} from './favicon-service';
describe('FaviconService', () => {
it('updates an existing favicon link with a generated SVG URL', () => {
const favicon = {type: '', href: ''} as HTMLLinkElement;
const querySelectorSpy = vi.spyOn(document, 'querySelector').mockReturnValue(favicon);
const createObjectUrlSpy = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:favicon');
const service = new FaviconService();
service.updateFavicon('#abcdef', '#123456');
expect(querySelectorSpy).toHaveBeenCalledWith("link[rel*='icon']");
expect(createObjectUrlSpy).toHaveBeenCalledOnce();
expect(favicon.type).toBe('image/svg+xml');
expect(favicon.href).toBe('blob:favicon');
});
it('creates and appends a favicon link when one does not already exist', () => {
const appended: HTMLLinkElement[] = [];
const favicon = {rel: '', type: '', href: ''} as HTMLLinkElement;
vi.spyOn(document, 'querySelector').mockReturnValue(null);
vi.spyOn(document, 'createElement').mockReturnValue(favicon);
vi.spyOn(document.head, 'appendChild').mockImplementation(node => {
appended.push(node as HTMLLinkElement);
return node;
});
vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:new-favicon');
const service = new FaviconService();
service.updateFavicon('#fedcba', '#abcdef');
expect(appended).toEqual([favicon]);
expect(favicon.rel).toBe('icon');
expect(favicon.type).toBe('image/svg+xml');
expect(favicon.href).toBe('blob:new-favicon');
});
it('revokes the previous favicon object URL before replacing it', () => {
const favicon = {type: '', href: ''} as HTMLLinkElement;
vi.spyOn(document, 'querySelector').mockReturnValue(favicon);
vi.spyOn(URL, 'createObjectURL')
.mockReturnValueOnce('blob:first-favicon')
.mockReturnValueOnce('blob:second-favicon');
const revokeObjectUrlSpy = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined);
const service = new FaviconService();
service.updateFavicon('#fedcba', '#abcdef');
service.updateFavicon('#89abcd', '#123456');
expect(revokeObjectUrlSpy).toHaveBeenCalledWith('blob:first-favicon');
expect(favicon.href).toBe('blob:second-favicon');
});
});