refactor: events to a pure stream instead of being part of topics

NOTE: tests are passing, but the client is broken
This commit is contained in:
Andy Burke 2025-11-08 11:55:57 -08:00
parent c34069066d
commit a5707e2f81
31 changed files with 934 additions and 686 deletions

View file

@ -0,0 +1,58 @@
import { api, API_CLIENT } from '../utils/api.ts';
import * as asserts from '@std/assert';
import { delete_user, EPHEMERAL_SERVER, get_ephemeral_listen_server, get_new_user, set_user_permissions } from './helpers.ts';
import { generateTotp } from '../utils/totp.ts';
Deno.test({
name: 'API - CHANNELS - Delete',
permissions: {
env: true,
read: true,
write: true,
net: true
},
fn: async () => {
let test_server_info: EPHEMERAL_SERVER | null = null;
try {
test_server_info = await get_ephemeral_listen_server();
const client: API_CLIENT = api({
prefix: '/api',
hostname: test_server_info.hostname,
port: test_server_info.port
});
const info = await get_new_user(client);
await set_user_permissions(client, info.user, info.session, [...info.user.permissions, 'channels.create']);
const new_channel = await client.fetch('/channels', {
method: 'POST',
headers: {
'x-session_id': info.session.id,
'x-totp': await generateTotp(info.session.secret)
},
json: {
name: 'test delete channel'
}
});
asserts.assert(new_channel);
const deleted_channel = await client.fetch(`/channels/${new_channel.id}`, {
method: 'DELETE',
headers: {
'x-session_id': info.session.id,
'x-totp': await generateTotp(info.session.secret)
}
});
asserts.assert(deleted_channel);
await delete_user(client, info);
} finally {
if (test_server_info) {
await test_server_info?.server?.stop();
}
}
}
});