From c4f81c55b0ba135581bdaba743e9d4895fddf5d7 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:32:07 -0700 Subject: [PATCH] [Tests][Mystery-Encounter] Fix `The Strong Stuff` flakyness (#4394) * extend: log in encounter phase for better debugging * fix: `the storng stuff` test flakiness The enemy pokemon could get contrary or other abilities that cause the expected values to be ... not as expected * remove accidental it.each tests were being executed 30-100 times. This is a debugging tool but was never supposed to make it to merge. --- .../utils/encounter-phase-utils.ts | 2 +- src/phases/encounter-phase.ts | 2 +- .../an-offer-you-cant-refuse-encounter.test.ts | 2 +- .../encounters/the-strong-stuff-encounter.test.ts | 12 ++++++++---- src/test/reload.test.ts | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 7eb205ce3f7..ef4f396b823 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -339,7 +339,7 @@ export async function initBattleWithEnemyConfig(scene: BattleScene, partyConfig: loadEnemyAssets.push(enemyPokemon.loadAssets()); - console.log(enemyPokemon.name, enemyPokemon.species.speciesId, enemyPokemon.stats); + console.log(`Pokemon: ${enemyPokemon.name}`, `Species ID: ${enemyPokemon.species.speciesId}`, `Stats: ${enemyPokemon.stats}`, `Ability: ${enemyPokemon.getAbility().name}`, `Passive Ability: ${enemyPokemon.getPassiveAbility().name}`); }); scene.pushPhase(new MysteryEncounterBattlePhase(scene, partyConfig.disableSwitch)); diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index cead9de0fc6..16b907f5d95 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -141,7 +141,7 @@ export class EncounterPhase extends BattlePhase { loadEnemyAssets.push(enemyPokemon.loadAssets()); - console.log(getPokemonNameWithAffix(enemyPokemon), enemyPokemon.species.speciesId, enemyPokemon.stats); + console.log(`Pokemon: ${getPokemonNameWithAffix(enemyPokemon)}`, `Species ID: ${enemyPokemon.species.speciesId}`, `Stats: ${enemyPokemon.stats}`, `Ability: ${enemyPokemon.getAbility().name}`, `Passive Ability: ${enemyPokemon.getPassiveAbility().name}`); return true; }); diff --git a/src/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts b/src/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts index c39e636b462..88704746a3c 100644 --- a/src/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts +++ b/src/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts @@ -231,7 +231,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { }); describe("Option 3 - Leave", () => { - it.each(Array.from({length: 30}))("should leave encounter without battle", async () => { + it("should leave encounter without battle", async () => { const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, defaultParty); diff --git a/src/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts b/src/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts index 5c1353ee337..4bcb063fff0 100644 --- a/src/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts +++ b/src/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts @@ -25,6 +25,7 @@ import { MysteryEncounterPokemonData } from "#app/data/mystery-encounters/myster import { CommandPhase } from "#app/phases/command-phase"; import { MovePhase } from "#app/phases/move-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; +import { Abilities } from "#app/enums/abilities"; const namespace = "mysteryEncounter:theStrongStuff"; const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; @@ -43,10 +44,13 @@ describe("The Strong Stuff - Mystery Encounter", () => { beforeEach(async () => { game = new GameManager(phaserGame); scene = game.scene; - game.override.mysteryEncounterChance(100); - game.override.startingWave(defaultWave); - game.override.startingBiome(defaultBiome); - game.override.disableTrainerWaves(); + game.override + .mysteryEncounterChance(100) + .startingWave(defaultWave) + .startingBiome(defaultBiome) + .disableTrainerWaves() + .enemyAbility(Abilities.BALL_FETCH) + .enemyPassiveAbility(Abilities.BALL_FETCH); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ diff --git a/src/test/reload.test.ts b/src/test/reload.test.ts index 5009d76d1a7..7c4523dd9ef 100644 --- a/src/test/reload.test.ts +++ b/src/test/reload.test.ts @@ -35,7 +35,7 @@ describe("Reload", () => { expect(preReloadRngState).toBe(postReloadRngState); }, 20000); - it.each(Array.from({length: 100}))("should not have RNG inconsistencies after a biome switch", async () => { + it("should not have RNG inconsistencies after a biome switch", async () => { game.override .startingWave(10) .battleType("single")