const { test, expect } = require('@playwright/test'); const { createAgent, getCurrentWorkspace, login, localized, uniqueName } = require('./helpers'); test('api keys page opens create key flow', async ({ page }) => { await login(page); const workspace = await getCurrentWorkspace(page); await createAgent(page, workspace.id, { slug: uniqueName('playwright_keys_agent'), display_name: 'Playwright Keys Agent', description: 'Agent for API key page smoke test.', instructions: {}, tool_selection_policy: {}, }); await page.goto('/api-keys'); await expect(page.locator('.page-title')).toHaveText(localized('Agent Keys', 'Ключи агентов')); await expect(page.locator('[data-testid="machine-access-summary"]')).toHaveCount(0); await expect(page.locator('#machine-access-note')).toHaveCount(0); await expect(page.locator('[data-i18n="apikeys.agent.subtitle"]')).toContainText( localized('Select the AI agent this key is issued for', 'Выберите AI-агента') ); await expect(page.locator('#agent-select')).not.toBeDisabled(); await expect(page.locator('#btn-create-key')).toBeEnabled(); await page.locator('#btn-create-key').click(); await expect(page.locator('#modal-create')).toHaveClass(/open/); await expect(page.locator('.modal-title')).toHaveText(localized('Create MCP client key', 'Создать ключ MCP-клиента')); 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', 'Скопируйте этот ключ сейчас')); await page.locator('#modal-done-btn').click(); await page.locator('#key-kind-approval').click(); await expect(page.locator('#key-kind-hint')).toContainText( localized('human confirmation interface', 'человек подтверждает действие') ); await expect(page.locator('#btn-create-key')).toContainText( localized('Create approval key', 'Создать ключ подтверждения') ); await page.locator('#btn-create-key').click(); await expect(page.locator('.modal-title')).toHaveText(localized('Create approval key', 'Создать ключ подтверждения')); await expect(page.locator('#approval-key-warning')).toContainText( localized('Do not pass this key to an LLM', 'Не передавайте этот ключ LLM') ); await page.locator('#new-key-name').fill(`playwright-approval-${Date.now()}`); await page.locator('#modal-confirm-btn').click(); await expect(page.locator('#reveal-key-value')).toContainText('crk_appr_'); });