From 8e729d995511d9a7b42d2773aae34e2e988196c7 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 6 Aug 2025 23:23:50 -0400 Subject: [PATCH] Added logging blacklist for `ActivatePriorityQueuePhase` --- test/test-utils/phase-interceptor.ts | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/test/test-utils/phase-interceptor.ts b/test/test-utils/phase-interceptor.ts index ea580976aff..961d38e9249 100644 --- a/test/test-utils/phase-interceptor.ts +++ b/test/test-utils/phase-interceptor.ts @@ -6,12 +6,18 @@ import { UiMode } from "#enums/ui-mode"; // biome-ignore-start lint/correctness/noUnusedImports: TSDoc imports import type { GameManager } from "#test/test-utils/game-manager"; import type { PromptHandler } from "#test/test-utils/helpers/prompt-handler"; -import { setTimeout } from "timers/promises"; // biome-ignore-end lint/correctness/noUnusedImports: TSDoc imports import { format } from "util"; import chalk from "chalk"; import { vi } from "vitest"; +/** + * A Set containing phase names that will not be shown in the console when started. + * + * Used to reduce console noise from very repetitive phases. + */ +const blacklistedPhaseNames: ReadonlySet = new Set(["ActivatePriorityQueuePhase"]); + /** * The interceptor's current state. * Possible values are the following: @@ -28,8 +34,8 @@ type StateType = "running" | "interrupted" | "idling"; export class PhaseInterceptor { private scene: BattleScene; /** - * A log of phases having been executed. - * Entries are appended each time {@linkcode run} is called, and can be cleared with {@linkcode clearLogs}. + * A log containing all phases having been executed in FIFO order. \ + * Entries are appended each time {@linkcode run} is called, and can be cleared manually with {@linkcode clearLogs}. */ public log: PhaseString[] = []; /** @@ -181,9 +187,10 @@ export class PhaseInterceptor { /** * Deprecated no-op function. * - * This was previously used to reset timers created using `setInterval` on test end. - * However, since we now use standard async functions to run phases, - * this function has become a no-op. + * This was previously used to reset timers created using `setInterval` to wait for phase end + * and undo various method stubs upon a test ending. \ + * However, since we now use {@linkcode vi.waitUntil} and {@linkcode vi.spyOn} to perform these tasks + * respectively, this function has become no longer needed. * @deprecated This is no longer needed and will be removed in a future PR */ public restoreOg() {} @@ -193,23 +200,24 @@ export class PhaseInterceptor { * @param phaseName - The name of the phase to log. */ private logPhase(phaseName: PhaseString) { - this.doLog(`Start Phase ${phaseName}`); + if (!blacklistedPhaseNames.has(phaseName)) { + this.doLog(`Starting Phase: ${phaseName}`); + } this.log.push(phaseName); } /** - * Clears phase logs + * Clear all prior phase logs. */ public clearLogs(): void { this.log = []; } /** - * Wrapper function to add green coloration to phase logs. + * Wrapper function to add coral coloration to phase logs. * @param args - Arguments to original logging function. */ private doLog(...args: unknown[]): void { - // Use chalk highlighting instead of normal green due to Node.js not respecting `%c` CSS color setting - console.log(chalk.green(...args)); + console.log(chalk.hex("#ff7f50")(...args)); } }