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

test.describe('Page smoke', () => {
  test.beforeEach(async ({ page }) => {
    await loginToDashboard(page);
  });

  test('Dashboard renders Command Deck', async ({ page }) => {
    await expect(page.getByRole('heading', { name: 'Command Deck' })).toBeVisible();
    await expect(page.getByText('Fleet Pipeline')).toBeVisible();
    await expect(page.getByText('Machine Roster')).toBeVisible();
  });

  test('Agents renders Fleet Roster', async ({ page }) => {
    await page.getByRole('link', { name: /Fleet Roster/i }).click();
    await expect(page.getByRole('heading', { name: 'Fleet Roster' })).toBeVisible({ timeout: 10_000 });
    await expect(page.getByText(/NODES/i)).toBeVisible();
  });

  test('Settings renders Calibrate', async ({ page }) => {
    await page.getByRole('link', { name: /Calibrate/i }).click();
    await expect(page.getByRole('heading', { name: 'Calibrate' })).toBeVisible({ timeout: 10_000 });
    await expect(page.getByRole('button', { name: 'Save Calibration' })).toBeVisible();
  });

  test('Builder renders The Forge', async ({ page }) => {
    await page.getByRole('link', { name: /Forge/i }).click();
    await expect(page.getByRole('heading', { name: 'The Forge' })).toBeVisible({ timeout: 10_000 });
    await expect(page.getByRole('heading', { name: 'Quick Forge' })).toBeVisible();
    await expect(page.getByRole('button', { name: 'Simple' })).toBeVisible();
  });
});
