story 2-12-preview-partial-mode: implemented and reviewed via bmad-loop
This commit is contained in:
1 parent
d1ba0bd0e4
commit
ab35d67177
56 files changed
+5801
-376
No files matched your search
Vendored
+110
@@ -213,6 +213,27 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.openapi-import-findings summary {
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.openapi-import-findings-page {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.openapi-import-findings-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
padding-top: 6px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.openapi-import-plan-candidate,
|
||||
.openapi-import-plan-outcome {
|
||||
display: grid;
|
||||
@@ -334,6 +355,30 @@
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.openapi-import-partial-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
width: fit-content;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.openapi-import-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 4px 0;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.openapi-import-pagination[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.openapi-import-group-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -452,6 +497,21 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.openapi-import-plan-version,
|
||||
.openapi-import-plan-revalidation {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.openapi-import-plan-stale {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--red);
|
||||
border-radius: 10px;
|
||||
color: var(--red);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.openapi-import-operation:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
@@ -466,6 +526,25 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.openapi-import-source-location {
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.openapi-import-conflict {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
color: var(--amber);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.openapi-import-conflict-proposal {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.openapi-import-method {
|
||||
padding: 4px 8px;
|
||||
border-radius: 999px;
|
||||
@@ -475,6 +554,26 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.openapi-import-operation-readiness {
|
||||
justify-self: start;
|
||||
padding: 4px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--surface-muted, #21262d);
|
||||
color: var(--text-secondary);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.openapi-import-operation-readiness-actionable {
|
||||
background: var(--green-glow, rgba(63, 185, 80, 0.16));
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.openapi-import-operation-readiness-blocked {
|
||||
background: var(--red-glow, rgba(248, 81, 73, 0.16));
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.openapi-import-findings {
|
||||
grid-column: 2 / -1;
|
||||
display: grid;
|
||||
@@ -643,6 +742,17 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.openapi-import-result-skipped-page {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.openapi-import-result-skipped-page ul {
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
margin: 0;
|
||||
padding-left: 22px;
|
||||
}
|
||||
|
||||
.openapi-import-created-list {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
|
||||
@@ -433,7 +433,16 @@
|
||||
<button class="btn-secondary" id="openapi-import-clear-visible" type="button" data-i18n="openapi.clear_visible">Снять видимые</button>
|
||||
</div>
|
||||
</div>
|
||||
<label class="openapi-import-partial-toggle">
|
||||
<input id="openapi-import-partial-mode" type="checkbox">
|
||||
<span data-i18n="openapi.partial_mode">Enable partial import</span>
|
||||
</label>
|
||||
<div class="openapi-import-groups" id="openapi-import-groups"></div>
|
||||
<nav class="openapi-import-pagination" id="openapi-import-pagination" data-testid="openapi-import-pagination" data-i18n-aria-label="openapi.pagination.label" aria-label="Pagination" hidden>
|
||||
<button class="btn-secondary" id="openapi-import-page-previous" type="button" data-i18n="openapi.pagination.previous">Previous</button>
|
||||
<span id="openapi-import-page-status" data-testid="openapi-import-page-status" role="status" aria-live="polite" aria-atomic="true"></span>
|
||||
<button class="btn-secondary" id="openapi-import-page-next" type="button" data-i18n="openapi.pagination.next">Next</button>
|
||||
</nav>
|
||||
<div class="openapi-import-footer">
|
||||
<span id="openapi-import-selection" data-i18n="openapi.selection.empty">Выбрано: 0</span>
|
||||
<button class="btn-primary" id="openapi-import-create" type="button" data-i18n="openapi.plan.create">Просмотреть план импорта</button>
|
||||
@@ -441,11 +450,20 @@
|
||||
<section class="openapi-import-plan-confirmation" id="openapi-import-plan-confirmation" data-testid="openapi-import-apply-confirmation" aria-labelledby="openapi-import-plan-title" hidden>
|
||||
<h3 id="openapi-import-plan-title" data-i18n="openapi.plan.confirm_title">Подтвердите план импорта</h3>
|
||||
<p class="openapi-import-plan-intro" data-i18n="openapi.plan.confirm_intro">Перед применением проверьте точный план сервера.</p>
|
||||
<p class="openapi-import-plan-version" id="openapi-import-plan-version" data-testid="openapi-import-plan-version"></p>
|
||||
<p class="openapi-import-plan-revalidation" id="openapi-import-plan-revalidation-status" data-testid="openapi-import-plan-revalidation-status" role="status" aria-live="polite" aria-atomic="true"></p>
|
||||
<p class="openapi-import-plan-stale" id="openapi-import-plan-stale" data-testid="openapi-import-plan-stale" hidden></p>
|
||||
<p class="openapi-import-plan-blocked-help" id="openapi-import-plan-blocked-help" data-i18n="openapi.plan.blocked_help" hidden>Исправьте решения для заблокированных операций и создайте план заново.</p>
|
||||
<div class="openapi-import-plan-counts" id="openapi-import-plan-counts" data-testid="openapi-import-apply-counts"></div>
|
||||
<nav class="openapi-import-pagination" id="openapi-import-plan-pagination" data-testid="openapi-import-plan-pagination" data-i18n-aria-label="openapi.pagination.plan_label" aria-label="Plan candidates" hidden>
|
||||
<button class="btn-secondary" id="openapi-import-plan-page-previous" type="button" data-i18n="openapi.pagination.previous">Previous</button>
|
||||
<span id="openapi-import-plan-page-status" data-testid="openapi-import-plan-page-status" role="status" aria-live="polite" aria-atomic="true"></span>
|
||||
<button class="btn-secondary" id="openapi-import-plan-page-next" type="button" data-i18n="openapi.pagination.next">Next</button>
|
||||
</nav>
|
||||
<div class="openapi-import-plan-candidates" id="openapi-import-plan-candidates"></div>
|
||||
<p class="openapi-import-plan-versioning" id="openapi-import-versioning-consequences" data-testid="openapi-import-versioning-consequences" hidden></p>
|
||||
<div class="openapi-import-plan-actions">
|
||||
<button class="btn-secondary" id="openapi-import-plan-reopen" type="button" data-testid="openapi-import-plan-reopen" data-i18n="openapi.plan.reopen">Reopen and check current plan</button>
|
||||
<button class="btn-secondary" id="openapi-import-plan-back" type="button" data-i18n="openapi.plan.back">Назад к выбору</button>
|
||||
<button class="btn-primary" id="openapi-import-plan-apply" type="button" data-testid="openapi-import-plan-apply" data-i18n="openapi.plan.apply">Применить импорт</button>
|
||||
</div>
|
||||
|
||||
@@ -447,6 +447,13 @@
|
||||
signal: options && options.signal,
|
||||
});
|
||||
},
|
||||
revalidateOpenApiImportPlan: function(workspaceId, planReference, options) {
|
||||
return request(API_BASE + '/workspaces/' + encodeURIComponent(workspaceId) + '/imports/openapi/plans/' + encodeURIComponent(planReference), {
|
||||
method: 'GET',
|
||||
headers: headers({ 'Accept-Language': localStorage.getItem('crank_lang') === 'ru' ? 'ru' : 'en' }),
|
||||
signal: options && options.signal,
|
||||
});
|
||||
},
|
||||
applyOpenApiImportPlan: function(workspaceId, planReference, payload, options) {
|
||||
return request(API_BASE + '/workspaces/' + encodeURIComponent(workspaceId) + '/imports/openapi/' + encodeURIComponent(planReference) + '/apply', {
|
||||
method: 'POST',
|
||||
|
||||
+44
-2
@@ -2134,10 +2134,25 @@ Object.assign(TRANSLATIONS.en, {
|
||||
'openapi.method.all': 'All methods',
|
||||
'openapi.select_visible': 'Select visible',
|
||||
'openapi.clear_visible': 'Clear visible',
|
||||
'openapi.partial_mode': 'Enable partial import',
|
||||
'openapi.pagination.previous': 'Previous',
|
||||
'openapi.pagination.next': 'Next',
|
||||
'openapi.pagination.label': 'Preview pages',
|
||||
'openapi.pagination.plan_label': 'Import plan candidates',
|
||||
'openapi.pagination.result_label': 'Import results',
|
||||
'openapi.findings.summary': 'Findings: {count}',
|
||||
'openapi.pagination.status': 'Page {page} of {pages} · {total} matching operations',
|
||||
'openapi.create': 'Create drafts',
|
||||
'openapi.plan.create': 'Review import plan',
|
||||
'openapi.plan.confirm_title': 'Confirm import plan',
|
||||
'openapi.plan.confirm_intro': 'Review the exact server plan before applying it.',
|
||||
'openapi.plan.reopen': 'Reopen and check current plan',
|
||||
'openapi.plan.version': 'Review {version} · reference {reference} · digest {digest}',
|
||||
'openapi.plan.revalidation_pending': 'Checking this saved plan…',
|
||||
'openapi.plan.revalidation_current': 'The saved plan is current.',
|
||||
'openapi.plan.revalidation_stale': 'The saved plan is stale.',
|
||||
'openapi.plan.revalidation_error': 'The saved plan could not be verified.',
|
||||
'openapi.plan.revalidation_guidance': 'Return to the preview and create a new plan before applying.',
|
||||
'openapi.plan.back': 'Back to selection',
|
||||
'openapi.plan.back_fix': 'Back to fix decisions',
|
||||
'openapi.plan.apply': 'Apply import',
|
||||
@@ -2189,8 +2204,11 @@ Object.assign(TRANSLATIONS.en, {
|
||||
'openapi.selection.empty': 'Selected: 0',
|
||||
'openapi.selection': 'Selected: {selected} of {total}, shown: {visible}',
|
||||
'openapi.group.selection': 'selected {selected} of {total}, shown {visible}',
|
||||
'openapi.group.select': 'Select group',
|
||||
'openapi.group.select': 'Select group on this page',
|
||||
'openapi.operation.fields': 'inputs: {input} · outputs: {output}',
|
||||
'openapi.operation.readiness_actionable': 'Actionable',
|
||||
'openapi.operation.readiness_blocked': 'Blocked',
|
||||
'openapi.operation.readiness_unresolved': 'Authentication required',
|
||||
'openapi.mapping.path': 'Path',
|
||||
'openapi.mapping.query': 'Query',
|
||||
'openapi.mapping.header': 'Header',
|
||||
@@ -2199,6 +2217,8 @@ Object.assign(TRANSLATIONS.en, {
|
||||
'openapi.source.summary': '{name} · {size} · methods: {count}',
|
||||
'openapi.status.file_ready': 'File is ready for preview.',
|
||||
'openapi.status.previewing': 'Uploading and parsing the document…',
|
||||
'openapi.status.uploading': 'Uploading the document…',
|
||||
'openapi.status.parsing': 'Parsing the OpenAPI document…',
|
||||
'openapi.status.preview_ready': 'Document is ready. Select methods to import.',
|
||||
'openapi.status.creating': 'Creating drafts…',
|
||||
'openapi.status.created': 'Created: {created}; skipped: {skipped}.',
|
||||
@@ -2243,6 +2263,7 @@ Object.assign(TRANSLATIONS.en, {
|
||||
'openapi.result.fix': 'Fix in wizard',
|
||||
'openapi.result.open': 'Open in wizard',
|
||||
'openapi.result.skipped': 'Skipped',
|
||||
'openapi.result.skipped_count': 'Skipped: {count} candidates',
|
||||
|
||||
});
|
||||
|
||||
@@ -2301,10 +2322,25 @@ Object.assign(TRANSLATIONS.ru, {
|
||||
'openapi.method.all': 'Все методы',
|
||||
'openapi.select_visible': 'Выбрать видимые',
|
||||
'openapi.clear_visible': 'Снять видимые',
|
||||
'openapi.partial_mode': 'Включить частичный импорт',
|
||||
'openapi.pagination.previous': 'Назад',
|
||||
'openapi.pagination.next': 'Далее',
|
||||
'openapi.pagination.label': 'Страницы предпросмотра',
|
||||
'openapi.pagination.plan_label': 'Кандидаты плана импорта',
|
||||
'openapi.pagination.result_label': 'Результаты импорта',
|
||||
'openapi.findings.summary': 'Замечаний: {count}',
|
||||
'openapi.pagination.status': 'Страница {page} из {pages} · операций по фильтру: {total}',
|
||||
'openapi.create': 'Создать черновики',
|
||||
'openapi.plan.create': 'Проверить план импорта',
|
||||
'openapi.plan.confirm_title': 'Подтвердите план импорта',
|
||||
'openapi.plan.confirm_intro': 'Перед применением проверьте точный план сервера.',
|
||||
'openapi.plan.reopen': 'Повторно открыть и проверить план',
|
||||
'openapi.plan.version': 'Проверка {version} · ссылка {reference} · digest {digest}',
|
||||
'openapi.plan.revalidation_pending': 'Проверяем сохранённый план…',
|
||||
'openapi.plan.revalidation_current': 'Сохранённый план актуален.',
|
||||
'openapi.plan.revalidation_stale': 'Сохранённый план устарел.',
|
||||
'openapi.plan.revalidation_error': 'Не удалось проверить сохранённый план.',
|
||||
'openapi.plan.revalidation_guidance': 'Вернитесь к предпросмотру и создайте новый план перед применением.',
|
||||
'openapi.plan.back': 'Назад к выбору',
|
||||
'openapi.plan.back_fix': 'Назад к исправлению решений',
|
||||
'openapi.plan.apply': 'Применить импорт',
|
||||
@@ -2356,8 +2392,11 @@ Object.assign(TRANSLATIONS.ru, {
|
||||
'openapi.selection.empty': 'Выбрано: 0',
|
||||
'openapi.selection': 'Выбрано: {selected} из {total}, показано: {visible}',
|
||||
'openapi.group.selection': 'выбрано {selected} из {total}, показано {visible}',
|
||||
'openapi.group.select': 'Выбрать группу',
|
||||
'openapi.group.select': 'Выбрать группу на этой странице',
|
||||
'openapi.operation.fields': 'входов: {input} · выходов: {output}',
|
||||
'openapi.operation.readiness_actionable': 'Можно импортировать',
|
||||
'openapi.operation.readiness_blocked': 'Заблокировано',
|
||||
'openapi.operation.readiness_unresolved': 'Требуется авторизация',
|
||||
'openapi.mapping.path': 'Path',
|
||||
'openapi.mapping.query': 'Query',
|
||||
'openapi.mapping.header': 'Header',
|
||||
@@ -2366,6 +2405,8 @@ Object.assign(TRANSLATIONS.ru, {
|
||||
'openapi.source.summary': '{name} · {size} · методов: {count}',
|
||||
'openapi.status.file_ready': 'Файл готов к разбору.',
|
||||
'openapi.status.previewing': 'Загружаю и разбираю документ…',
|
||||
'openapi.status.uploading': 'Загружаю документ…',
|
||||
'openapi.status.parsing': 'Разбираю документ OpenAPI…',
|
||||
'openapi.status.preview_ready': 'Документ готов. Выберите методы для импорта.',
|
||||
'openapi.status.creating': 'Создаю черновики…',
|
||||
'openapi.status.created': 'Создано: {created}; пропущено: {skipped}.',
|
||||
@@ -2410,6 +2451,7 @@ Object.assign(TRANSLATIONS.ru, {
|
||||
'openapi.result.fix': 'Исправить в мастере',
|
||||
'openapi.result.open': 'Открыть в мастере',
|
||||
'openapi.result.skipped': 'Пропущено',
|
||||
'openapi.result.skipped_count': 'Пропущено кандидатов: {count}',
|
||||
|
||||
|
||||
});
|
||||
|
||||
+585
-175
File diff suppressed because it is too large.
Load diff
@@ -254,6 +254,7 @@ test('[P1] AC-13 submits the confirmed new_version decision for the exact existi
|
||||
const operationCheckbox = operationRow.locator('[data-openapi-operation]');
|
||||
await expect(operationCheckbox).toBeVisible();
|
||||
const operationKey = await operationCheckbox.inputValue();
|
||||
await page.locator('#openapi-import-partial-mode').check();
|
||||
for (const checkbox of await page.locator('[data-openapi-operation]').all()) {
|
||||
if (await checkbox.inputValue() !== operationKey) await checkbox.uncheck();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,273 @@
|
||||
// Operator-run AC-11 evidence against a Reference Deployment. This spec is
|
||||
// intentionally separate from the local/mocked Playwright matrix.
|
||||
const fs = require('node:fs');
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const { localized, login } = require('./helpers');
|
||||
|
||||
// Remote operator credentials must not enter retry artifacts or failure captures.
|
||||
test.use({ trace: 'off', video: 'off', screenshot: 'off' });
|
||||
test.describe.configure({ retries: 0 });
|
||||
|
||||
const referenceBaseUrl = process.env.PLAYWRIGHT_BASE_URL;
|
||||
const SAMPLE_COUNT = 20;
|
||||
const OPERATION_COUNT = 2000;
|
||||
const MAX_UPLOAD_BYTES = 256 * 1024;
|
||||
const MAX_P95_MS = 2000;
|
||||
|
||||
function openApiDocument(operationCount) {
|
||||
const lines = [
|
||||
'openapi: 3.0.3',
|
||||
'info:',
|
||||
' title: Crank Reference Preview Benchmark',
|
||||
' version: "1.0.0"',
|
||||
'servers:',
|
||||
' - url: https://api.example.test',
|
||||
'paths:',
|
||||
];
|
||||
|
||||
for (let index = 0; index < operationCount; index += 1) {
|
||||
lines.push(` /op-${index}:`);
|
||||
lines.push(' get:');
|
||||
lines.push(' responses:');
|
||||
lines.push(' "200":');
|
||||
lines.push(' description: OK');
|
||||
}
|
||||
|
||||
return Buffer.from(lines.join('\n') + '\n', 'utf8');
|
||||
}
|
||||
|
||||
function percentile95(samples) {
|
||||
const sorted = [...samples].sort((left, right) => left - right);
|
||||
return sorted[Math.ceil(sorted.length * 0.95) - 1];
|
||||
}
|
||||
|
||||
function safeReferenceOrigin(rawUrl) {
|
||||
const url = new URL(rawUrl);
|
||||
if (!['http:', 'https:'].includes(url.protocol)) {
|
||||
throw new Error('PLAYWRIGHT_BASE_URL must use http or https');
|
||||
}
|
||||
if (url.username || url.password || url.search || url.hash) {
|
||||
throw new Error('PLAYWRIGHT_BASE_URL must not contain credentials, query parameters, or fragments');
|
||||
}
|
||||
if (['localhost', '127.0.0.1', '::1'].includes(url.hostname)) {
|
||||
throw new Error('AC-11 Reference benchmark requires a remote PLAYWRIGHT_BASE_URL');
|
||||
}
|
||||
return url.origin;
|
||||
}
|
||||
|
||||
function readReferenceManifest(manifestPath) {
|
||||
if (!manifestPath) {
|
||||
throw new Error('CRANK_AC11_REFERENCE_ENV_JSON is required when PLAYWRIGHT_BASE_URL is set');
|
||||
}
|
||||
|
||||
let manifest;
|
||||
try {
|
||||
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
} catch (_error) {
|
||||
throw new Error('CRANK_AC11_REFERENCE_ENV_JSON must point to a readable valid JSON manifest');
|
||||
}
|
||||
|
||||
const deployment = manifest && manifest.deployment;
|
||||
const loadGenerator = manifest && manifest.load_generator;
|
||||
const browser = manifest && manifest.browser;
|
||||
const nonempty = (value) => typeof value === 'string' && value.trim().length > 0;
|
||||
const finiteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
||||
const versionHasMajor = (value, major) => nonempty(value) && new RegExp(`^${major}(?:\\.|$)`).test(value.trim());
|
||||
|
||||
if (!deployment || !loadGenerator || !browser) {
|
||||
throw new Error('Reference manifest requires deployment, load_generator, and browser objects');
|
||||
}
|
||||
for (const [name, host] of [['deployment', deployment], ['load_generator', loadGenerator], ['browser', browser]]) {
|
||||
if (!nonempty(host.host_id)) throw new Error(`Reference manifest ${name}.host_id is required`);
|
||||
}
|
||||
if (deployment.host_id.trim() === loadGenerator.host_id.trim()
|
||||
|| deployment.host_id.trim() === browser.host_id.trim()) {
|
||||
throw new Error('Reference manifest requires deployment and load generator/browser on separate hosts');
|
||||
}
|
||||
if (!nonempty(deployment.cpu_model) || !nonempty(deployment.storage_type)
|
||||
|| deployment.storage_type.trim().toLowerCase() !== 'ssd'
|
||||
|| !finiteNumber(deployment.cpu_cores)
|
||||
|| !finiteNumber(deployment.ram_gib) || !finiteNumber(deployment.ssd_iops)
|
||||
|| !finiteNumber(deployment.ssd_throughput_mb_s) || !finiteNumber(deployment.ssd_capacity_gb)
|
||||
|| !finiteNumber(deployment.lan_mbps)
|
||||
|| !versionHasMajor(deployment.postgres_version, 16)
|
||||
|| !versionHasMajor(deployment.valkey_version, 8)) {
|
||||
throw new Error('Reference manifest is missing valid CPU, RAM, database, SSD, or LAN fields');
|
||||
}
|
||||
if (deployment.cpu_cores !== 4 || deployment.ram_gib !== 8
|
||||
|| deployment.ssd_capacity_gb < 100 || deployment.ssd_iops < 3000
|
||||
|| deployment.ssd_throughput_mb_s < 100
|
||||
|| deployment.lan_mbps < 1000) {
|
||||
throw new Error('Reference deployment must meet 4 CPU / 8 GiB RAM, SSD 3000 IOPS / 100 MB/s, and 1 Gbit LAN');
|
||||
}
|
||||
if (!finiteNumber(loadGenerator.cpu_cores) || !finiteNumber(loadGenerator.ram_gib)
|
||||
|| loadGenerator.cpu_cores !== 4 || loadGenerator.ram_gib !== 8) {
|
||||
throw new Error('Reference load_generator must have 4 CPU and 8 GiB RAM');
|
||||
}
|
||||
|
||||
// Emit only the fields needed for benchmark interpretation. Do not copy
|
||||
// arbitrary manifest keys (which could contain credentials) into reports.
|
||||
return {
|
||||
provenance: 'operator_manifest',
|
||||
deployment: {
|
||||
cpu_model: deployment.cpu_model.trim(),
|
||||
cpu_cores: deployment.cpu_cores,
|
||||
ram_gib: deployment.ram_gib,
|
||||
postgres_version: deployment.postgres_version.trim(),
|
||||
valkey_version: deployment.valkey_version.trim(),
|
||||
storage_type: 'SSD',
|
||||
ssd_capacity_gb: deployment.ssd_capacity_gb,
|
||||
ssd_iops: deployment.ssd_iops,
|
||||
ssd_throughput_mb_s: deployment.ssd_throughput_mb_s,
|
||||
lan_mbps: deployment.lan_mbps,
|
||||
},
|
||||
load_generator: { cpu_cores: loadGenerator.cpu_cores, ram_gib: loadGenerator.ram_gib },
|
||||
browser_host_separate_from_deployment: true,
|
||||
};
|
||||
}
|
||||
|
||||
test('[P1][reference] AC-11 measures 20 real 2000-operation preview round trips', async ({ page }, testInfo) => {
|
||||
test.skip(!referenceBaseUrl, 'Set PLAYWRIGHT_BASE_URL to a Reference Deployment to run AC-11 evidence');
|
||||
test.setTimeout(300_000);
|
||||
|
||||
expect(process.env.PLAYWRIGHT_SKIP_WEB_SERVER).toBe('1');
|
||||
const referenceOrigin = safeReferenceOrigin(referenceBaseUrl);
|
||||
const referenceManifest = readReferenceManifest(process.env.CRANK_AC11_REFERENCE_ENV_JSON);
|
||||
const yaml = openApiDocument(OPERATION_COUNT);
|
||||
expect(yaml.byteLength).toBeLessThan(MAX_UPLOAD_BYTES);
|
||||
|
||||
await login(page);
|
||||
await page.waitForFunction(() => Boolean(document.querySelector('[data-testid="onboarding-dismiss"]')));
|
||||
await page.locator('[data-testid="onboarding-dismiss"]').click();
|
||||
await expect(page.locator('#crank-onboarding-panel')).toBeHidden();
|
||||
await page.evaluate(() => window.setLang('en'));
|
||||
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: 'reference-preview-2000.yaml',
|
||||
mimeType: 'application/yaml',
|
||||
buffer: yaml,
|
||||
});
|
||||
|
||||
const previewButton = page.locator('#openapi-import-preview');
|
||||
const createButton = page.locator('#openapi-import-create');
|
||||
const rows = page.locator('.openapi-import-operation');
|
||||
const samplesMs = [];
|
||||
let browserEnvironment;
|
||||
|
||||
// Warm the preview once before timing. Warm-up still uses the real remote
|
||||
// preview API.
|
||||
const warmupResponsePromise = page.waitForResponse((response) =>
|
||||
response.request().method() === 'POST'
|
||||
&& response.url().includes('/imports/openapi/preview'),
|
||||
);
|
||||
await previewButton.click();
|
||||
const warmupResponse = await warmupResponsePromise;
|
||||
expect(warmupResponse.status(), 'warm-up preview status').toBe(200);
|
||||
expect(new URL(warmupResponse.url()).origin).toBe(referenceOrigin);
|
||||
await expect(page.locator('[data-testid="openapi-import-page-status"]')).toContainText('2000');
|
||||
await expect(createButton).toBeEnabled();
|
||||
|
||||
const previewResponses = [];
|
||||
page.on('response', (response) => {
|
||||
if (response.request().method() === 'POST' && response.url().includes('/imports/openapi/preview')) {
|
||||
previewResponses.push({ status: response.status(), url: response.url() });
|
||||
}
|
||||
});
|
||||
|
||||
for (let sampleIndex = 0; sampleIndex < SAMPLE_COUNT; sampleIndex += 1) {
|
||||
await expect(previewButton).toBeEnabled();
|
||||
await page.evaluate((index) => {
|
||||
const measurements = window.__ac11Measurements || (window.__ac11Measurements = []);
|
||||
const sample = { start: null, elapsed: null };
|
||||
measurements[index] = sample;
|
||||
const ready = () => {
|
||||
const panel = document.querySelector('#openapi-import-preview-panel');
|
||||
const button = document.querySelector('#openapi-import-preview');
|
||||
const status = document.querySelector('[data-testid="openapi-import-page-status"]');
|
||||
const create = document.querySelector('#openapi-import-create');
|
||||
const rowCount = document.querySelectorAll('.openapi-import-operation').length;
|
||||
if (sample.start === null || !button || button.disabled || !panel || panel.hidden
|
||||
|| !status || !status.textContent.includes('2000') || !create || create.disabled
|
||||
|| rowCount < 1 || rowCount > 100) return;
|
||||
sample.elapsed = Number((performance.now() - sample.start).toFixed(3));
|
||||
observer.disconnect();
|
||||
};
|
||||
const observer = new MutationObserver(ready);
|
||||
observer.observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true });
|
||||
document.addEventListener('click', (event) => {
|
||||
if (event.target.closest('#openapi-import-preview')) sample.start = performance.now();
|
||||
}, { capture: true, once: true });
|
||||
}, sampleIndex);
|
||||
const responsePromise = page.waitForResponse((response) =>
|
||||
response.request().method() === 'POST'
|
||||
&& response.url().includes('/imports/openapi/preview'),
|
||||
);
|
||||
await previewButton.click();
|
||||
const previewResponse = await responsePromise;
|
||||
expect(previewResponse.status(), `preview sample ${sampleIndex + 1} status`).toBe(200);
|
||||
expect(new URL(previewResponse.url()).origin).toBe(referenceOrigin);
|
||||
|
||||
await page.waitForFunction((index) => {
|
||||
const sample = window.__ac11Measurements && window.__ac11Measurements[index];
|
||||
return sample && sample.elapsed !== null;
|
||||
}, sampleIndex, { polling: 'raf' });
|
||||
const elapsed = await page.evaluate((index) => window.__ac11Measurements[index].elapsed, sampleIndex);
|
||||
|
||||
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
|
||||
await expect(page.locator('[data-testid="openapi-import-page-status"]')).toContainText('2000');
|
||||
await expect(rows.first()).toBeVisible();
|
||||
expect(await rows.count()).toBeGreaterThan(0);
|
||||
expect(await rows.count()).toBeLessThanOrEqual(100);
|
||||
await expect(createButton).toBeEnabled();
|
||||
|
||||
samplesMs.push(elapsed);
|
||||
browserEnvironment = await page.evaluate(() => ({
|
||||
user_agent: navigator.userAgent,
|
||||
platform: navigator.platform,
|
||||
language: navigator.language,
|
||||
hardware_concurrency: navigator.hardwareConcurrency || null,
|
||||
viewport: { width: innerWidth, height: innerHeight },
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
}));
|
||||
}
|
||||
|
||||
expect(previewResponses).toHaveLength(SAMPLE_COUNT);
|
||||
expect(previewResponses.every((item) => item.status === 200)).toBe(true);
|
||||
const p95Ms = percentile95(samplesMs);
|
||||
const report = {
|
||||
benchmark: 'story-2.12-ac-11-reference-preview',
|
||||
generated_at: new Date().toISOString(),
|
||||
result: { sample_count: samplesMs.length, p95_ms: p95Ms, threshold_ms: MAX_P95_MS },
|
||||
workload: {
|
||||
operations: OPERATION_COUNT,
|
||||
yaml_bytes: yaml.byteLength,
|
||||
max_yaml_bytes: MAX_UPLOAD_BYTES,
|
||||
preview_http_statuses: previewResponses.map((item) => item.status),
|
||||
rendered_operation_rows: await rows.count(),
|
||||
max_rendered_operation_rows: 100,
|
||||
enabled_interaction: 'Create button enabled after preview',
|
||||
interaction_enabled: true,
|
||||
measurement_scope: 'click through real HTTP request, parsing, populated first page, and enabled Create button',
|
||||
},
|
||||
samples_ms: samplesMs,
|
||||
environment: {
|
||||
reference_origin: referenceOrigin,
|
||||
playwright_base_url_configured: true,
|
||||
playwright_skip_web_server: process.env.PLAYWRIGHT_SKIP_WEB_SERVER === '1',
|
||||
node_version: process.version,
|
||||
os_platform: process.platform,
|
||||
os_arch: process.arch,
|
||||
browser: browserEnvironment,
|
||||
reference_manifest: referenceManifest,
|
||||
},
|
||||
};
|
||||
|
||||
const rawReport = JSON.stringify(report, null, 2);
|
||||
await testInfo.attach('ac11-reference-preview-report.json', {
|
||||
body: Buffer.from(rawReport),
|
||||
contentType: 'application/json',
|
||||
});
|
||||
console.log('AC11_REFERENCE_PREVIEW_REPORT ' + JSON.stringify(report));
|
||||
expect(p95Ms, 'Reference preview p95 must be at most 2 seconds').toBeLessThanOrEqual(MAX_P95_MS);
|
||||
});
|
||||
@@ -142,7 +142,9 @@ paths:
|
||||
const request = await previewRequest;
|
||||
expect(request.headers()['content-type']).toMatch(/^multipart\/form-data; boundary=/i);
|
||||
await expect(page.locator('#openapi-import-preview-panel')).toBeVisible();
|
||||
await expect(page.locator('.openapi-import-document-findings')).toContainText(/base URL/i);
|
||||
const documentFindings = page.locator('.openapi-import-document-findings');
|
||||
await documentFindings.locator('summary').click();
|
||||
await expect(documentFindings).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();
|
||||
@@ -159,6 +161,7 @@ paths:
|
||||
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-partial-mode').check();
|
||||
await page.locator('#openapi-import-clear-visible').click();
|
||||
await expect(page.locator('#openapi-import-selection')).toContainText(localized('Selected: 1', 'Выбрано: 1'));
|
||||
await page.locator('#openapi-import-search').fill('');
|
||||
@@ -174,7 +177,9 @@ paths:
|
||||
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', 'Описание инструмента слишком короткое'));
|
||||
const operationFindings = importedOperation.locator('.openapi-import-findings');
|
||||
await operationFindings.locator('summary').click();
|
||||
await expect(operationFindings).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);
|
||||
@@ -272,7 +277,7 @@ test('OpenAPI upload recovers from pagehide and a preview server error', async (
|
||||
buffer: Buffer.from('openapi: 3.0.3'),
|
||||
});
|
||||
await page.locator('#openapi-import-preview').click();
|
||||
await expect(page.locator('#openapi-import-status')).toContainText(localized('Uploading and parsing', 'Загружаю и разбираю'));
|
||||
await expect(page.locator('#openapi-import-status')).toContainText(localized('Uploading the document', 'Загружаю документ'));
|
||||
|
||||
await page.evaluate(() => window.dispatchEvent(new PageTransitionEvent('pagehide', { persisted: true })));
|
||||
await expect(page.locator('#openapi-import-status')).toHaveText('');
|
||||
|
||||
Reference in new issue
Block a user