story 2-13-importplan-re-import: implemented and reviewed via bmad-loop

This commit is contained in:
bsodfather committed 2026-09-29 08:12:01 +03:00
1 parent c562d5368d
commit f69c36fa65
66 files changed
+11366 -686

No files matched your search

+1
View File
@@ -156,6 +156,7 @@ test('onboarding error exposes safe support correlation and retries without a cl
});
await page.goto('/');
await expect(page.getByTestId('onboarding-trigger')).toContainText(/3\s*\/\s*7/);
await page.getByTestId('onboarding-trigger').click();
fail = true;
await page.getByTestId('onboarding-refresh').click();
@@ -0,0 +1,278 @@
const { test, expect } = require('@playwright/test');
const { login, localized, uniqueName } = require('./helpers');
async function dismissOnboardingIfOpen(page) {
await page.locator('#crank-onboarding-panel').waitFor({ state: 'attached' });
await page.locator('[data-testid="onboarding-dismiss"]').waitFor({ state: 'attached' });
await page.evaluate(() => {
const dismiss = document.querySelector('[data-testid="onboarding-dismiss"]');
if (dismiss) dismiss.click();
});
await expect(page.locator('#crank-onboarding-panel')).toBeHidden();
}
function importDocument(prefix) {
return [
'openapi: 3.0.3',
'info: { title: ImportPlan UI test, version: \'1\' }',
'paths:',
' /' + prefix + '-selected:',
' get:',
' operationId: ' + prefix + '_selected',
' responses:',
' \'200\': { description: OK }',
' /' + prefix + '-excluded:',
' get:',
' operationId: ' + prefix + '_excluded',
' responses:',
' \'200\': { description: OK }',
].join('\n');
}
function planResponse(prefix) {
return {
plan_reference: 'plan_e2e_importplan_213',
plan_digest: 'a'.repeat(64),
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
selection_mode: 'partial',
counts: { selected: 1, excluded: 1, actionable: 1, blocked: 0 },
candidates: [
{
key: 'GET /' + prefix + '-selected',
name: 'selected_operation',
state: 'actionable',
action: 'new_version',
target_operation_id: 'op_existing_target',
confirmed_name: null,
auth_profile_id: null,
reason: null,
},
{
key: 'GET /' + prefix + '-excluded',
name: 'excluded_operation',
state: 'excluded',
action: null,
target_operation_id: null,
confirmed_name: null,
auth_profile_id: null,
reason: 'not_selected',
},
],
};
}
async function preparePlanFlow(page, locale) {
const planCalls = [];
const applyCalls = [];
const prefix = uniqueName('plan_apply');
let releaseApplyResponse;
const applyResponseHeld = new Promise((resolve) => {
releaseApplyResponse = resolve;
});
// Keep this mock aligned with the public CreatePlan response shape.
await page.route('**/api/admin/workspaces/*/operations', async (route) => {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({ items: [], page: 1, page_size: 0, total: 0 }),
});
});
await page.route(/\/imports\/openapi\/[^/]+\/plans$/, async (route) => {
planCalls.push({
url: route.request().url(),
payload: route.request().postDataJSON(),
});
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(planResponse(prefix)),
});
});
await page.route(/\/imports\/openapi\/[^/]+\/apply$/, async (route) => {
applyCalls.push({
url: route.request().url(),
payload: route.request().postDataJSON(),
});
// Keep the request pending until the test has checked the duplicate guard.
await applyResponseHeld;
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
plan_digest: 'a'.repeat(64),
counts: { selected: 1, excluded: 1, created: 0, versioned: 1 },
outcomes: [{ status: 'versioned' }],
}),
});
});
// Contain the legacy path so this red-phase test cannot mutate the E2E DB.
await page.route(/\/imports\/openapi\/[^/]+\/create$/, async (route) => {
await route.fulfill({
status: 409,
contentType: 'application/json',
body: JSON.stringify({ message: 'ImportPlan flow required' }),
});
});
await login(page);
await dismissOnboardingIfOpen(page);
await page.evaluate((language) => window.setLang(language), locale);
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await expect(page.locator('#openapi-import-modal')).toBeVisible();
await page.locator('#openapi-import-file').setInputFiles({
name: 'import-plan.yaml',
mimeType: 'application/yaml',
buffer: Buffer.from(importDocument(prefix)),
});
const previewResponse = page.waitForResponse((response) =>
response.request().method() === 'POST'
&& response.url().includes('/imports/openapi/preview'),
);
await page.locator('#openapi-import-preview').click();
await previewResponse;
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
await page.locator('#openapi-import-server-custom').fill('https://api.example.test');
// The existing preview action becomes Plan creation followed by confirmation.
await page.locator('#openapi-import-create').click();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await expect.poll(() => planCalls.length).toBe(1);
return { planCalls, applyCalls, prefix, releaseApplyResponse };
}
async function assertConfirmation(page, prefix) {
const confirmation = page.locator('[data-testid="openapi-import-apply-confirmation"]');
const counts = page.locator('[data-testid="openapi-import-apply-counts"]');
const versioning = page.locator('[data-testid="openapi-import-versioning-consequences"]');
await expect(counts).toContainText(localized('Selected: 1', 'Выбрано: 1'));
await expect(counts).toContainText(localized('Excluded: 1', 'Исключено: 1'));
await expect(counts).toContainText(localized('Actionable: 1', 'Можно применить: 1'));
await expect(counts).toContainText(localized('Blocked: 0', 'Заблокировано: 0'));
await expect(versioning).toContainText(localized('new Draft Version', 'новая версия черновика'));
await expect(versioning).toContainText(
localized('Published Version and history remain unchanged', 'Опубликованная версия и история останутся без изменений'),
);
await expect(confirmation).toContainText('GET /' + prefix + '-selected');
await expect(confirmation).toContainText('GET /' + prefix + '-excluded');
await expect(confirmation).toContainText('op_existing_target');
}
test('[P1] AC-13 renders server-confirmed partial and new_version consequences in RU and EN', async ({ page }) => {
// This test covers rendering of a stored server plan only. It does not
// specify how UI controls compose selection/decision request fields.
const { planCalls, prefix } = await preparePlanFlow(page, 'ru');
for (const locale of ['ru', 'en']) {
await test.step('confirmation in ' + locale, async () => {
await page.evaluate((language) => window.setLang(language), locale);
await assertConfirmation(page, prefix);
});
}
expect(planCalls).toHaveLength(1);
expect(planCalls[0].url).toMatch(/\/imports\/openapi\/[^/]+\/plans$/);
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]').getByRole('button', {
name: localized('Apply import', 'Применить импорт'),
})).toBeVisible();
});
test('[P1] AC-13 double-click sends one Apply with the stored reference, digest and idempotency key', async ({ page }) => {
const { applyCalls, releaseApplyResponse } = await preparePlanFlow(page, 'en');
const applyButton = page.getByRole('button', {
name: localized('Apply import', 'Применить импорт'),
});
await applyButton.dblclick();
await expect.poll(() => applyCalls.length).toBe(1);
await expect(applyButton).toBeDisabled();
releaseApplyResponse();
await expect(page.locator('[data-testid="openapi-import-apply-result"]')).toBeVisible();
expect(applyCalls).toHaveLength(1);
expect(applyCalls[0].url).toMatch(/\/imports\/openapi\/plan_e2e_importplan_213\/apply$/);
expect(applyCalls[0].payload).toMatchObject({
plan_digest: 'a'.repeat(64),
});
expect(typeof applyCalls[0].payload.idempotency_key).toBe('string');
expect(applyCalls[0].payload.idempotency_key.length).toBeGreaterThan(0);
});
test('[P1] AC-13 submits the confirmed new_version decision for the exact existing operation', async ({ page }) => {
const prefix = uniqueName('plan_version');
const targetOperationId = 'op_exact_importplan_target';
const planCalls = [];
const expectedName = prefix + '_selected';
await page.route('**/api/admin/workspaces/*/operations', async (route) => {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
items: [{ id: targetOperationId, name: expectedName, protocol: 'rest', status: 'draft' }],
page: 1,
page_size: 1,
total: 1,
}),
});
});
await page.route(/\/imports\/openapi\/[^/]+\/plans$/, async (route) => {
const payload = route.request().postDataJSON();
planCalls.push(payload);
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
plan_reference: 'plan_e2e_importplan_decision',
plan_digest: 'b'.repeat(64),
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
selection_mode: payload.selection_mode,
counts: { selected: 1, excluded: 0, actionable: 1, blocked: 0 },
candidates: [{
key: payload.decisions[0].operation_key,
name: expectedName,
state: 'actionable',
action: 'new_version',
target_operation_id: targetOperationId,
confirmed_name: null,
auth_profile_id: null,
reason: null,
}],
}),
});
});
await login(page);
await dismissOnboardingIfOpen(page);
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await page.locator('#openapi-import-file').setInputFiles({
name: 'import-plan-decision.yaml',
mimeType: 'application/yaml',
buffer: Buffer.from(importDocument(prefix)),
});
const previewResponse = page.waitForResponse((response) =>
response.request().method() === 'POST' && response.url().includes('/imports/openapi/preview'),
);
await page.locator('#openapi-import-preview').click();
await previewResponse;
const operationRow = page.locator('.openapi-import-operation').filter({ hasText: expectedName });
const operationCheckbox = operationRow.locator('[data-openapi-operation]');
await expect(operationCheckbox).toBeVisible();
const operationKey = await operationCheckbox.inputValue();
for (const checkbox of await page.locator('[data-openapi-operation]').all()) {
if (await checkbox.inputValue() !== operationKey) await checkbox.uncheck();
}
await expect(operationRow.locator('.openapi-import-operation-meta')).toContainText(expectedName);
const action = operationRow.locator('[data-openapi-decision-action]');
await expect(action.locator('option[value="new_version"]')).toBeEnabled();
await action.selectOption('new_version');
await expect(operationRow.locator('[data-openapi-decision-target]')).toHaveValue(targetOperationId);
await page.locator('#openapi-import-server-custom').fill('https://api.example.test');
await page.locator('#openapi-import-create').click();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toContainText(targetOperationId);
expect(planCalls).toHaveLength(1);
expect(planCalls[0].selection_mode).toBe('partial');
expect(planCalls[0].selected_operation_keys).toEqual([operationKey]);
expect(planCalls[0].decisions).toEqual([{
operation_key: operationKey,
action: 'new_version',
target_operation_id: targetOperationId,
}]);
});
+114 -38
View File
@@ -11,6 +11,48 @@ async function dismissOnboardingIfOpen(page) {
await expect(page.locator('#crank-onboarding-panel')).toBeHidden();
}
function planResponse(payload, planReference) {
const decisions = payload.decisions || [];
return {
plan_reference: planReference,
plan_digest: 'c'.repeat(64),
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
selection_mode: payload.selection_mode,
counts: { selected: decisions.length, excluded: 0, actionable: decisions.length, blocked: 0 },
candidates: decisions.map((decision) => ({
key: decision.operation_key,
name: decision.confirmed_name || decision.operation_key,
state: 'actionable',
action: decision.action,
target_operation_id: decision.target_operation_id || null,
confirmed_name: decision.confirmed_name || null,
auth_profile_id: null,
reason: null,
})),
};
}
function applyResponse(payload, names) {
const outcomes = (payload.outcomes || []).map((outcome) => ({
key: outcome.key,
name: names && names[outcome.key] || outcome.name || outcome.key,
status: outcome.status || 'created',
}));
return {
counts: { created: outcomes.filter((outcome) => outcome.status === 'created').length },
outcomes,
};
}
async function mockEmptyOperationsList(page) {
await page.route('**/api/admin/workspaces/*/operations', async (route) => {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({ items: [], page: 1, page_size: 0, total: 0 }),
});
});
}
test('operations page shows demo catalog and filter works', async ({ page }) => {
await login(page);
await expect(page.locator('.page-heading')).toHaveText(localized('Operations', 'Операции'));
@@ -112,7 +154,6 @@ paths:
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(localized('Response', 'Ответ'));
await expect(page.locator('#openapi-import-selection')).toContainText(localized('Selected: 2', 'Выбрано: 2'));
await page.locator('#openapi-import-search').fill('status');
@@ -127,18 +168,19 @@ paths:
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(localized('Import result', 'Результат импорта'));
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(localized('tool description is too short', 'Описание инструмента слишком короткое'));
await expect(page.locator('.openapi-import-result-row').filter({ hasText: operationId })).toContainText(localized('Fix in wizard', 'Исправить в мастере'));
await expect(page.locator('.openapi-import-primary-result a')).toHaveAttribute(
'href',
/\/wizard\/\?mode=edit&operationId=op_/
);
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await page.locator('#openapi-import-plan-apply').click();
await expect(page.locator('#openapi-import-result')).toBeVisible();
await expect(page.locator('#openapi-import-result')).toContainText(localized('Import plan result', 'Результат плана импорта'));
await expect(page.locator('.openapi-import-plan-outcomes')).toContainText(operationId);
await expect(page.locator('.openapi-import-plan-outcomes')).toContainText('POST /v1/rates/{date}');
await expect(importedOperation.locator('.openapi-import-findings')).toContainText(localized('tool description is too short', 'Описание инструмента слишком короткое'));
await expect(page.locator('tbody')).toContainText(new RegExp(operationId, 'i'));
await expect(page.locator('tbody')).not.toContainText(new RegExp(statusOperationId, 'i'));
await expect(page.locator('body')).not.toContainText(sourceCanary);
await page.locator('[data-openapi-close]').last().click();
await page.locator('tbody tr').filter({ hasText: operationId }).locator('.row-btn-edit').click();
await expect(page).toHaveURL(/\/wizard\/\?mode=edit&operationId=op_/);
});
test('OpenAPI upload rejects invalid files locally and restores focus after Escape', async ({ page }) => {
@@ -246,6 +288,7 @@ test('OpenAPI apply cancellation preserves the import job for an idempotent retr
await login(page);
await dismissOnboardingIfOpen(page);
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await mockEmptyOperationsList(page);
await page.route('**/imports/openapi/preview', async (route) => {
await route.fulfill({
@@ -269,11 +312,18 @@ test('OpenAPI apply cancellation preserves the import job for an idempotent retr
});
const requests = [];
await page.route('**/imports/openapi/*/plans', async (route) => {
const payload = route.request().postDataJSON();
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify(planResponse(payload, 'plan_retry_same_authority')),
});
});
let releaseFirst;
const firstRequest = new Promise((resolve) => {
releaseFirst = resolve;
});
await page.route('**/imports/openapi/*/create', async (route) => {
await page.route('**/imports/openapi/*/apply', async (route) => {
requests.push({ url: route.request().url(), body: route.request().postData() });
if (requests.length === 1) await firstRequest;
if (requests.length === 3) {
@@ -287,12 +337,9 @@ test('OpenAPI apply cancellation preserves the import job for an idempotent retr
try {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
created: [{
operation_key: 'get:/retry', name: 'renamed_after_conflict', operation_id: 'op_retry', version: 1,
}],
skipped: [], findings: [],
}),
body: JSON.stringify(applyResponse({ outcomes: [{
key: 'get:/retry', name: 'renamed_after_conflict', status: 'created',
}] })),
});
} catch (_error) {
// The first request is deliberately aborted by the browser.
@@ -305,23 +352,25 @@ test('OpenAPI apply cancellation preserves the import job for an idempotent retr
await page.locator('#openapi-import-preview').click();
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
await page.locator('#openapi-import-create').click();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await page.locator('#openapi-import-plan-apply').click();
await expect.poll(() => requests.length).toBe(1);
await page.locator('#openapi-import-cancel').click();
await expect(page.locator('#openapi-import-status')).toContainText(localized('may have completed', 'мог завершиться'));
await expect(page.locator('#openapi-import-status')).toContainText(localized('Apply result is unknown', 'Результат применения неизвестен'));
await expect(page.locator('#openapi-import-retry')).toBeVisible();
await page.locator('[data-openapi-close]').last().click();
await page.reload();
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await expect(page.locator('#openapi-import-retry')).toBeVisible();
await page.locator('#openapi-import-retry').click();
await expect(page.locator('#openapi-import-result')).toContainText('GET /retry');
await expect(page.locator('#openapi-import-result')).toContainText('get:/retry');
await expect.poll(() => requests.length).toBe(2);
// Let the cancelled first attempt answer after the retry. Its stale response
// must not overwrite or unlock the newer attempt's state.
releaseFirst();
await page.waitForTimeout(50);
await expect(page.locator('#openapi-import-result')).toContainText('GET /retry');
expect(requests[0].url).toContain('/imports/openapi/job_retry_same_authority/create');
await expect(page.locator('#openapi-import-result')).toContainText('get:/retry');
expect(requests[0].url).toContain('/imports/openapi/plan_retry_same_authority/apply');
expect(requests[1].url).toBe(requests[0].url);
expect(requests[1].body).toBe(requests[0].body);
@@ -334,17 +383,20 @@ test('OpenAPI apply cancellation preserves the import job for an idempotent retr
await page.locator('#openapi-import-preview').click();
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
await page.locator('#openapi-import-create').click();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await page.locator('#openapi-import-plan-apply').click();
await expect.poll(() => requests.length).toBe(3);
await expect(page.locator('#openapi-import-file-select')).toBeEnabled();
await expect(page.locator('#openapi-import-reset')).toBeEnabled();
await expect(page.locator('#openapi-import-retry')).toBeVisible();
expect(await page.evaluate(() => sessionStorage.getItem('crank_openapi_apply_replay_v1'))).toBeNull();
expect(await page.evaluate(() => sessionStorage.getItem('crank_openapi_plan_apply_replay_v2'))).toBeNull();
});
test('OpenAPI apply preserves job authority after language or workspace changes', async ({ page }) => {
await login(page);
await dismissOnboardingIfOpen(page);
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await mockEmptyOperationsList(page);
await page.route('**/imports/openapi/preview', async (route) => {
await route.fulfill({
@@ -368,16 +420,21 @@ test('OpenAPI apply preserves job authority after language or workspace changes'
});
const releases = [];
const applyRequests = [];
await page.route('**/imports/openapi/*/create', async (route) => {
await page.route('**/imports/openapi/*/plans', async (route) => {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify(planResponse(route.request().postDataJSON(), 'plan_active_apply')),
});
});
await page.route('**/imports/openapi/*/apply', async (route) => {
applyRequests.push({ url: route.request().url(), body: route.request().postData() });
await new Promise((resolve) => releases.push(resolve));
try {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
created: [{ operation_key: 'get:/active', name: 'active', operation_id: 'op_active', version: 1 }],
skipped: [], findings: [],
}),
body: JSON.stringify(applyResponse({ outcomes: [{
key: 'get:/active', name: 'active', status: 'created',
}] })),
});
} catch (_error) {
// The invalidation aborts a request that must not update the modal afterwards.
@@ -394,6 +451,8 @@ test('OpenAPI apply preserves job authority after language or workspace changes'
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
await page.locator('#openapi-import-server-custom').fill('https://api.example.test');
await page.locator('#openapi-import-create').click();
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
await page.locator('#openapi-import-plan-apply').click();
await expect(page.locator('#openapi-import-cancel')).toBeVisible();
await expect.poll(() => releases.length).toBeGreaterThan(0);
}
@@ -402,14 +461,14 @@ test('OpenAPI apply preserves job authority after language or workspace changes'
// Exercise the actual UI language switcher path: it updates storage,
// re-renders translations and dispatches crank:langchange in one action.
await page.evaluate(() => window.setLang('en'));
await expect(page.locator('#openapi-import-status')).toContainText('may have completed');
await expect(page.locator('#openapi-import-status')).toContainText('Apply result is unknown');
await expect(page.locator('#openapi-import-retry')).toBeVisible();
await expect(page.locator('#openapi-import-file-select')).toBeDisabled();
releases.shift()();
await page.locator('#openapi-import-retry').click();
await expect.poll(() => releases.length).toBeGreaterThan(0);
releases.shift()();
await expect(page.locator('#openapi-import-result')).toContainText('GET /active');
await expect(page.locator('#openapi-import-result')).toContainText('get:/active');
expect(applyRequests[1].url).toBe(applyRequests[0].url);
expect(applyRequests[1].body).toBe(applyRequests[0].body);
@@ -419,7 +478,7 @@ test('OpenAPI apply preserves job authority after language or workspace changes'
await page.evaluate(() => {
window.dispatchEvent(new CustomEvent('crank:workspacechange', { detail: { id: 'workspace-after-apply' } }));
});
await expect(page.locator('#openapi-import-status')).toContainText('may have completed');
await expect(page.locator('#openapi-import-status')).toContainText('Apply result is unknown');
await expect(page.locator('#openapi-import-retry')).toBeVisible();
await expect(page.locator('#openapi-import-file-select')).toBeDisabled();
releases.shift()();
@@ -516,6 +575,7 @@ test('OpenAPI upload ignores a stale failure and renders only correlation identi
await login(page);
await dismissOnboardingIfOpen(page);
await page.getByRole('button', { name: localized('Import OpenAPI', 'Импорт OpenAPI') }).click();
await mockEmptyOperationsList(page);
const sourceCanary = 'do-not-render-openapi-source-canary';
await page.locator('#openapi-import-file').setInputFiles({
name: 'safe.yaml',
@@ -590,14 +650,30 @@ test('OpenAPI upload ignores a stale failure and renders only correlation identi
});
await page.locator('#openapi-import-retry').click();
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
let createRequests = 0;
await page.route('**/imports/openapi/*/create', async (route) => {
createRequests += 1;
await new Promise((resolve) => setTimeout(resolve, 100));
await route.fulfill({ contentType: 'application/json', body: JSON.stringify({ created: [], skipped: [], findings: [] }) });
await page.route('**/imports/openapi/*/plans', async (route) => {
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify(planResponse(route.request().postDataJSON(), 'plan_ui_evidence')),
});
});
let applyRequests = 0;
let releaseApply;
const applyResponseHeld = new Promise((resolve) => { releaseApply = resolve; });
await page.route('**/imports/openapi/*/apply', async (route) => {
applyRequests += 1;
await applyResponseHeld;
await route.fulfill({
contentType: 'application/json',
body: JSON.stringify(applyResponse({ outcomes: [{ key: 'get:/health', name: 'health', status: 'created' }] })),
});
});
await page.locator('#openapi-import-create').click();
await page.locator('#openapi-import-create').evaluate((button) => button.click());
await expect(page.locator('#openapi-import-status')).toContainText('Created: 0; skipped: 0.');
expect(createRequests).toBe(1);
await expect(page.locator('[data-testid="openapi-import-apply-confirmation"]')).toBeVisible();
const applyButton = page.locator('#openapi-import-plan-apply');
await applyButton.dblclick();
await expect.poll(() => applyRequests).toBe(1);
await expect(applyButton).toBeDisabled();
releaseApply();
await expect(page.locator('#openapi-import-status')).toContainText('Import plan applied.');
expect(applyRequests).toBe(1);
});
+1 -1
View File
@@ -193,7 +193,7 @@ test('wizard builds visual request mappings from JSON sample and path params', a
await page.goto('/wizard/');
await page.locator('[data-testid="wizard-protocol-rest"]').click();
await page.evaluate(() => window.CrankWizardShell.goToStep(2));
await page.locator('#btn-continue').click();
await expect(page.locator('#step-panel-2')).toBeVisible();
await page.locator('#endpoint-path').fill('/rates/{date}');
await page.evaluate(() => window.CrankWizardShell.goToStep(3));