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

// The site has no light mode: it renders dark whatever the device's
// light/dark setting is (app.css has no prefers-color-scheme switch).

for (const scheme of ['light', 'dark'] as const) {
    test.describe(`Always dark — device set to ${scheme}`, () => {
        test.use({ colorScheme: scheme });

        test('player pages render dark', async ({ page }, testInfo) => {
            await loginAs(page, USER.mobile, USER.password);

            for (const [name, path] of [['home', '/'], ['deposit', '/deposit'], ['withdrawal', '/withdrawal']] as const) {
                await page.goto(`${BASE_URL}${path}`);
                await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(0, 0, 0)');
                await expect(page.locator('body')).toHaveCSS('color', 'rgb(255, 255, 255)');
                await page.screenshot({ path: testInfo.outputPath(`dark-${name}-device-${scheme}.png`) });
            }
        });

        test('WFBO looks the same on either device setting', async ({ page }, testInfo) => {
            await loginAs(page, ADMIN.mobile, ADMIN.password);
            await page.goto(`${BASE_URL}/wfbo`);
            await expect(page.locator('[data-testid="wfbo-sidebar"]')).toBeVisible();
            await page.screenshot({ path: testInfo.outputPath(`wfbo-device-${scheme}.png`) });
        });
    });
}
