Fix chat visibility and conversation sync
This commit is contained in:
1 parent
f4e8fdc42f
commit
34ae532cdd
10 files changed
+416
-23
No files matched your search
@@ -93,6 +93,65 @@ describe('MatrixClient HTTP timeout', () => {
|
||||
}, 10_000);
|
||||
});
|
||||
|
||||
describe('MatrixClient direct room registration', () => {
|
||||
it('creates rooms with the direct-message flag', async () => {
|
||||
let requestBody: unknown;
|
||||
const client = new MatrixClient(creds, createMockLogger(), {
|
||||
minRequestIntervalMs: 0,
|
||||
fetchImpl: vi.fn(async (_url, init) => {
|
||||
requestBody = JSON.parse(String(init?.body));
|
||||
return new Response(JSON.stringify({ room_id: '!new:example.test' }), {
|
||||
status: 200,
|
||||
headers: { 'content-type': 'application/json' },
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
await expect(client.createDirectRoom('@them:example.test'))
|
||||
.resolves.toBe('!new:example.test');
|
||||
expect(requestBody).toEqual({
|
||||
preset: 'reddit_dm',
|
||||
invite: ['@them:example.test'],
|
||||
is_direct: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('additively repairs m.direct account data without removing existing rooms', async () => {
|
||||
const requests: Array<{ method: string; url: string; body?: unknown }> = [];
|
||||
const client = new MatrixClient(creds, createMockLogger(), {
|
||||
minRequestIntervalMs: 0,
|
||||
fetchImpl: vi.fn(async (url, init) => {
|
||||
requests.push({
|
||||
method: init?.method ?? 'GET',
|
||||
url: String(url),
|
||||
...(init?.body ? { body: JSON.parse(String(init.body)) } : {}),
|
||||
});
|
||||
if (init?.method === 'GET') {
|
||||
return new Response(JSON.stringify({
|
||||
'@existing:example.test': ['!old:example.test'],
|
||||
'@them:example.test': ['!already:example.test'],
|
||||
}), { status: 200, headers: { 'content-type': 'application/json' } });
|
||||
}
|
||||
return new Response('{}', { status: 200, headers: { 'content-type': 'application/json' } });
|
||||
}),
|
||||
});
|
||||
|
||||
await expect(client.repairDirectRoomMappings([
|
||||
{ recipientMxid: '@them:example.test', roomId: '!already:example.test' },
|
||||
{ recipientMxid: '@them:example.test', roomId: '!new:example.test' },
|
||||
])).resolves.toBe(1);
|
||||
|
||||
expect(requests).toHaveLength(2);
|
||||
expect(requests[1]).toMatchObject({
|
||||
method: 'PUT',
|
||||
body: {
|
||||
'@existing:example.test': ['!old:example.test'],
|
||||
'@them:example.test': ['!already:example.test', '!new:example.test'],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('MatrixClient authentication classification', () => {
|
||||
it('does not classify a room-level 403 as an expired account token', async () => {
|
||||
const client = new MatrixClient(creds, createMockLogger(), {
|
||||
|
||||
Reference in new issue
Block a user