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

test('api keys page opens create key flow', async ({ page }) => {
  await login(page);
  await page.goto('/api-keys');
  await expect(page.locator('.page-title')).toHaveText(localized('API Keys', 'API Ключи'));
  await page.locator('#btn-create-key').click();
  await expect(page.locator('.modal-title')).toHaveText(localized('Create API key', 'Создать API-ключ'));
  await page.locator('#new-key-name').fill(`playwright-${Date.now()}`);
  await page.locator('#modal-confirm-btn').click();
  await expect(page.locator('#modal-reveal-body')).toContainText(localized('Copy this key now', 'Скопируйте этот ключ сейчас'));
});
