diff --git a/test/testUtils/gameWrapper.ts b/test/testUtils/gameWrapper.ts index 050e9f13257..9264b68d421 100644 --- a/test/testUtils/gameWrapper.ts +++ b/test/testUtils/gameWrapper.ts @@ -21,6 +21,8 @@ import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin; import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin; import EventEmitter = Phaser.Events.EventEmitter; import UpdateList = Phaser.GameObjects.UpdateList; +import { PokedexMonContainer } from "#app/ui/pokedex-mon-container"; +import MockContainer from "./mocks/mocksContainer/mockContainer"; // biome-ignore lint/style/noNamespaceImport: Necessary in order to mock the var import * as bypassLoginModule from "#app/global-vars/bypass-login"; @@ -61,6 +63,10 @@ export default class GameWrapper { } }; BattleScene.prototype.addPokemonIcon = () => new Phaser.GameObjects.Container(this.scene); + + // Pokedex container is not actually mocking container, but the sprites they contain are mocked. + // We need to mock the remove function to not throw an error when removing a sprite. + PokedexMonContainer.prototype.remove = MockContainer.prototype.remove; } setScene(scene: BattleScene) { diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 3d56c513c00..fffbf12ad16 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -205,6 +205,7 @@ export default class PhaseInterceptor { private phaseFrom; private inProgress; private originalSetMode; + private originalSetOverlayMode; private originalSuperEnd; /** @@ -442,6 +443,7 @@ export default class PhaseInterceptor { */ initPhases() { this.originalSetMode = UI.prototype.setMode; + this.originalSetOverlayMode = UI.prototype.setOverlayMode; this.originalSuperEnd = Phase.prototype.end; UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args); Phase.prototype.end = () => this.superEndPhase.call(this); @@ -508,6 +510,18 @@ export default class PhaseInterceptor { return ret; } + /** + * mock to set overlay mode + * @param mode - The {@linkcode Mode} to set. + * @param args - Additional arguments to pass to the original method. + */ + setOverlayMode(mode: Mode, ...args: unknown[]): Promise { + const instance = this.scene.ui; + console.log("setOverlayMode", `${Mode[mode]} (=${mode})`, args); + const ret = this.originalSetOverlayMode.apply(instance, [mode, ...args]); + return ret; + } + /** * Method to start the prompt handler. */ @@ -572,6 +586,7 @@ export default class PhaseInterceptor { phase.prototype.start = this.phases[phase.name].start; } UI.prototype.setMode = this.originalSetMode; + UI.prototype.setOverlayMode = this.originalSetOverlayMode; Phase.prototype.end = this.originalSuperEnd; clearInterval(this.promptInterval); clearInterval(this.interval);