fix: improve plugins functionality with server management

This commit is contained in:
2026-04-29 20:33:54 +02:00
parent b8f6d58d99
commit fa2cca6fa4
82 changed files with 1708 additions and 303 deletions

View File

@@ -1,7 +1,4 @@
import {
reconcileRoomSnapshotChannels,
sanitizeRoomSnapshot
} from './rooms.helpers';
import { reconcileRoomSnapshotChannels, sanitizeRoomSnapshot } from './rooms.helpers';
describe('room snapshot helpers', () => {
it('drops empty channel arrays from outgoing snapshots', () => {
@@ -9,10 +6,9 @@ describe('room snapshot helpers', () => {
});
it('keeps cached channels when incoming snapshot has none', () => {
const cachedChannels = [
{ id: 'general', name: 'general', type: 'text', position: 0 },
{ id: 'updates', name: 'updates', type: 'text', position: 1 }
] as const;
const generalChannel = { id: 'general', name: 'general', type: 'text', position: 0 } as const;
const updatesChannel = { id: 'updates', name: 'updates', type: 'text', position: 1 } as const;
const cachedChannels = [generalChannel, updatesChannel] as const;
expect(reconcileRoomSnapshotChannels(cachedChannels as never, undefined)).toEqual(cachedChannels);
expect(reconcileRoomSnapshotChannels(cachedChannels as never, [] as never)).toEqual(cachedChannels);
@@ -24,21 +20,16 @@ describe('room snapshot helpers', () => {
{ id: 'updates', name: 'updates', type: 'text', position: 1 },
{ id: 'voice', name: 'General', type: 'voice', position: 0 }
] as const;
const incomingChannels = [
{ id: 'general', name: 'general', type: 'text', position: 0 }
] as const;
const incomingChannels = [{ id: 'general', name: 'general', type: 'text', position: 0 }] as const;
expect(reconcileRoomSnapshotChannels(cachedChannels as never, incomingChannels as never)).toEqual(cachedChannels);
});
it('accepts incoming channels when snapshot is at least as complete', () => {
const cachedChannels = [
{ id: 'general', name: 'general', type: 'text', position: 0 }
] as const;
const incomingChannels = [
{ id: 'general', name: 'general', type: 'text', position: 0 },
{ id: 'updates', name: 'updates', type: 'text', position: 1 }
] as const;
const generalChannel = { id: 'general', name: 'general', type: 'text', position: 0 } as const;
const updatesChannel = { id: 'updates', name: 'updates', type: 'text', position: 1 } as const;
const cachedChannels = [generalChannel] as const;
const incomingChannels = [generalChannel, updatesChannel] as const;
expect(reconcileRoomSnapshotChannels(cachedChannels as never, incomingChannels as never)).toEqual(incomingChannels);
});