Bind Reddit and Matrix session identities

This commit is contained in:
jjbrunton committed 2026-08-08 19:43:35 +01:00
1 parent 34ae532cdd
commit 492efe0f8a
12 files changed
+234 -55

No files matched your search

+6 -2
View File
@@ -36,10 +36,10 @@ describe('BrowserClient', () => {
expect(JSON.stringify(logger)).not.toContain('secret');
});
it('reads the username from Reddit\'s nested me.json account response', async () => {
it('reads the username and stable account ID from Reddit\'s nested me.json response', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ kind: 't2', data: { name: 'bot-account' } }),
json: async () => ({ kind: 't2', data: { name: 'bot-account', id: 'abc123' } }),
});
vi.stubGlobal('fetch', fetchMock);
const page = {
@@ -50,6 +50,10 @@ describe('BrowserClient', () => {
const client = new BrowserClient(getTestConfig(), createLogger(), runtime);
await expect(client.getAuthenticatedUsername()).resolves.toBe('bot-account');
await expect(client.getAuthenticatedIdentity()).resolves.toEqual({
username: 'bot-account',
accountId: 't2_abc123',
});
expect(fetchMock).toHaveBeenCalledWith(
'https://www.reddit.com/api/me.json',
{ credentials: 'include' },