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

// Coverage boundary: the publish wizard renders only for an authenticated
// ATProto session, and a live PDS publish needs real OAuth, which this CI e2e
// harness cannot establish. So e2e covers the signed-out callout (no wizard);
// the signed-in wizard assembly, draft round-trip, validation, and promote-on-
// publish are covered by the Rust unit/integration suites (src/publish/draft.rs,
// src/appview/drafts.rs) plus the manual Playwright pass against `just serve`.

test('signed-out /publish shows the sign-in callout, not the wizard', async ({ page }) => {
  await page.goto('/publish');

  await expect(page.getByRole('heading', { name: 'Share your models' })).toBeVisible();
  const callout = page.locator('section[aria-label="Sign in"]');
  await expect(callout.getByRole('button', { name: 'Sign in' })).toBeVisible();

  // The signed-out surface must not expose the wizard stepper or publish action.
  await expect(page.getByRole('navigation', { name: 'Publish steps' })).toHaveCount(0);
  await expect(page.getByRole('button', { name: 'Publish', exact: true })).toHaveCount(0);
});

test('signed-out publish callout returns the user to /publish after sign-in', async ({ page }) => {
  await page.goto('/publish');

  const returnTo = page.locator('section[aria-label="Sign in"] input[name="return_to"]');
  await expect(returnTo).toHaveValue('/publish');
});
