Files
HealthLog/src/lib/notifications/__tests__/strip-emoji.test.ts
T
Marc-André Bombeck e391150455 fix(notifications): strip emoji from routine reminder push content
Reminder pushes (medication-due, mood, briefing, cycle) carried the
colour-coded phase markers the Telegram channel uses, which leaked onto the
iOS lock screen and other push channels as decorative bubbles. Strip emoji
in the APNs, Web Push and ntfy senders for every event except SYSTEM_ALERT,
so routine reminders render as plain text while system / failure alerts keep
their severity glyphs. Telegram is unchanged — emoji stay idiomatic there.
2026-06-06 16:27:59 +02:00

50 lines
1.5 KiB
TypeScript

import { describe, it, expect } from "vitest";
import {
stripDecorativeEmoji,
shouldStripEmoji,
plainPushText,
} from "@/lib/notifications/strip-emoji";
describe("stripDecorativeEmoji", () => {
it("removes the colour-coded reminder phase markers and tidies whitespace", () => {
expect(stripDecorativeEmoji("🟢 Reminder: Ramipril")).toBe(
"Reminder: Ramipril",
);
expect(stripDecorativeEmoji("🔴 Missed: Metformin")).toBe(
"Missed: Metformin",
);
});
it("strips clock / skip / check emoji and regional indicators", () => {
expect(stripDecorativeEmoji("🕐 1h ⏭ Skip ✅")).toBe("1h Skip");
});
it("leaves plain text untouched", () => {
expect(stripDecorativeEmoji("Due soon: Vitamin D (1 tablet)")).toBe(
"Due soon: Vitamin D (1 tablet)",
);
});
it("spares ™ © ® so brand names survive", () => {
expect(stripDecorativeEmoji("Tylenol® reminder")).toBe("Tylenol® reminder");
});
});
describe("shouldStripEmoji / plainPushText", () => {
it("strips for routine reminder events", () => {
expect(shouldStripEmoji("MEDICATION_REMINDER")).toBe(true);
expect(shouldStripEmoji("MOOD_REMINDER")).toBe(true);
expect(plainPushText("🟢 Take Ramipril", "MEDICATION_REMINDER")).toBe(
"Take Ramipril",
);
});
it("keeps emoji for system / failure alerts", () => {
expect(shouldStripEmoji("SYSTEM_ALERT")).toBe(false);
expect(plainPushText("⚠️ Sync failed", "SYSTEM_ALERT")).toBe(
"⚠️ Sync failed",
);
});
});