mirror of
https://github.com/GoodStartLabs/AI_Diplomacy.git
synced 2026-04-19 12:58:09 +00:00
More work
This commit is contained in:
parent
9695a64d65
commit
f4b853a6c5
2 changed files with 16 additions and 13 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue