From 831922c247b0a5f5b5ba53d27192f0a3d7b09fcc Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Thu, 18 Sep 2025 14:23:54 -0400 Subject: [PATCH] Fixed callers directly passing `true` to `to` --- test/abilities/good-as-gold.test.ts | 2 +- test/moves/fissure.test.ts | 3 +-- test/moves/focus-punch.test.ts | 5 ++--- test/mystery-encounter/encounter-test-utils.ts | 13 +++++++------ test/test-utils/mocks/mock-phase.ts | 2 +- test/test-utils/phase-interceptor.ts | 6 +++++- .../test-utils/tests/phase-interceptor/unit.test.ts | 6 +++--- test/ui/battle-info.test.ts | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/test/abilities/good-as-gold.test.ts b/test/abilities/good-as-gold.test.ts index c6b6faf8349..39c5045505f 100644 --- a/test/abilities/good-as-gold.test.ts +++ b/test/abilities/good-as-gold.test.ts @@ -102,7 +102,7 @@ describe("Abilities - Good As Gold", () => { game.move.select(MoveId.HELPING_HAND, 0); game.move.select(MoveId.TACKLE, 1); - await game.phaseInterceptor.to("MoveEndPhase", true); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.getPlayerField()[1].getTag(BattlerTagType.HELPING_HAND)).toBeUndefined(); }); diff --git a/test/moves/fissure.test.ts b/test/moves/fissure.test.ts index b5255d75d73..06c64621dc6 100644 --- a/test/moves/fissure.test.ts +++ b/test/moves/fissure.test.ts @@ -3,7 +3,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; import type { EnemyPokemon, PlayerPokemon } from "#field/pokemon"; -import { DamageAnimPhase } from "#phases/damage-anim-phase"; import { TurnEndPhase } from "#phases/turn-end-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; @@ -50,7 +49,7 @@ describe("Moves - Fissure", () => { game.override.ability(AbilityId.NO_GUARD).enemyAbility(AbilityId.FUR_COAT); game.move.select(MoveId.FISSURE); - await game.phaseInterceptor.to(DamageAnimPhase, true); + await game.phaseInterceptor.to("DamageAnimPhase"); expect(enemyPokemon.isFainted()).toBe(true); }); diff --git a/test/moves/focus-punch.test.ts b/test/moves/focus-punch.test.ts index d7b40569aaa..202cab51294 100644 --- a/test/moves/focus-punch.test.ts +++ b/test/moves/focus-punch.test.ts @@ -123,9 +123,8 @@ describe("Moves - Focus Punch", () => { await game.classicMode.startBattle([SpeciesId.CHARIZARD]); game.move.select(MoveId.FOCUS_PUNCH); - await game.phaseInterceptor.to("MoveEndPhase", true); - await game.phaseInterceptor.to("MessagePhase", false); - await game.phaseInterceptor.to("MoveEndPhase", true); + await game.phaseInterceptor.to("MoveEndPhase"); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.textInterceptor.logs).toContain(i18next.t("moveTriggers:lostFocus", { pokemonName: "Charizard" })); expect(game.textInterceptor.logs).not.toContain(i18next.t("battle:attackFailed")); }); diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 6a4b7025f1c..884a91a3d2a 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -5,11 +5,9 @@ import { StatusEffect } from "#enums/status-effect"; import { UiMode } from "#enums/ui-mode"; // biome-ignore lint/performance/noNamespaceImport: Necessary for mocks import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; -import { MessagePhase } from "#phases/message-phase"; import { MysteryEncounterBattlePhase, MysteryEncounterRewardsPhase } from "#phases/mystery-encounter-phases"; import { VictoryPhase } from "#phases/victory-phase"; import type { GameManager } from "#test/test-utils/game-manager"; -import { MockConsole } from "#test/test-utils/mocks/mock-console/mock-console"; import type { MessageUiHandler } from "#ui/message-ui-handler"; import type { MysteryEncounterUiHandler } from "#ui/mystery-encounter-ui-handler"; import type { OptionSelectUiHandler } from "#ui/option-select-ui-handler"; @@ -47,7 +45,7 @@ export async function runMysteryEncounterToEnd( return await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); } if (game.scene.battleStyle === BattleStyle.SWITCH) { - MockConsole.queuePostTestWarning("BattleStyle.SWITCH was used during a test case, swapping to set mode..."); + console.warn("BattleStyle.SWITCH was used during ME battle, swapping to set mode..."); game.settings.battleStyle(BattleStyle.SET); } await game.toNextTurn(); @@ -69,7 +67,7 @@ export async function runSelectMysteryEncounterOption( () => game.isCurrentPhase("MysteryEncounterOptionSelectedPhase", "CommandPhase", "TurnInitPhase"), ); - if (game.isCurrentPhase(MessagePhase)) { + if (game.isCurrentPhase("MessagePhase")) { await game.phaseInterceptor.to("MessagePhase"); } @@ -84,7 +82,7 @@ export async function runSelectMysteryEncounterOption( () => game.isCurrentPhase("MysteryEncounterOptionSelectedPhase", "CommandPhase", "TurnInitPhase"), ); - await game.phaseInterceptor.to("MysteryEncounterPhase", true); + await game.phaseInterceptor.to("MysteryEncounterPhase"); // select the desired option const uiHandler = game.scene.ui.getHandler(); @@ -154,7 +152,10 @@ async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, * @param game * @param runRewardsPhase */ -export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManager, runRewardsPhase = true) { +export async function skipBattleRunMysteryEncounterRewardsPhase( + game: GameManager, + runRewardsPhase?: false | undefined, +) { game.scene.phaseManager.clearPhaseQueue(); game.scene.phaseManager.clearPhaseQueueSplice(); game.scene.getEnemyParty().forEach(p => { diff --git a/test/test-utils/mocks/mock-phase.ts b/test/test-utils/mocks/mock-phase.ts index 6a64c7472e5..a970356b3d5 100644 --- a/test/test-utils/mocks/mock-phase.ts +++ b/test/test-utils/mocks/mock-phase.ts @@ -6,7 +6,7 @@ import { Phase } from "#app/phase"; */ export abstract class mockPhase extends Phase { public phaseName: any; - start() { + public override start() { this.end(); } } diff --git a/test/test-utils/phase-interceptor.ts b/test/test-utils/phase-interceptor.ts index 2107eb65108..0194cbf5fd4 100644 --- a/test/test-utils/phase-interceptor.ts +++ b/test/test-utils/phase-interceptor.ts @@ -87,7 +87,6 @@ export class PhaseInterceptor { * @param target - The name of the {@linkcode Phase} to transition to * @param runTarget - Whether or not to run the target phase before resolving; default `true` * @returns A Promise that resolves once `target` has been reached. - * @todo remove `Constructor` from type signature in favor of phase strings * @remarks * This will not resolve for _any_ reason until the target phase has been reached. * @example @@ -95,6 +94,11 @@ export class PhaseInterceptor { * await game.phaseInterceptor.to("MoveEffectPhase", false); * ``` */ + public async to(target: PhaseString, runTarget?: boolean): Promise; + /** + * @deprecated Use `PhaseString` instead for `target` + */ + public async to(target: Constructor, runTarget?: boolean): Promise; public async to(target: PhaseString | Constructor, runTarget = true): Promise { this.target = typeof target === "string" ? target : (target.name as PhaseString); diff --git a/test/test-utils/tests/phase-interceptor/unit.test.ts b/test/test-utils/tests/phase-interceptor/unit.test.ts index de4283c3af4..8c44206488c 100644 --- a/test/test-utils/tests/phase-interceptor/unit.test.ts +++ b/test/test-utils/tests/phase-interceptor/unit.test.ts @@ -60,9 +60,9 @@ describe("Utils - Phase Interceptor - Unit", () => { * @param phases - An array of constructors to {@linkcode Phase}s to set. * Constructors must have no arguments. */ - function setPhases(phase: Constructor, ...phases: Constructor[]) { + function setPhases(...phases: [Constructor, ...Constructor[]]) { game.scene.phaseManager.clearAllPhases(); - game.scene.phaseManager.phaseQueue = [phase, ...phases].map(m => new m()) as Phase[]; + game.scene.phaseManager.phaseQueue = phases.map(m => new m()) as Phase[]; game.scene.phaseManager.shiftPhase(); // start the thing going } @@ -77,7 +77,7 @@ describe("Utils - Phase Interceptor - Unit", () => { } /** Wrapper function to make TS not complain about incompatible argument typing on `PhaseString`. */ - function to(phaseName: string, runTarget = true) { + function to(phaseName: string, runTarget?: false): Promise { return game.phaseInterceptor.to(phaseName as unknown as PhaseString, runTarget); } diff --git a/test/ui/battle-info.test.ts b/test/ui/battle-info.test.ts index 6588064d63f..4e77b880e42 100644 --- a/test/ui/battle-info.test.ts +++ b/test/ui/battle-info.test.ts @@ -48,7 +48,7 @@ describe.todo("UI - Battle Info", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to("ExpPhase", true); + await game.phaseInterceptor.to("ExpPhase"); expect(Math.pow).not.toHaveBeenCalledWith(2, expGainsSpeed); },