Files
crank/apps/ui/tests/e2e/resources-story311.spec.js
T
bsodfather 54ce770682
CI / Rust Checks (pull_request) Failing after 13m41s
CI / UI Checks (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Deploy (pull_request) Skipped
Community Release / release (push) Failing after 13m33s
feat(epic3): deliver the accepted Epic 3 scope through Story 3.17
Recovery delivery of the accumulated, TL-accepted Epic 3 work that had never been
committed to Git (stories 3.6-3.17, see the crank board). Story 3.18 is not accepted
yet and is deliberately excluded: its logging surface, its capability registration,
its oracle projections and its tests are not part of this tree.

Accepted scope
- 3.6 typed static Resource Drafts; 3.7 publication and exact binding of static
  Resource Versions; 3.8 MCP discovery/read and revocation of static Resources;
- 3.9 Resource import/export in API and UI plus TLS dependency maintenance;
  3.10 REST-backed Resource templates; 3.11 shared REST read runtime and the MCP
  revision/capability foundation;
- 3.12 parameterised Prompt Drafts with preview; 3.13 Prompt publication and exact
  version binding to Agents; 3.14 MCP prompts; 3.15 Prompt import/export;
- 3.16 composite Prompts with published Resources (dependency content scan plus
  dynamic read through the accepted 3.11 runtime, admin preview and MCP prompts/get);
- 3.17 bounded MCP completion suggestions from typed published schemas and the
  resources/list admission fix for bound template publications.

Accepted evidence being reused (unchanged code paths)
- 3.16 candidate: core 7, admin-api 22, registry 4, mcp-server 4, UI 6; one final
  `just verify` run 1651 passed / 0 failed / 2 ignored.
- 3.17 candidate: full run 1672 passed / 0 failed / 2 ignored, QA targeted reruns and
  a real MCP Inspector 2.12.0 client smoke.

Delivery engineering in this commit
- CI: one event per change (feature branches are gated by their pull request, push
  runs only on main), story events run the changed packages, the full workspace suite
  stays the feature/release gate; no cache/sharding without a measured runner check.
- Release: the packaged archives, checksums and SBOM are now uploaded to the Gitea
  release entry of the tag instead of dying with the runner workspace.

Not included on purpose: Story 3.18 work, build caches, runtime databases, local
credentials and scratch evidence.

Refs: crank kanban t_e39d7263; baseline 1b6db09bd1.
2026-10-25 09:08:22 +00:00

133 lines
7.6 KiB
JavaScript

const { test, expect } = require('@playwright/test');
const {
createPublishedOperation,
createTemplateDraft,
getCurrentWorkspace,
login,
uniqueName,
} = require('./helpers');
function operationPayload(name) {
return {
name,
display_name: name,
category: 'sales',
protocol: 'rest',
security_level: 'standard',
target: { kind: 'rest', base_url: 'http://127.0.0.1:9', method: 'GET', path_template: '/orders/{order_id}' },
input_schema: { type: 'object', required: true, fields: { order_id: { type: 'string', required: true, format: 'uuid' } } },
output_schema: { type: 'object', required: true, fields: { id: { type: 'string', required: true } } },
input_mapping: { rules: [{ source: '$.mcp.order_id', target: '$.request.path.order_id', required: true }] },
output_mapping: { rules: [{ source: '$.response.body.id', target: '$.output.id', required: true }] },
execution_config: { timeout_ms: 1000, safety: { class: 'read' } },
tool_description: { title: name, description: 'Story 3.11 UI fixture' },
};
}
test('story311_ui_requires_confirmation_for_admin_test_read', async ({ page }) => {
await login(page);
const workspace = await getCurrentWorkspace(page);
const operationName = uniqueName('story311_read');
const operation = await createPublishedOperation(page, workspace.id, operationPayload(operationName));
expect(operation.status).toBe(200);
const resourceName = uniqueName('story311_resource');
const created = await createTemplateDraft(page, workspace.id, {
uri: `crank://e2e/${resourceName}`,
name: resourceName,
description: 'admin test read',
kind: 'text',
mime_type: 'text/plain',
sensitivity: 'internal',
source: {
operation_id: operation.operation_id,
operation_version: 1,
uri_template: 'crank://orders/{order_id}',
parameters: [{ name: 'order_id', input_path: 'input.order_id', schema: { type: 'string', required: true, format: 'uuid' } }],
cache: { ttl_ms: 60000, vary: ['order_id'], max_bytes: 65536 },
failure: { outcome: 'error' },
},
});
expect(created.status).toBe(201);
const resourceId = created.json.resource.resource_id;
let sentBody;
let calls = 0;
let releaseLate;
let noteSecondRequest;
let noteOldResponseComplete;
const secondRequest = new Promise((resolve) => { noteSecondRequest = resolve; });
const oldResponseComplete = new Promise((resolve) => { noteOldResponseComplete = resolve; });
const lateResponse = new Promise((resolve) => { releaseLate = resolve; });
await page.route(`**/resources/${resourceId}/test-runs`, async (route) => {
const requestNumber = ++calls;
sentBody = route.request().postDataJSON();
if (requestNumber === 2) {
noteSecondRequest();
await lateResponse;
}
const failing = requestNumber === 5 || requestNumber === 7;
const output = requestNumber === 4 ? null : {
id: requestNumber === 2 ? '123e4567-e89b-12d3-a456-426614174001' :
requestNumber === 3 ? '123e4567-e89b-12d3-a456-426614174002' :
requestNumber === 6 || requestNumber === 8 ? `recovered-${requestNumber}` : '123e4567-e89b-12d3-a456-426614174000',
};
await route.fulfill({ status: failing ? 502 : 200, contentType: 'application/json', body: JSON.stringify({
ok: true, request_id: `req_test_${requestNumber}`, trace_id: `trace_test_${requestNumber}`, output,
}) });
if (requestNumber === 2) noteOldResponseComplete();
});
await page.goto(`/resources?resource_id=${encodeURIComponent(resourceId)}`);
await expect(page.locator('[data-testid="resource-test-card"]')).toBeVisible();
await expect(page.locator('[data-testid="resource-test-parameter"]')).toHaveAttribute('required', '');
await expect(page.locator('[data-testid="resource-test-pinned"]')).toContainText(operation.operation_id);
await expect(page.locator('[data-testid="resource-test-pinned"]')).toContainText('v1');
await expect(page.locator('[data-testid="resource-test-pinned"]')).toContainText(/internal|внутренн/i);
await page.locator('[data-testid="resource-test-parameter"]').fill('123e4567-e89b-12d3-a456-426614174000');
await page.locator('[data-testid="resource-test-start"]').click();
await expect(page.locator('[data-testid="resource-test-confirm"]')).toBeVisible();
expect(sentBody).toBeUndefined();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/completed|завершена/i);
expect(sentBody).toMatchObject({ version: 1, parameters: { order_id: '123e4567-e89b-12d3-a456-426614174000' } });
expect(Object.keys(sentBody).sort()).toEqual(['digest', 'parameters', 'updated_at', 'version']);
await expect(page.locator('[data-testid="resource-test-output"]')).toContainText('123e4567-e89b-12d3-a456-426614174000');
await page.locator('[data-testid="resource-test-parameter"]').fill('123e4567-e89b-12d3-a456-426614174001');
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await secondRequest;
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText('Reading from the pinned operation');
await page.locator('[data-testid="resource-test-parameter"]').fill('123e4567-e89b-12d3-a456-426614174002');
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/completed|завершена/i);
await expect(page.locator('[data-testid="resource-test-output"]')).toContainText('123e4567-e89b-12d3-a456-426614174002');
releaseLate();
await oldResponseComplete;
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/completed|завершена/i);
await expect(page.locator('[data-testid="resource-test-output"]')).toContainText('123e4567-e89b-12d3-a456-426614174002');
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/returned no content|не вернуло содержимое/i);
await expect(page.locator('[data-testid="resource-test-output"]')).toBeEmpty();
await page.evaluate(() => window.setLang('en'));
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText('The test read failed safely');
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/completed/i);
await expect(page.locator('[data-testid="resource-test-output"]')).toContainText('recovered-6');
await page.evaluate(() => window.setLang('ru'));
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText('Не удалось безопасно выполнить чтение');
await page.locator('[data-testid="resource-test-start"]').click();
await page.locator('[data-testid="resource-test-accept"]').click();
await expect(page.locator('[data-testid="resource-test-status"]')).toContainText(/завершена/i);
await expect(page.locator('[data-testid="resource-test-output"]')).toContainText('recovered-8');
});