Notification token on Windows

This commit is contained in:
Fedor Indutny 2025-02-03 14:30:19 -08:00 committed by GitHub
parent 74acb3a2dd
commit 22d30ec4eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 142 additions and 122 deletions

View file

@ -12,12 +12,12 @@ describe('renderWindowsToast', () => {
avatarPath: 'C:/temp/ab/abcd',
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
token: 'token',
type: NotificationType.Message,
});
const expected =
'<toast launch="sgnl://show-conversation?conversationId=conversation5" activationType="protocol"><visual><binding template="ToastImageAndText02"><image id="1" src="file:///C:/temp/ab/abcd" hint-crop="circle"></image><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
'<toast launch="sgnl://show-conversation?token=token" activationType="protocol"><visual><binding template="ToastImageAndText02"><image id="1" src="file:///C:/temp/ab/abcd" hint-crop="circle"></image><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
assert.strictEqual(xml, expected);
});
@ -26,12 +26,12 @@ describe('renderWindowsToast', () => {
const xml = renderWindowsToast({
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
token: 'token',
type: NotificationType.Message,
});
const expected =
'<toast launch="sgnl://show-conversation?conversationId=conversation5" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
'<toast launch="sgnl://show-conversation?token=token" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
assert.strictEqual(xml, expected);
});
@ -40,14 +40,12 @@ describe('renderWindowsToast', () => {
const xml = renderWindowsToast({
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
messageId: 'message6',
storyId: 'story7',
token: 'token',
type: NotificationType.Message,
});
const expected =
'<toast launch="sgnl://show-conversation?conversationId=conversation5&amp;messageId=message6&amp;storyId=story7" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
'<toast launch="sgnl://show-conversation?token=token" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
assert.strictEqual(xml, expected);
});
@ -56,7 +54,7 @@ describe('renderWindowsToast', () => {
const xml = renderWindowsToast({
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
token: 'token',
type: NotificationType.IncomingCall,
});
@ -70,12 +68,12 @@ describe('renderWindowsToast', () => {
const xml = renderWindowsToast({
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
token: 'token',
type: NotificationType.IncomingGroupCall,
});
const expected =
'<toast launch="sgnl://start-call-lobby?conversationId=conversation5" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
'<toast launch="sgnl://start-call-lobby?token=token" activationType="protocol"><visual><binding template="ToastText02"><text id="1">Alice</text><text id="2">Hi there!</text></binding></visual></toast>';
assert.strictEqual(xml, expected);
});
@ -84,7 +82,7 @@ describe('renderWindowsToast', () => {
const xml = renderWindowsToast({
body: 'Hi there!',
heading: 'Alice',
conversationId: 'conversation5',
token: 'token',
type: NotificationType.IsPresenting,
});

View file

@ -186,37 +186,23 @@ describe('signalRoutes', () => {
it('showConversation', () => {
const check = createCheck({ isRoute: true, hasWebUrl: false });
const args1 = `conversationId=${foo}`;
const args2 = `conversationId=${foo}&messageId=${foo}`;
const args3 = `conversationId=${foo}&messageId=${foo}&storyId=${foo}`;
const args1 = `token=${foo}`;
const result1: ParsedSignalRoute = {
key: 'showConversation',
args: { conversationId: foo, messageId: null, storyId: null },
};
const result2: ParsedSignalRoute = {
key: 'showConversation',
args: { conversationId: foo, messageId: foo, storyId: null },
};
const result3: ParsedSignalRoute = {
key: 'showConversation',
args: { conversationId: foo, messageId: foo, storyId: foo },
args: { token: foo },
};
check(`sgnl://show-conversation/?${args1}`, result1);
check(`sgnl://show-conversation?${args1}`, result1);
check(`sgnl://show-conversation/?${args2}`, result2);
check(`sgnl://show-conversation?${args2}`, result2);
check(`sgnl://show-conversation/?${args3}`, result3);
check(`sgnl://show-conversation?${args3}`, result3);
});
it('startCallLobby', () => {
const result: ParsedSignalRoute = {
key: 'startCallLobby',
args: { conversationId: foo },
args: { token: foo },
};
const check = createCheck({ isRoute: true, hasWebUrl: false });
check(`sgnl://start-call-lobby/?conversationId=${foo}`, result);
check(`sgnl://start-call-lobby?conversationId=${foo}`, result);
check(`sgnl://start-call-lobby/?token=${foo}`, result);
check(`sgnl://start-call-lobby?token=${foo}`, result);
});
it('showWindow', () => {