const { test, expect } = require('@playwright/test'); const { login, localized, uniqueName } = require('./helpers'); test('operations page shows demo catalog and filter works', async ({ page }) => { await login(page); await expect(page.locator('.page-heading')).toHaveText(localized('Operations', 'Операции')); await expect(page.locator('.ws-switcher-trigger')).toBeVisible(); await expect(page.locator('#ws-dropdown')).toHaveCount(0); await expect(page.locator('tbody tr')).toHaveCount(1); await page.getByPlaceholder(localized('Search operations', 'Поиск операций')).fill('frankfurter'); await expect(page.locator('tbody tr')).toHaveCount(1); await expect(page.locator('tbody tr').first()).toContainText(/frankfurter_latest_rate/i); }); test('operations page imports OpenAPI methods as drafts', async ({ page }) => { await login(page); const operationId = uniqueName('get_rates'); const statusOperationId = `${operationId}_status`; await page.getByRole('button', { name: /Импорт OpenAPI/i }).click(); await expect(page.locator('#openapi-import-modal')).toBeVisible(); await page.locator('#openapi-import-document').fill(` openapi: 3.0.3 info: title: Demo Import API servers: paths: /v1/rates/{date}: post: operationId: ${operationId} summary: Получить курсы валют description: Курсы. tags: [currency] parameters: - name: date in: path required: true schema: { type: string } - name: base in: query required: true schema: { type: string } - name: X-API-Version in: header required: false schema: { type: string } requestBody: required: true content: application/json: schema: type: object required: [symbols] properties: symbols: { type: string } responses: '200': description: OK content: application/json: schema: type: object properties: base: { type: string } /v1/status: get: operationId: ${statusOperationId} summary: Проверить статус tags: [service] responses: '200': description: OK content: application/json: schema: type: object properties: status: { type: string } `); await page.locator('#openapi-import-preview').click(); await expect(page.locator('#openapi-import-preview-panel')).toBeVisible(); await expect(page.locator('.openapi-import-document-findings')).toContainText(/base URL/i); await expect(page.locator('.openapi-import-group').filter({ hasText: 'currency' })).toBeVisible(); const importedOperation = page.locator('.openapi-import-operation').filter({ hasText: 'Получить курсы валют' }); await expect(importedOperation).toBeVisible(); await expect(page.locator('.openapi-import-operation').filter({ hasText: 'Проверить статус' })).toBeVisible(); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Path'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('date'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Query'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('base'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Header'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('X-API-Version'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Body'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('symbols'); await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Ответ'); await expect(page.locator('#openapi-import-selection')).toContainText('Выбрано: 2'); await page.locator('#openapi-import-search').fill('status'); await expect(page.locator('.openapi-import-operation:visible')).toHaveCount(1); await expect(page.locator('.openapi-import-operation:visible').filter({ hasText: 'Проверить статус' })).toBeVisible(); await page.locator('#openapi-import-clear-visible').click(); await expect(page.locator('#openapi-import-selection')).toContainText('Выбрано: 1'); await page.locator('#openapi-import-search').fill(''); await page.locator('#openapi-import-method-filter').selectOption('POST'); await expect(page.locator('.openapi-import-operation:visible')).toHaveCount(1); await expect(page.locator('.openapi-import-operation:visible').filter({ hasText: 'Получить курсы валют' })).toBeVisible(); await page.locator('#openapi-import-method-filter').selectOption(''); await page.locator('#openapi-import-server-custom').fill('https://api.example.test'); await page.locator('#openapi-import-create').click(); await expect(page.locator('#openapi-import-result')).toContainText('Результат импорта'); await expect(page.locator('.openapi-import-result-table')).toBeVisible(); await expect(page.locator('.openapi-import-result-row').filter({ hasText: operationId })).toContainText('POST /v1/rates/{date}'); await expect(page.locator('.openapi-import-result-row').filter({ hasText: operationId })).toContainText(/Описание инструмента слишком короткое/); await expect(page.locator('.openapi-import-result-row').filter({ hasText: operationId })).toContainText('Исправить в мастере'); await expect(page.locator('.openapi-import-primary-result a')).toHaveAttribute( 'href', /\/wizard\/\?mode=edit&operationId=op_/ ); await expect(page.locator('tbody')).toContainText(new RegExp(operationId, 'i')); await expect(page.locator('tbody')).not.toContainText(new RegExp(statusOperationId, 'i')); });