import { describe, expect, it } from "vitest"; import { isDeadLinkErrorText, germanDeadLinkReason } from "../src/shared/dead-link"; describe("isDeadLinkErrorText", () => { it("matches the real Mega-Debrid French dead-link phrase", () => { expect(isDeadLinkErrorText("Mega-Debrid API: Fichier supprimé chez l'hébergeur")).toBe(true); }); it("matches inside the aggregated provider-chain error (api dead | web timeout)", () => { const aggregated = "Unrestrict fehlgeschlagen: Mega-Debrid API: Mega-Debrid (API): Fichier supprimé chez l'hébergeur | Mega-Debrid Web: Mega-Debrid (Web): Abbruch/Timeout nach 60s"; expect(isDeadLinkErrorText(aggregated)).toBe(true); }); it("matches the de-accented variant (encoding may strip accents)", () => { expect(isDeadLinkErrorText("Fichier supprime chez l'hebergeur")).toBe(true); }); it("matches other clearly-dead French phrases", () => { expect(isDeadLinkErrorText("Fichier introuvable")).toBe(true); expect(isDeadLinkErrorText("Le fichier n'existe plus")).toBe(true); }); it("still matches the existing English dead-link phrases", () => { expect(isDeadLinkErrorText("file not found")).toBe(true); expect(isDeadLinkErrorText("File has been deleted")).toBe(true); expect(isDeadLinkErrorText("file is no longer available")).toBe(true); expect(isDeadLinkErrorText("link is dead")).toBe(true); }); it("does NOT match temporary/transient failures", () => { expect(isDeadLinkErrorText("Abbruch/Timeout nach 60s")).toBe(false); expect(isDeadLinkErrorText("Quota/Limit erreicht")).toBe(false); expect(isDeadLinkErrorText("Rate-Limit (429)")).toBe(false); expect(isDeadLinkErrorText("Kein Server fuer diesen Hoster")).toBe(false); expect(isDeadLinkErrorText("queue-timeout")).toBe(false); expect(isDeadLinkErrorText("hosternotavailable")).toBe(false); }); }); describe("germanDeadLinkReason", () => { it("renders the deleted-at-host phrase in German", () => { expect(germanDeadLinkReason("Mega-Debrid API: Fichier supprimé chez l'hébergeur")).toBe("Datei beim Hoster gelöscht"); }); it("renders a plain deletion in German", () => { expect(germanDeadLinkReason("fichier supprimé")).toBe("Datei gelöscht"); }); it("renders not-found in German", () => { expect(germanDeadLinkReason("Fichier introuvable")).toBe("Datei beim Hoster nicht gefunden"); }); });