mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
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:
1 parent
b75e1cdc42
commit
1c21dd443f
1 file changed
+10
@@ -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 };
|
||||
|
||||
|
||||
Reference in new issue
Block a user