feat: expose streaming test run results
This commit is contained in:
@@ -831,10 +831,18 @@ var TRANSLATIONS = {
|
||||
'wizard.test.failed': 'Test run returned errors',
|
||||
'wizard.test.completed_body': 'The current draft executed successfully against the upstream.',
|
||||
'wizard.test.failed_body': 'The draft executed, but the backend returned validation or runtime errors.',
|
||||
'wizard.test.window_completed': 'Window test completed',
|
||||
'wizard.test.window_completed_body': 'Window complete: {window_complete}. Truncated: {truncated}. Has more: {has_more}.',
|
||||
'wizard.test.session_started': 'Session test started',
|
||||
'wizard.test.session_started_body': 'Session {session_id} was created. Poll after {poll_after_ms} ms from the stream sessions view.',
|
||||
'wizard.test.async_job_started': 'Async job test started',
|
||||
'wizard.test.async_job_started_body': 'Async job {job_id} was created. Track status and result from the async jobs view.',
|
||||
'wizard.test.no_response': 'No test response yet',
|
||||
'wizard.test.no_response_body': 'Run a test first, then copy the response preview into the output sample editor.',
|
||||
'wizard.test.response_copied': 'Response copied',
|
||||
'wizard.test.response_copied_body': 'The latest test response was copied into the output sample editor.',
|
||||
'wizard.boolean.yes': 'yes',
|
||||
'wizard.boolean.no': 'no',
|
||||
'wizard.yaml.exported': 'YAML exported',
|
||||
'wizard.yaml.exported_body': 'The current draft YAML was downloaded from the backend.',
|
||||
'wizard.yaml.none': 'No YAML provided',
|
||||
@@ -1813,10 +1821,18 @@ var TRANSLATIONS = {
|
||||
'wizard.test.failed': 'Тестовый прогон вернул ошибки',
|
||||
'wizard.test.completed_body': 'Текущий черновик успешно выполнился против upstream.',
|
||||
'wizard.test.failed_body': 'Черновик выполнился, но backend вернул ошибки валидации или runtime.',
|
||||
'wizard.test.window_completed': 'Оконный тест завершен',
|
||||
'wizard.test.window_completed_body': 'Окно завершено: {window_complete}. Усечено: {truncated}. Есть продолжение: {has_more}.',
|
||||
'wizard.test.session_started': 'Session-тест запущен',
|
||||
'wizard.test.session_started_body': 'Создана session {session_id}. Следующий poll можно делать через {poll_after_ms} мс из представления stream sessions.',
|
||||
'wizard.test.async_job_started': 'Async job тест запущен',
|
||||
'wizard.test.async_job_started_body': 'Создан async job {job_id}. Отслеживайте статус и результат через представление async jobs.',
|
||||
'wizard.test.no_response': 'Тестового ответа пока нет',
|
||||
'wizard.test.no_response_body': 'Сначала выполните тест, затем скопируйте response preview в editor output sample.',
|
||||
'wizard.test.response_copied': 'Ответ скопирован',
|
||||
'wizard.test.response_copied_body': 'Последний тестовый ответ скопирован в editor output sample.',
|
||||
'wizard.boolean.yes': 'да',
|
||||
'wizard.boolean.no': 'нет',
|
||||
'wizard.yaml.exported': 'YAML экспортирован',
|
||||
'wizard.yaml.exported_body': 'YAML текущего черновика скачан из backend.',
|
||||
'wizard.yaml.none': 'YAML не предоставлен',
|
||||
|
||||
+45
-5
@@ -2546,6 +2546,47 @@ function setTextareaValue(id, value) {
|
||||
element.value = safeStringify(value);
|
||||
}
|
||||
|
||||
function describeWizardTestResult(result) {
|
||||
if (result.stream_session && result.stream_session.session_id) {
|
||||
return {
|
||||
title: tKey('wizard.test.session_started'),
|
||||
body: tfKey('wizard.test.session_started_body', {
|
||||
session_id: result.stream_session.session_id,
|
||||
poll_after_ms: result.stream_session.poll_after_ms
|
||||
}),
|
||||
isError: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (result.async_job && result.async_job.job_id) {
|
||||
return {
|
||||
title: tKey('wizard.test.async_job_started'),
|
||||
body: tfKey('wizard.test.async_job_started_body', {
|
||||
job_id: result.async_job.job_id
|
||||
}),
|
||||
isError: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (result.window) {
|
||||
return {
|
||||
title: result.ok ? tKey('wizard.test.window_completed') : tKey('wizard.test.failed'),
|
||||
body: tfKey('wizard.test.window_completed_body', {
|
||||
truncated: result.window.truncated ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no'),
|
||||
has_more: result.window.has_more ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no'),
|
||||
window_complete: result.window.window_complete ? tKey('wizard.boolean.yes') : tKey('wizard.boolean.no')
|
||||
}),
|
||||
isError: !result.ok,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: result.ok ? tKey('wizard.test.completed') : tKey('wizard.test.failed'),
|
||||
body: result.ok ? tKey('wizard.test.completed_body') : tKey('wizard.test.failed_body'),
|
||||
isError: !result.ok,
|
||||
};
|
||||
}
|
||||
|
||||
async function uploadInputSampleFromWizard() {
|
||||
await persistCurrentDraft(true);
|
||||
await window.CrankApi.uploadInputSample(
|
||||
@@ -2586,12 +2627,11 @@ async function runWizardTest() {
|
||||
setTextareaValue('wizard-test-request-preview', result.request_preview);
|
||||
setTextareaValue('wizard-test-response-preview', result.response_preview);
|
||||
setTextareaValue('wizard-test-errors', result.errors && result.errors.length ? result.errors : []);
|
||||
var status = describeWizardTestResult(result);
|
||||
showWizardLiveStatus(
|
||||
result.ok ? tKey('wizard.test.completed') : tKey('wizard.test.failed'),
|
||||
result.ok
|
||||
? tKey('wizard.test.completed_body')
|
||||
: tKey('wizard.test.failed_body'),
|
||||
!result.ok
|
||||
status.title,
|
||||
status.body,
|
||||
status.isError
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user