CI / UI Checks (pull_request) Successful in 11s
CI / Rust Checks (pull_request) Successful in 12m45s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Community Release / release (push) Successful in 40m35s
Tool Draft фиксирует synchronous/background/adaptive, deadline и fallback; runtime применяет единый снимок политики (concurrency, очередь, approval, deadline) до внешнего действия. Насыщение отклоняется typed overload с retry guidance, mandatory safety store fail closed, background/adaptive используют опубликованный synchronous/unsupported fallback. Refs: #29
140 lines
4.9 KiB
JavaScript
140 lines
4.9 KiB
JavaScript
const { test, expect } = require('@playwright/test');
|
|
const { getCurrentWorkspace, login } = require('./helpers');
|
|
|
|
// Story 4.1 (FR-21): the published execution policy is part of the Tool version and must survive a
|
|
// wizard save. The editor is a free-form document, so a no-op edit must not erase it and an explicit
|
|
// invalid value must be reported instead of being silently replaced by defaults.
|
|
function draftSnapshot(operationId) {
|
|
return {
|
|
id: operationId,
|
|
name: operationId,
|
|
display_name: 'Policy rates',
|
|
category: 'general',
|
|
protocol: 'rest',
|
|
target: {
|
|
kind: 'rest',
|
|
base_url: 'https://api.example.test',
|
|
method: 'GET',
|
|
path_template: '/rates',
|
|
static_headers: {},
|
|
},
|
|
input_schema: {
|
|
type: 'object',
|
|
description: null,
|
|
required: false,
|
|
nullable: false,
|
|
default_value: null,
|
|
fields: {},
|
|
items: null,
|
|
enum_values: [],
|
|
variants: [],
|
|
},
|
|
output_schema: {
|
|
type: 'object',
|
|
description: null,
|
|
required: false,
|
|
nullable: false,
|
|
default_value: null,
|
|
fields: {},
|
|
items: null,
|
|
enum_values: [],
|
|
variants: [],
|
|
},
|
|
input_mapping: { rules: [] },
|
|
output_mapping: { rules: [{ source: '$.response.body.rate', target: '$.output.rate', required: true }] },
|
|
execution_config: {
|
|
timeout_ms: 10000,
|
|
retry_policy: null,
|
|
auth_profile_ref: null,
|
|
headers: {},
|
|
approval_policy: null,
|
|
execution_policy: {
|
|
mode: 'adaptive',
|
|
deadline_ms: 45000,
|
|
no_tasks_fallback: 'unsupported',
|
|
},
|
|
},
|
|
tool_description: { title: 'Policy rates', description: 'Get rates.', tags: [], examples: [] },
|
|
wizard_state: { input_sample: {}, output_sample: {}, test_input: {}, import_findings: [] },
|
|
};
|
|
}
|
|
|
|
test('wizard round-trips the published execution policy and rejects an invalid edit', async ({ page }) => {
|
|
await login(page);
|
|
const workspace = await getCurrentWorkspace(page);
|
|
const operationId = 'policy_rates_41';
|
|
const operationPath = `/api/admin/workspaces/${encodeURIComponent(workspace.id)}/operations/${operationId}`;
|
|
const savedPayloads = [];
|
|
|
|
await page.route(operationPath, async (route) => {
|
|
if (route.request().method() === 'PATCH') {
|
|
savedPayloads.push(route.request().postDataJSON());
|
|
await route.fulfill({
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ operation_id: operationId, workspace_id: workspace.id, version: 2, status: 'draft' }),
|
|
});
|
|
return;
|
|
}
|
|
await route.fulfill({
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
id: operationId,
|
|
workspace_id: workspace.id,
|
|
name: operationId,
|
|
display_name: 'Policy rates',
|
|
category: 'general',
|
|
protocol: 'rest',
|
|
status: 'draft',
|
|
current_draft_version: 1,
|
|
draft_version_ref: { version: 1, status: 'draft' },
|
|
published_version_ref: null,
|
|
agent_refs: [],
|
|
}),
|
|
});
|
|
});
|
|
await page.route(`${operationPath}/versions/*`, async (route) => {
|
|
await route.fulfill({
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
operation_id: operationId,
|
|
workspace_id: workspace.id,
|
|
version: 1,
|
|
status: 'draft',
|
|
snapshot: draftSnapshot(operationId),
|
|
}),
|
|
});
|
|
});
|
|
await page.route('**/operations/analyze-quality', async (route) => {
|
|
await route.fulfill({ contentType: 'application/json', body: JSON.stringify({ blocking: false, findings: [] }) });
|
|
});
|
|
page.on('dialog', (dialog) => dialog.accept());
|
|
|
|
await page.goto(`/wizard/?mode=edit&operationId=${operationId}`);
|
|
await expect(page.locator('#tool-display-name')).toHaveValue('Policy rates');
|
|
|
|
const editorValue = await page.locator('#tool-exec-config').inputValue();
|
|
expect(editorValue).toContain('execution_policy');
|
|
expect(editorValue).toContain('adaptive');
|
|
expect(editorValue).toContain('45000');
|
|
expect(editorValue).toContain('unsupported');
|
|
|
|
// A real edit still saves the pinned policy unchanged.
|
|
await page.evaluate(() => window.CrankWizardShell.doGoToStep(4));
|
|
await page.locator('#tool-display-name').fill('Policy rates edited');
|
|
await page.locator('.btn-save-draft').click();
|
|
await expect.poll(() => savedPayloads.length).toBe(1);
|
|
expect(savedPayloads[0].execution_config.execution_policy).toEqual({
|
|
mode: 'adaptive',
|
|
deadline_ms: 45000,
|
|
no_tasks_fallback: 'unsupported',
|
|
});
|
|
|
|
// An explicit invalid policy is refused instead of being silently rewritten to defaults.
|
|
await page.evaluate(() => window.CrankWizardShell.doGoToStep(5));
|
|
await expect(page.locator('#tool-exec-config')).toBeVisible();
|
|
await page.locator('#tool-exec-config').fill('timeout_ms: 10000\nexecution_policy:\n mode: background\n deadline_ms: 0\n');
|
|
await page.locator('.btn-save-draft').click();
|
|
await expect(page.locator('#tool-exec-config')).toHaveValue(/deadline_ms: 0/);
|
|
expect(savedPayloads.length).toBe(1);
|
|
});
|