From 62aea1ad8dad0dc5559b74ae10a748a47cd40fdc Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 6 Aug 2025 23:16:17 -0400 Subject: [PATCH] Fixed `didLog` to not start phases again when interrupted --- test/test-utils/phase-interceptor.ts | 10 ++++++---- test/test-utils/tests/helpers/prompt-handler.test.ts | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/test-utils/phase-interceptor.ts b/test/test-utils/phase-interceptor.ts index fb7e2329f38..ea580976aff 100644 --- a/test/test-utils/phase-interceptor.ts +++ b/test/test-utils/phase-interceptor.ts @@ -82,9 +82,11 @@ export class PhaseInterceptor { async () => { // If we were interrupted by a UI prompt, we assume that the calling code will queue inputs to // end the current phase manually, so we just wait for the phase to end from the caller. - if (this.state === "interrupted" && !didLog) { - this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!"); - didLog = true; + if (this.state === "interrupted") { + if (!didLog) { + this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!"); + didLog = true; + } return false; } @@ -102,7 +104,7 @@ export class PhaseInterceptor { await this.run(currentPhase); return false; }, - { interval: 0, timeout: 5_000 }, + { interval: 0, timeout: 20_000 }, ); // We hit the target; run as applicable and wrap up. diff --git a/test/test-utils/tests/helpers/prompt-handler.test.ts b/test/test-utils/tests/helpers/prompt-handler.test.ts index 2b313406cdb..4169e946dbe 100644 --- a/test/test-utils/tests/helpers/prompt-handler.test.ts +++ b/test/test-utils/tests/helpers/prompt-handler.test.ts @@ -44,7 +44,7 @@ describe("Test Utils - PromptHandler", () => { phaseManager: { getCurrentPhase: () => ({ - phaseName: "testDialoguePhase", + phaseName: "CommandPhase", }) as unknown as Phase, }, }, @@ -67,7 +67,7 @@ describe("Test Utils - PromptHandler", () => { } describe("setMode", () => { - it("should wrap and pass along original function arguments", async () => { + it("should wrap and pass along original function arguments from setModeInternal", async () => { const setModeSpy = vi.spyOn(promptHandler as any, "setMode"); promptHandler["game"].scene.ui["setModeInternal"](UiMode.PARTY, false, false, false, []); @@ -75,7 +75,7 @@ describe("Test Utils - PromptHandler", () => { expect(setModeCallback).toHaveBeenCalledAfter(setModeSpy); }); - it("should call PhaseInterceptor.checkMode", async () => { + it("should call PhaseInterceptor.checkMode if current phase in `endBySetMode`", async () => { promptHandler["game"].scene.ui["setModeInternal"](UiMode.PARTY, false, false, false, []); expect(checkModeCallback).toHaveBeenCalledOnce();