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

test('about combines platform and runtime content into one responsive carousel', async ({ page }) => {
  await page.goto('/about');

  const carousel = page.getByRole('region', { name: 'Learnitive highlights' });
  await expect(carousel).toBeVisible();
  await expect(carousel.getByRole('heading', { name: 'More Than an Editor' })).toBeVisible();
  await expect(page.getByText('Cursor · Replit · Learnitive', { exact: true })).toBeVisible();
  await expect(page.getByText('Moving from Cursor or Replit?', { exact: true })).toHaveCount(0);

  const previous = carousel.getByRole('button', { name: 'Previous highlight' });
  const next = carousel.getByRole('button', { name: 'Next highlight' });
  await expect(previous).toBeDisabled();
  await next.click();
  await expect(carousel.getByRole('heading', { name: 'Terminal and Environment' })).toBeVisible();
  await expect(carousel.getByRole('link', { name: /Read Terminal and Runtime docs/u })).toHaveAttribute('href', '/docs/texlab');
  await expect(carousel.getByRole('link', { name: 'Explore installed software' })).toHaveAttribute('href', '/software-list');
  await expect(next).toBeDisabled();
  await expect(previous).toBeEnabled();

  await page.setViewportSize({ width: 390, height: 844 });
  const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
  expect(overflow).toBeLessThanOrEqual(0);
});

test('pricing starts with plans and shares the AI webapp builder line across Pro cards', async ({ page }) => {
  await page.goto('/pricing');

  await expect(page.getByRole('heading', { name: 'A mindful pricing.' })).toBeVisible();
  await expect(page.getByRole('heading', { name: 'Choose the plan that fits your workflow' })).toHaveCount(0);
  const plans = page.getByRole('region', { name: 'Pricing plans' });
  await expect(plans).toBeVisible();
  await expect(plans.locator('[data-plan="lifetime"]')).toContainText('AI webapp builder with shell access');
  await expect(plans.locator('[data-plan="monthly"]')).toContainText('AI webapp builder with shell access');

  await page.goto('/');
  await expect(page.getByText(/Upgrade to Pro for unlimited projects/u)).toHaveCount(0);
});
