Skip to content

Commit c9bf49f

Browse files
author
Sorra
authored
Merge pull request #414 from TheWizardsCode/copilot/fix-golfscene-interaction-test
Fix flaky GolfScene AI-discard display bug and brittle timing in browser test
2 parents 952b50c + 0fb691f commit c9bf49f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

example-games/golf/scenes/GolfScene.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,13 @@ export class GolfScene extends CardGameScene {
934934
drawnCard = this.session.shared.discardPile.popOrThrow();
935935
}
936936

937-
// When AI draws from discard, update the pile visual immediately
937+
// When AI draws from discard, refresh the pile display to show the new
938+
// top card (or empty placeholder). The card has already been popped, so
939+
// we use refreshPiles() — updateDiscardPileAfterDraw() is designed for
940+
// the human peek-not-pop path and would incorrectly compute the display
941+
// when the card is already removed from the pile.
938942
if (drawSource === 'discard') {
939-
this.updateDiscardPileAfterDraw();
943+
this.refreshPiles();
940944
}
941945

942946
// Show the drawn card to the player

tests/golf/GolfInteraction.browser.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,10 @@ describe('GolfScene interaction tests', () => {
363363
// Swap with grid card 0
364364
clickGameObject(internals.humanCardSprites[0]);
365365

366-
// Wait for AI to take its turn (AI_DELAY = 600ms + animation time)
367-
await wait(3000);
366+
// Wait for both the human animation and the full AI turn to complete.
367+
// Using a phase-based wait is more reliable than a fixed timeout in CI,
368+
// as it polls until the game returns to a stable state.
369+
await waitForAnyPhase(scene, ['waiting-for-draw', 'round-ended'], 15000);
368370

369371
// After AI turn, it should be human's turn again (or round ended)
370372
const phase = internals.phaseManager.current;

0 commit comments

Comments
 (0)