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

test('wizard loads and protocol selection updates flow', async ({ page }) => {
  await login(page);
  await page.goto('/wizard/');
  await expect(page.locator('[data-step-counter]').first()).toContainText(localized('Step', 'Шаг'));
  await expect(page.locator('#step-panel-1 .step-panel-title')).toContainText(localized('Choose a protocol', 'Выберите протокол'));
  await page.getByText(/graphql/i).first().click();
  await page.locator('#btn-continue').click();
  await expect(page.locator('#step-panel-2 .step-panel-title')).toContainText(localized('Select upstream', 'Выберите upstream'));
});

test('community wizard hides premium protocols and explains edition scope', async ({ page }) => {
  await login(page);
  await page.goto('/wizard/');
  await expect(page.locator('[data-testid="wizard-protocol-rest"]')).toBeVisible();
  await expect(page.locator('[data-testid="wizard-protocol-graphql"]')).toBeVisible();
  await expect(page.locator('[data-testid="wizard-protocol-grpc"]')).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('#wizard-edition-protocol-note')).toContainText(localized('Commercial editions unlock', 'коммерческих редакциях'));

   await page.locator('[data-testid="wizard-protocol-grpc"]').click();
   await page.locator('#btn-continue').click();
   await page.locator('#btn-continue').click();
   await page.locator('#btn-continue').click();
   await page.locator('#btn-continue').click();

   await expect(page.locator('#wizard-streaming-config-card')).toBeHidden();
   await expect(page.locator('#wizard-streaming-capability-note')).toContainText(localized('commercial edition', 'коммерческую редакцию'));
});
