From 388cd1e6310193fe4ea3aef58baee4b4148d415c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Fri, 24 Oct 2025 21:43:02 -0400 Subject: [PATCH] Align profile modal moderation tests with dynamic defaults --- ...profile-modal-moderation-settings.test.mjs | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/ui/profile-modal-moderation-settings.test.mjs b/tests/ui/profile-modal-moderation-settings.test.mjs index de1ad73d..d9b2789f 100644 --- a/tests/ui/profile-modal-moderation-settings.test.mjs +++ b/tests/ui/profile-modal-moderation-settings.test.mjs @@ -3,12 +3,18 @@ import assert from "node:assert/strict"; import { JSDOM } from "jsdom"; import ProfileModalController from "../../js/ui/profileModalController.js"; -import { - DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, - DEFAULT_BLUR_THRESHOLD, - DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, - DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, -} from "../../js/constants.js"; +import { getDefaultModerationSettings } from "../../js/state/cache.js"; + +function createDefaultModerationSettingsSnapshot() { + return getDefaultModerationSettings(); +} + +const { + blurThreshold: DEFAULT_BLUR_THRESHOLD, + autoplayBlockThreshold: DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, + trustedMuteHideThreshold: DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, + trustedSpamHideThreshold: DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, +} = createDefaultModerationSettingsSnapshot(); const DEFAULT_BLUR_STRING = String(DEFAULT_BLUR_THRESHOLD); const DEFAULT_AUTOPLAY_STRING = String(DEFAULT_AUTOPLAY_BLOCK_THRESHOLD); @@ -77,29 +83,20 @@ beforeEach(async () => { }; }; - storedSettings = { - blurThreshold: DEFAULT_BLUR_THRESHOLD, - autoplayBlockThreshold: DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, - trustedMuteHideThreshold: DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, - trustedSpamHideThreshold: DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, - }; + storedSettings = { ...createDefaultModerationSettingsSnapshot() }; moderationService = { getDefaultModerationSettings() { - return { - blurThreshold: DEFAULT_BLUR_THRESHOLD, - autoplayBlockThreshold: DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, - trustedMuteHideThreshold: DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, - trustedSpamHideThreshold: DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, - }; + return createDefaultModerationSettingsSnapshot(); }, getActiveModerationSettings() { return { ...storedSettings }; }, updateModerationSettings(partial = {}) { + const defaults = createDefaultModerationSettingsSnapshot(); if (Object.prototype.hasOwnProperty.call(partial, "blurThreshold")) { const value = partial.blurThreshold; storedSettings.blurThreshold = - value === null ? DEFAULT_BLUR_THRESHOLD : value; + value === null ? defaults.blurThreshold : value; } if ( Object.prototype.hasOwnProperty.call( @@ -109,7 +106,7 @@ beforeEach(async () => { ) { const value = partial.autoplayBlockThreshold; storedSettings.autoplayBlockThreshold = - value === null ? DEFAULT_AUTOPLAY_BLOCK_THRESHOLD : value; + value === null ? defaults.autoplayBlockThreshold : value; } if ( Object.prototype.hasOwnProperty.call( @@ -119,7 +116,7 @@ beforeEach(async () => { ) { const value = partial.trustedMuteHideThreshold; storedSettings.trustedMuteHideThreshold = - value === null ? DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD : value; + value === null ? defaults.trustedMuteHideThreshold : value; } if ( Object.prototype.hasOwnProperty.call( @@ -129,17 +126,12 @@ beforeEach(async () => { ) { const value = partial.trustedSpamHideThreshold; storedSettings.trustedSpamHideThreshold = - value === null ? DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD : value; + value === null ? defaults.trustedSpamHideThreshold : value; } return { ...storedSettings }; }, resetModerationSettings() { - storedSettings = { - blurThreshold: DEFAULT_BLUR_THRESHOLD, - autoplayBlockThreshold: DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, - trustedMuteHideThreshold: DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, - trustedSpamHideThreshold: DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, - }; + storedSettings = { ...createDefaultModerationSettingsSnapshot() }; return { ...storedSettings }; }, };