Pushover notifications can target specific devices

This commit is contained in:
Jarek Krochmalski committed 2026-08-23 10:20:59 +02:00
1 parent 7692758467
commit 70491423dc
5 files changed
+104 -12

No files matched your search

+55 -1
View File
@@ -6,7 +6,7 @@
*/
import { describe, test, expect } from 'bun:test';
import { escapeTelegramMarkdown, buildGotifyUrl } from '../src/lib/utils/notification-parsers';
import { escapeTelegramMarkdown, buildGotifyUrl, parsePushoverUrl } from '../src/lib/utils/notification-parsers';
// Test the event type mapping logic (mirrors notifications.ts)
const EVENT_TYPE_MAPPING: Record<string, string> = {
@@ -273,3 +273,57 @@ describe('Telegram Markdown Escaping', () => {
expect(envTag).not.toContain('\\]');
});
});
describe('Pushover URL Parsing', () => {
test('backward compatible: pushover://user/token has no device', () => {
expect(parsePushoverUrl('pushover://uKey123/aToken456')).toEqual({
userKey: 'uKey123',
apiToken: 'aToken456',
device: undefined
});
});
test('pushover:// with a single device', () => {
expect(parsePushoverUrl('pushover://uKey123/aToken456/phone')).toEqual({
userKey: 'uKey123',
apiToken: 'aToken456',
device: 'phone'
});
});
test('pushover:// with multiple devices -> comma-separated list', () => {
expect(parsePushoverUrl('pushover://uKey123/aToken456/phone/tablet/desktop')).toEqual({
userKey: 'uKey123',
apiToken: 'aToken456',
device: 'phone,tablet,desktop'
});
});
test('apprise-native pover://user@token form, no device', () => {
expect(parsePushoverUrl('pover://uKey123@aToken456')).toEqual({
userKey: 'uKey123',
apiToken: 'aToken456',
device: undefined
});
});
test('apprise-native pover://user@token/device1/device2', () => {
expect(parsePushoverUrl('pover://uKey123@aToken456/phone/tablet')).toEqual({
userKey: 'uKey123',
apiToken: 'aToken456',
device: 'phone,tablet'
});
});
test('trailing slash / empty segments are ignored', () => {
expect(parsePushoverUrl('pushover://uKey123/aToken456/')?.device).toBeUndefined();
expect(parsePushoverUrl('pover://uKey123@aToken456//phone')?.device).toBe('phone');
});
test('malformed URLs return null', () => {
expect(parsePushoverUrl('pushover://onlyuser')).toBeNull();
expect(parsePushoverUrl('pover://useronly')).toBeNull();
expect(parsePushoverUrl('invalid://user/token')).toBeNull();
expect(parsePushoverUrl('')).toBeNull();
});
});