More work

This commit is contained in:
Tyler Marques 2025-06-03 19:13:51 -07:00
parent 9695a64d65
commit f4b853a6c5
No known key found for this signature in database
GPG key ID: CB99EDCF41D3016F
2 changed files with 16 additions and 13 deletions

View file

@ -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();

View file

@ -37,15 +37,18 @@ export async function stopGamePlayback(page: Page): Promise<void> {
}
/**
* 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<string | null> {
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;
}
}