import { test, expect } from '@playwright/test';
import { BASE_URL, ADMIN, USER, loginAs } from '../helpers';

// EZDOS and Head2Head Karera were removed: no menu entries, lobby cards,
// report rows or pages left for players or back office.

test.describe('Removed games — EZDOS and Head2Head Karera', () => {

    test('back office has no menu entries, dashboard badges or pages for them', async ({ page }) => {
        await loginAs(page, ADMIN.mobile, ADMIN.password);
        await page.goto(`${BASE_URL}/wfbo`);

        await expect(page.locator('[data-testid="wfbo-nav-game-hub-ez"]')).toHaveCount(0);
        await expect(page.locator('[data-testid="wfbo-nav-game-hub-h2h"]')).toHaveCount(0);
        await expect(page.locator('.stat-game-badge', { hasText: /^(EZ|H2H):/ })).toHaveCount(0);

        for (const path of ['/wfbo/games/ezdos', '/wfbo/ezdos/settings', '/wfbo/ezdos/results',
                            '/wfbo/games/head2head-karera', '/wfbo/head2head-karera/events', '/wfbo/head2head-karera/settings']) {
            const response = await page.goto(`${BASE_URL}${path}`);
            expect(response?.status(), path).toBe(404);
        }

        // The Games menu still lists the remaining games.
        await page.goto(`${BASE_URL}/wfbo/games/report`);
        await expect(page.locator('[data-testid="wfbo-nav-game-hub-pk"]')).toBeVisible();
        await page.locator('[data-testid="wfbo-nav-game-hub-pk"]').scrollIntoViewIfNeeded();
    });

    test('players see no lobby cards and their pages are gone', async ({ page }) => {
        await loginAs(page, USER.mobile, USER.password);
        await page.goto(`${BASE_URL}/`);

        await expect(page.locator('[data-testid="play-ezdos-card"]')).toHaveCount(0);
        await expect(page.locator('[data-testid="play-head2head-karera-card"]')).toHaveCount(0);

        for (const path of ['/play/ezdos', '/play/ezdos/results', '/play/head2head-karera', '/play/head2head-karera/history']) {
            const response = await page.goto(`${BASE_URL}${path}`);
            expect(response?.status(), path).toBe(404);
        }
        await page.goto(`${BASE_URL}/`);
    });
});
