import { expect, test } from '@playwright/test';

/**
 * Track Q Q2 / frontend backlog F59: past "verified live" admin claims were
 * code-inspection only, because /backoffice needs a real Telegram login this
 * suite cannot perform. ?devBypassAdmin=true (src/app/app.ts, gated by
 * Angular's isDevMode() at runtime in @marketplaces/auth's
 * AdminAuthService.devBypassLogin - not just build-time, and a no-op in any
 * production build) is the existing, already-shipped answer - this test just
 * proves it actually gets an E2E run into the admin shell.
 */
test.describe('admin dev bypass', () => {
  test('?devBypassAdmin=true reaches the admin shell without a Telegram login', async ({ page }) => {
    await page.goto('/?devBypassAdmin=true');
    await page.waitForLoadState('networkidle');

    // The bypass alone doesn't navigate anywhere - it only activates the
    // session, so the admin surface has to be reached directly afterwards.
    await page.goto('/admin/dashboard');
    await page.waitForLoadState('networkidle');

    // A real Telegram-gated admin route would redirect to a login dialog;
    // reaching dashboard content is the actual proof the bypass worked.
    await expect(page).not.toHaveURL(/login/i);
    await expect(page.locator('body')).not.toContainText(/scan.*qr|log in with telegram/i);
  });
});
