Import Chrome's profile `Bookmarks` file and Firefox's JSON backup directly. Each reader is held to a parity rule against its browser's own HTML exporter, tested on Chromium/Firefox-faithful fixture pairs. One entry point, parseBookmarkFile, sniffs by content (JSON first, parsed exactly once, routed by shape); the picker loses its extension filter, which hid the extensionless `Bookmarks` file. Firefox's internal root names are localized by the caller. Merge finally reuses the folders a user already has, level by level, appending new items (core/merge.ts) - 1.0.x planned it exactly like Replace. Root folders are unwrapped by marker (core/route.ts), so restoring a backup no longer nests Other and Mobile one level deeper each time, 1.0.x backups included. Replace never dedupes, plans before the backup is taken, and refuses a backup the import could not read back (BACKUP_EXCEEDS_LIMITS) before anything is written, downloaded or deleted. The save dialog's late rejection is marked handled. Also found: the seeded round-trip suite had compared 200 empty trees since Phase 1 (xorshift32 seeded with 1-200 draws near zero first). makeRng now scrambles the seed and every seeded suite checks its corpus is non-trivial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { buildUrlIndex } from '@/lib/core/dedupe';
|
|
import { diffAgainstBrowser } from '@/lib/core/diff';
|
|
import type { BookmarkNode } from '@/lib/core/model';
|
|
|
|
/** The preview badges — docs/05 §5. */
|
|
const BROWSER = buildUrlIndex([
|
|
{ title: 'Bar', children: [{ title: 'have', url: 'https://have.example/' }] },
|
|
]);
|
|
|
|
describe('diffAgainstBrowser', () => {
|
|
const have: BookmarkNode = { title: 'mine', url: 'https://HAVE.example' };
|
|
const fresh: BookmarkNode = { title: 'new', url: 'https://new.example/' };
|
|
const again: BookmarkNode = { title: 'again', url: 'https://have.example/' };
|
|
const folder: BookmarkNode = { title: 'F', children: [have, fresh] };
|
|
const result = diffAgainstBrowser([folder, again], BROWSER);
|
|
|
|
it('badges every bookmark, comparing normalized URLs, path-insensitively', () => {
|
|
expect(result.status.get(have)).toBe('exists');
|
|
expect(result.status.get(fresh)).toBe('new');
|
|
expect(result.status.get(again)).toBe('exists');
|
|
});
|
|
|
|
it('counts per node, so a URL the file repeats counts each time', () => {
|
|
expect(result).toMatchObject({ existsCount: 2, newCount: 1 });
|
|
});
|
|
|
|
it('never badges a folder', () => {
|
|
expect(result.status.has(folder)).toBe(false);
|
|
});
|
|
});
|