diff --git a/ai_animation/tests/e2e/game-playthrough.spec.ts b/ai_animation/tests/e2e/game-playthrough.spec.ts index 63242d8..89afa7b 100644 --- a/ai_animation/tests/e2e/game-playthrough.spec.ts +++ b/ai_animation/tests/e2e/game-playthrough.spec.ts @@ -41,11 +41,11 @@ test.describe('Game Playthrough Tests', () => { // Verify that victory message was displayed for a reasonable amount of time expect(result.displayDuration).toBeGreaterThan(50); // At least 50ms (reduced for instant mode) - // The victory message should still be visible when we detect it + // The victory modal should still be visible when we detect it if (result.victoryDetected) { const currentVictoryMessage = await checkForVictoryMessage(page); if (currentVictoryMessage) { - await expect(page.locator('#news-banner-content')).toContainText(/GAME OVER|VICTORIOUS|🏆/); + await expect(page.locator('.victory-modal-overlay')).toBeVisible(); } } }); @@ -85,7 +85,6 @@ test.describe('Game Playthrough Tests', () => { await expect(page.locator('#prev-btn')).toBeVisible(); await expect(page.locator('#next-btn')).toBeVisible(); await expect(page.locator('canvas')).toBeVisible(); - await expect(page.locator('#news-banner-content')).toBeVisible(); await expect(page.locator('#phase-display')).toBeVisible(); await expect(page.locator('#game-id-display')).toBeVisible(); diff --git a/ai_animation/tests/e2e/test-helpers.ts b/ai_animation/tests/e2e/test-helpers.ts index 77c578c..5774b82 100644 --- a/ai_animation/tests/e2e/test-helpers.ts +++ b/ai_animation/tests/e2e/test-helpers.ts @@ -37,15 +37,18 @@ export async function stopGamePlayback(page: Page): Promise { } /** - * Helper function to check if a victory message is present + * Helper function to check if a victory message is present (checks for victory modal) */ export async function checkForVictoryMessage(page: Page): Promise { try { - const newsText = await page.locator('#news-banner-content').textContent(); - const victoryPattern = /GAME OVER.*WINS|VICTORIOUS|🏆.*WINS/i; - - if (newsText && victoryPattern.test(newsText)) { - return newsText; + // Check for victory modal + const victoryModal = page.locator('.victory-modal-overlay'); + if (await victoryModal.isVisible()) { + // Extract victory message from modal + const winnerText = await victoryModal.locator('h2').textContent(); + if (winnerText) { + return winnerText; + } } return null; } catch { @@ -127,11 +130,12 @@ export async function measureVictoryTiming( break; } - // Check if victory message disappeared (indicating new game started) - const currentVictoryMessage = await checkForVictoryMessage(page); - if (!currentVictoryMessage) { + // Check if victory modal disappeared (indicating new game started) + const victoryModal = page.locator('.victory-modal-overlay'); + const isModalVisible = await victoryModal.isVisible(); + if (!isModalVisible) { nextGameStarted = true; - console.log('Victory message disappeared, indicating new game started'); + console.log('Victory modal disappeared, indicating new game started'); break; } }