mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Lands five integrated branches: pipeline templates (#355), analytics opt-out (#354), 83 conversion presets bringing the catalog to 240 tools (#356), self-hosted positioning (#353), and e2e modernization (#351). Integration fixes: aligned stale web analytics tests with the opt-out/allow-list model, closed 3 CodeQL incomplete-sanitization alerts in the i18n generator, resolved settings/index/docs/format-matrix conflicts, and corrected tool counts to 240.
35 lines
965 B
TypeScript
35 lines
965 B
TypeScript
import { normalizeSearchQuery, TOOLS } from "@snapotter/shared";
|
|
import Fuse from "fuse.js";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const OPTS = {
|
|
keys: [
|
|
{ name: "name", weight: 0.35 },
|
|
{ name: "description", weight: 0.25 },
|
|
{ name: "keywords", weight: 0.3 },
|
|
{ name: "modality", weight: 0.15 },
|
|
{ name: "id", weight: 0.15 },
|
|
{ name: "category", weight: 0.1 },
|
|
],
|
|
threshold: 0.45,
|
|
ignoreLocation: true,
|
|
minMatchCharLength: 2,
|
|
};
|
|
|
|
function search(q: string) {
|
|
const fuse = new Fuse(TOOLS, OPTS as never);
|
|
return fuse.search(normalizeSearchQuery(q)).map((r) => r.item.id);
|
|
}
|
|
|
|
describe("app fuzzy search finds converters by variation", () => {
|
|
it.each([
|
|
["jpeg to png", "jpg-to-png"],
|
|
["jpg2png", "jpg-to-png"],
|
|
["heic jpg", "heic-to-jpg"],
|
|
["mov mp4", "mov-to-mp4"],
|
|
["convert mp4 to mp3", "mp4-to-mp3"],
|
|
])("%s finds %s", (q, id) => {
|
|
expect(search(q).slice(0, 5)).toContain(id);
|
|
});
|
|
});
|