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 <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-27 14:56:58 +00:00
1 parent b75e1cdc42
commit 1c21dd443f
1 file changed
+10
+10
View File
@@ -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 };