From 1c21dd443f33fc11737624288ac5ec54ea0dd821 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 14:56:58 +0000 Subject: [PATCH] test(moderation): wire up userBlocks mock in app harness Override app.isAuthorBlocked in createModerationAppHarness when a userBlocks mock is provided. This ensures that application logic checking block status respects the mock state instead of querying the uninitialized global singleton, fixing the failure in handleModerationBlock tests. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- tests/helpers/moderation-test-helpers.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/helpers/moderation-test-helpers.mjs b/tests/helpers/moderation-test-helpers.mjs index 1b8b4431..4563db74 100644 --- a/tests/helpers/moderation-test-helpers.mjs +++ b/tests/helpers/moderation-test-helpers.mjs @@ -272,6 +272,16 @@ export async function createModerationAppHarness(options = {}) { app.getActiveModerationThresholds = Application.prototype.getActiveModerationThresholds; + if (options.userBlocks) { + app.isAuthorBlocked = function (pubkey) { + const normalized = this.normalizeHexPubkey(pubkey); + if (normalized && options.userBlocks.isBlocked(normalized)) { + return true; + } + return Application.prototype.isAuthorBlocked.call(this, pubkey); + }; + } + app.defaultModerationSettings = getDefaultModerationSettings(); app.moderationSettings = { ...app.defaultModerationSettings };