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

test.describe('WFBO Leaderboard', () => {

    test.beforeEach(async ({ page }) => {
        await loginAs(page, FINANCE.mobile, FINANCE.password);
    });

    test('finance can access /wfbo/leaderboard and sees Master Agent column', async ({ page }) => {
        await page.goto(`${BASE_URL}/wfbo/leaderboard`);
        await expect(page.locator('[data-testid="wfbo-sidebar"]')).toBeVisible();
        await expect(page.getByRole('columnheader', { name: 'Master Agent' })).toBeVisible();
    });

    test('leaderboard row shows a master agent badge or an em dash', async ({ page }) => {
        await page.goto(`${BASE_URL}/wfbo/leaderboard`);
        const masterAgentLinks = page.locator('[data-testid^="master-agent-link-"]');
        if (await masterAgentLinks.count() === 0) {
            test.skip();
            return;
        }
        await expect(masterAgentLinks.first()).toBeVisible();
    });

});
