mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Generalize and extend notification channel type behaviour
This commit is contained in:
@@ -16,7 +16,8 @@ import {
|
||||
getPresetConfigPath,
|
||||
getTestConfigPath,
|
||||
getTestFolder,
|
||||
instantiateFromConfig, removeFolder,
|
||||
instantiateFromConfig,
|
||||
removeFolder,
|
||||
} from './Config';
|
||||
import quad = DataFactory.quad;
|
||||
import namedNode = DataFactory.namedNode;
|
||||
@@ -26,7 +27,7 @@ const baseUrl = `http://localhost:${port}/`;
|
||||
const clientPort = getPort('WebHookSubscription2021-client');
|
||||
const target = `http://localhost:${clientPort}/`;
|
||||
const webId = 'http://example.com/card/#me';
|
||||
const notificationType = 'WebHookSubscription2021';
|
||||
const notificationType = NOTIFY.WebHookSubscription2021;
|
||||
|
||||
const rootFilePath = getTestFolder('WebHookSubscription2021');
|
||||
const stores: [string, any][] = [
|
||||
@@ -109,7 +110,7 @@ describe.each(stores)('A server supporting WebHookSubscription2021 using %s', (n
|
||||
});
|
||||
|
||||
it('supports subscribing.', async(): Promise<void> => {
|
||||
await subscribe(notificationType, webId, subscriptionUrl, topic, { target });
|
||||
await subscribe(notificationType, webId, subscriptionUrl, topic, { [NOTIFY.target]: target });
|
||||
});
|
||||
|
||||
it('emits Created events.', async(): Promise<void> => {
|
||||
@@ -168,7 +169,7 @@ describe.each(stores)('A server supporting WebHookSubscription2021 using %s', (n
|
||||
});
|
||||
});
|
||||
|
||||
await subscribe(notificationType, webId, subscriptionUrl, topic, { target, state: 'abc' });
|
||||
await subscribe(notificationType, webId, subscriptionUrl, topic, { [NOTIFY.target]: target, state: 'abc' });
|
||||
|
||||
// Will resolve even though the resource did not change since subscribing
|
||||
const { request, response } = await clientPromise;
|
||||
|
||||
@@ -14,14 +14,15 @@ import {
|
||||
getPresetConfigPath,
|
||||
getTestConfigPath,
|
||||
getTestFolder,
|
||||
instantiateFromConfig, removeFolder,
|
||||
instantiateFromConfig,
|
||||
removeFolder,
|
||||
} from './Config';
|
||||
import quad = DataFactory.quad;
|
||||
import namedNode = DataFactory.namedNode;
|
||||
|
||||
const port = getPort('WebSocketSubscription2021');
|
||||
const baseUrl = `http://localhost:${port}/`;
|
||||
const notificationType = 'WebSocketSubscription2021';
|
||||
const notificationType = NOTIFY.WebSocketSubscription2021;
|
||||
|
||||
const rootFilePath = getTestFolder('WebSocketSubscription2021');
|
||||
const stores: [string, any][] = [
|
||||
@@ -166,7 +167,7 @@ describe.each(stores)('A server supporting WebSocketSubscription2021 using %s',
|
||||
|
||||
const channel = {
|
||||
'@context': [ 'https://www.w3.org/ns/solid/notification/v1' ],
|
||||
type: 'WebSocketSubscription2021',
|
||||
type: NOTIFY.WebSocketSubscription2021,
|
||||
topic: restricted,
|
||||
};
|
||||
|
||||
@@ -212,7 +213,8 @@ describe.each(stores)('A server supporting WebSocketSubscription2021 using %s',
|
||||
});
|
||||
|
||||
it('removes expired channels.', async(): Promise<void> => {
|
||||
const { source } = await subscribe(notificationType, webId, subscriptionUrl, topic, { endAt: 1 }) as any;
|
||||
const { source } =
|
||||
await subscribe(notificationType, webId, subscriptionUrl, topic, { endAt: '1988-03-09T14:48:00.000Z' }) as any;
|
||||
|
||||
const socket = new WebSocket(source);
|
||||
const messagePromise = new Promise<Buffer>((resolve): any => socket.on('message', resolve));
|
||||
|
||||
Reference in New Issue
Block a user