Pause suspended Reddit accounts

This commit is contained in:
jjbrunton committed 2026-08-14 16:00:37 +01:00
1 parent 94049ed9c4
commit 7d039265e7
21 files changed
+368 -26

No files matched your search

+15
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
import {
MatrixAuthError,
MatrixAccountSuspendedError,
MatrixClient,
MatrixFeatureDisabledError,
MatrixRateLimitError,
@@ -186,6 +187,20 @@ describe('MatrixClient direct room registration', () => {
});
describe('MatrixClient authentication classification', () => {
it('calls the account pause hook and throws a typed error for M_FORBIDDEN', async () => {
const onAccountSuspended = vi.fn();
const client = new MatrixClient(creds, createMockLogger(), {
minRequestIntervalMs: 0,
onAccountSuspended,
fetchImpl: vi.fn().mockResolvedValue(new Response(JSON.stringify({
errcode: 'M_FORBIDDEN', error: 'User is suspended',
}), { status: 403, headers: { 'content-type': 'application/json' } })),
});
await expect(client.whoami()).rejects.toBeInstanceOf(MatrixAccountSuspendedError);
expect(onAccountSuspended).toHaveBeenCalledOnce();
});
it('classifies an explicitly disabled endpoint as an unavailable feature', async () => {
const client = new MatrixClient(creds, createMockLogger(), {
minRequestIntervalMs: 0,