const { test, expect } = require('@playwright/test');
const { login } = require('./helpers');

test('shell and wizard expose stable diagnostics hooks', async ({ page }) => {
  await login(page);

  await page.goto('/');
  await expect(page.locator('[data-testid="shell-avatar"]')).toBeVisible();
  await page.locator('[data-testid="shell-avatar"]').click();
  await expect(page.locator('[data-testid="shell-user-name"]').first()).toBeVisible();
  await expect(page.locator('[data-testid="shell-user-role"]').first()).toBeVisible();

  await page.goto('/wizard/');
  await expect(page.locator('[data-testid="wizard-protocol-grid"]')).toBeVisible();
  await expect(page.locator('[data-testid="wizard-protocol-rest"]')).toBeVisible();
  await expect(page.locator('[data-testid="wizard-protocol-websocket"]')).toBeHidden();
  await expect(page.locator('[data-testid="wizard-protocol-soap"]')).toBeHidden();
  await expect(page.locator('html')).toHaveAttribute('data-crank-bootstrap-state', 'ready');
});

test('secrets page exposes stable secret management hooks', async ({ page }) => {
  await login(page);
  await page.goto('/secrets');

  await expect(page.locator('[data-testid="secret-create-button"]')).toBeVisible();
  await page.locator('[data-testid="secret-create-button"]').click();
  await expect(page.locator('[data-testid="secret-create-modal"]')).toBeVisible();
  await expect(page.locator('[data-testid="secret-name-input"]')).toBeVisible();
  await expect(page.locator('[data-testid="secret-kind-select"]')).toBeVisible();
  await expect(page.locator('[data-testid="secret-submit-button"]')).toBeVisible();
  await expect(page.locator('html')).toHaveAttribute('data-crank-bootstrap-state', 'ready');
});
