import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; globalThis.location = new URL('https://panel.example.test/user/cloud'); const copyFixture = { 'common.tasks.error.protocol': '任务状态协议无效,请联系管理员核查。', 'common.tasks.resolved.partial': '原任务失败;系统已确认部分宿主机已应用、部分未应用,未确认状态已收敛,资源锁已解除。', 'common.tasks.resolved.applied': '原任务失败,但系统已确认操作已应用,资源锁已解除。', 'common.tasks.resolved.not_applied': '原任务失败,但系统已确认操作未应用,资源锁已解除。', 'common.tasks.duration.day': '{count} 天', 'common.tasks.duration.hour': '{count} 小时', 'common.tasks.duration.minute': '{count} 分钟', 'common.tasks.duration.second': '{count} 秒', 'common.tasks.fallback_title': '后台任务', }; globalThis.VenixUserCopy = { locale: 'zh-CN', text(key, parameters = {}) { return (copyFixture[key] || key).replace(/\{([a-z_]+)\}/g, (match, name) => Object.prototype.hasOwnProperty.call(parameters, name) ? String(parameters[name]) : match); }, }; const observerUrl = new URL('../public/cloud/task-observer.js', import.meta.url); const centerUrl = new URL('../public/cloud/task-center.js', import.meta.url); const appUrl = new URL('../public/cloud/app.js', import.meta.url); const clientCssUrl = new URL('../public/cloud/client.css', import.meta.url); const layoutAssetsUrl = new URL('../resources/views/venix/layout_assets.tpl', import.meta.url); const adminUrl = new URL('../public/cloud/admin-hosts.js', import.meta.url); const detailUrl = new URL('../public/cloud/detail.js', import.meta.url); const adminInstancesUrl = new URL('../public/cloud/admin-instances.js', import.meta.url); const adminInstanceTransportUrl = new URL('../public/cloud/admin-instance-actions.js', import.meta.url); const adminInstanceConfigurationUrl = new URL('../public/cloud/admin-instance-configuration.js', import.meta.url); const adminInstanceBackupsUrl = new URL('../public/cloud/admin-instance-backups.js', import.meta.url); const runtimeUrl = new URL('../public/cloud/runtime.js', import.meta.url); const isoImagesUrl = new URL('../public/cloud/iso-images.js', import.meta.url); const invoiceDetailRuntimeUrl = new URL('../public/cloud/invoice-detail-runtime.js', import.meta.url); const reinstallViewUrl = new URL('../resources/views/venix/cloud/pages/reinstall.tpl', import.meta.url); const { normalizeTask, observeTask, readTask, recoveryTaskFailureNotice, resolvedTaskFailureNotice, taskSucceededWithoutRecovery, taskUrl, } = await import(`${observerUrl.href}?test=${Date.now()}`); const { dateText, taskDurationText, taskTitle } = await import(`${centerUrl.href}?test=${Date.now()}`); const protocolFailure = task => { assert.equal(task.terminal, true); assert.equal(task.completed, true); assert.equal(task.status, 'failed'); assert.equal(task.error_code, 'task_protocol_invalid'); assert.equal(task.effect_may_have_applied, true); assert.equal(task.safe_to_resubmit, false); }; // The fresh public contract has exactly one active representation and two // terminal states. Legacy aliases and incomplete envelopes fail closed. { const running = normalizeTask({ id: '41', completed: false }); assert.equal(running.status, 'running'); assert.equal(running.terminal, false); for (const status of ['succeeded', 'failed']) { const task = normalizeTask({ id: '41', completed: true, status }); assert.equal(task.status, status); assert.equal(task.terminal, true); assert.equal(taskSucceededWithoutRecovery(task), status === 'succeeded'); } for (const malformed of [ { completed: false }, { id: 'not-a-task', completed: false }, { id: '41' }, { id: '41', completed: false, status: 'running' }, { id: '41', completed: true }, { id: '41', completed: true, status: 'success' }, { id: '41', completed: true, status: 'completed' }, { id: '41', completed: true, status: 'done' }, { id: '41', completed: true, status: 'cancelled' }, { id: '41', completed: true, status: 'uncertain' }, { id: '41', completed: true, status: 'needs_attention' }, { id: '41', completed: true, status: 'SUCCEEDED' }, ]) protocolFailure(normalizeTask(malformed)); const failed = normalizeTask({ id: '42', completed: true, status: 'failed', error: 'host result lost', error_code: 'agent_timeout', effect_may_have_applied: true, safe_to_resubmit: true, failure: { effect_may_have_applied: false, safe_to_resubmit: true }, }); assert.equal(failed.effect_may_have_applied, true); assert.equal(failed.safe_to_resubmit, false, 'A possibly-applied task can never be resubmitted.'); assert.equal(failed.error, 'host result lost'); assert.equal(Object.prototype.hasOwnProperty.call(failed, 'failure'), false); const nestedOnly = normalizeTask({ id: '43', completed: true, status: 'failed', failure: { error: 'legacy', effect_may_have_applied: true, safe_to_resubmit: true }, }); assert.equal(nestedOnly.error, ''); assert.equal(nestedOnly.effect_may_have_applied, false); assert.equal(nestedOnly.safe_to_resubmit, false); for (const [effectResolution, expected] of [ ['applied', '原任务失败,但系统已确认操作已应用,资源锁已解除。'], ['not_applied', '原任务失败,但系统已确认操作未应用,资源锁已解除。'], ]) { const resolved = normalizeTask({ id: '44', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, effect_resolution: effectResolution, }); assert.equal(resolved.status, 'failed'); assert.equal(resolved.terminal, true); assert.equal(resolved.effect_resolution, effectResolution); assert.equal(resolvedTaskFailureNotice(resolved), expected); } const partial = normalizeTask({ id: '440', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, effect_resolution: 'applied', effect_scope: 'partial', }); assert.equal(partial.effect_resolution, 'applied'); assert.equal(partial.effect_scope, 'partial'); assert.equal(resolvedTaskFailureNotice(partial), '原任务失败;系统已确认部分宿主机已应用、部分未应用,未确认状态已收敛,资源锁已解除。'); const partialWithRecovery = normalizeTask({ id: '441', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, effect_resolution: 'applied', effect_scope: 'partial', recovery: { pending: true, message: '账本仍需核对。', last_checked_at: 1, next_check_at: 2, }, }); assert.equal(partialWithRecovery.effect_resolution, null); assert.equal(partialWithRecovery.effect_scope, null); assert.equal(resolvedTaskFailureNotice(partialWithRecovery), ''); for (const payload of [ { id: '45', completed: true, status: 'failed', effect_may_have_applied: true, effect_resolution: 'unknown' }, { id: '46', completed: true, status: 'failed', effect_may_have_applied: true, effect_resolution: 'internal_reviewed' }, { id: '47', completed: true, status: 'failed', effect_may_have_applied: false, effect_resolution: 'applied' }, { id: '48', completed: true, status: 'succeeded', effect_may_have_applied: true, effect_resolution: 'applied' }, ]) { const unresolved = normalizeTask(payload); assert.equal(unresolved.effect_resolution, null); assert.equal(resolvedTaskFailureNotice(unresolved), ''); } const nestedResolution = normalizeTask({ id: '49', completed: true, status: 'failed', effect_may_have_applied: true, failure: { effect_resolution: 'applied' }, }); assert.equal(nestedResolution.effect_resolution, null); const inheritedResolution = Object.assign(Object.create({ effect_resolution: 'applied', }), { id: '50', completed: true, status: 'failed', effect_may_have_applied: true, }); assert.equal(normalizeTask(inheritedResolution).effect_resolution, null); const recovering = normalizeTask({ id: '51', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, recovery: { pending: true, message: 'Agent 回执与宿主机证据暂不一致;系统仍会继续自动核对。', last_checked_at: 1_600_000_000, next_check_at: 1_600_000_030, }, }); assert.deepEqual(recovering.recovery, { pending: true, message: 'Agent 回执与宿主机证据暂不一致;系统仍会继续自动核对。', last_checked_at: 1_600_000_000, next_check_at: 1_600_000_030, }); assert.equal(recoveryTaskFailureNotice(recovering), recovering.recovery.message); const succeededWithInvalidLedger = normalizeTask({ id: '53', completed: true, status: 'succeeded', effect_may_have_applied: false, safe_to_resubmit: false, recovery: { pending: true, message: '任务派发账本异常;资源保持安全锁定。', last_checked_at: 1_600_000_000, next_check_at: 1_600_000_300, }, }); assert.equal(succeededWithInvalidLedger.status, 'succeeded'); assert.equal(succeededWithInvalidLedger.recovery?.pending, true); assert.equal(taskSucceededWithoutRecovery(succeededWithInvalidLedger), false); assert.equal( recoveryTaskFailureNotice(succeededWithInvalidLedger), succeededWithInvalidLedger.recovery.message, ); // A previously resolved failed task can become fenced again when its // dispatch ledger is found corrupt or a repaired counter still has a sticky // incident. Every consumer (task center, instance pages and administrator // pages) shares this normalization, so recovery must win over "已解除". for (const message of [ '任务单次派发计数账本异常;资源保持安全锁定。', '派发计数已修复,但原任务回执未通过完整性校验;不会解锁。', ]) { const failedResolvedButFenced = normalizeTask({ id: '54', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, effect_resolution: 'applied', recovery: { pending: true, message, last_checked_at: 1_600_000_000, next_check_at: 1_600_000_300, }, }); assert.equal(failedResolvedButFenced.effect_resolution, null); assert.equal(failedResolvedButFenced.recovery?.pending, true); assert.equal(resolvedTaskFailureNotice(failedResolvedButFenced), ''); assert.equal(recoveryTaskFailureNotice(failedResolvedButFenced), message); } for (const recovery of [ null, { pending: false, message: '伪造恢复状态' }, { pending: true, message: '' }, { pending: true, message: '服务端原始异常', last_checked_at: 'not-a-time' }, { pending: true, message: '服务端原始异常', next_check_at: -1 }, ]) { const task = normalizeTask({ id: '52', completed: true, status: 'failed', effect_may_have_applied: true, safe_to_resubmit: false, recovery, }); assert.equal(task.recovery, null); assert.equal(recoveryTaskFailureNotice(task), ''); } } // Receipts accept only the two top-level fields from the fresh API. { assert.equal(taskUrl({ task_id: 'a/b' }), ''); assert.equal(taskUrl({ status_url: '/api/v1/tasks/72' }), ''); assert.equal(taskUrl({ task_id: '72', status_url: '/api/v1/tasks/72' }), '/api/v1/tasks/72'); assert.equal(taskUrl({ task_id: '72', status_url: '/api/v1/tasks/72', result: {} }), ''); assert.equal(taskUrl({ task_id: '72', status_url: '/api/v1/tasks/73' }), ''); assert.equal(taskUrl({ status_url: '/api/v1/tasks/72?legacy=1' }), ''); assert.equal(taskUrl({ status_url: 'https://other.example.test/api/v1/tasks/72' }), ''); assert.equal(taskUrl({ id: '72' }), ''); assert.equal(taskUrl({ job_id: '72' }), ''); assert.equal(taskUrl({ task: { id: '72' } }), ''); const invalidDirect = observeTask('/api/v1/tasks/not-a-task', { fetchImpl: async () => { throw new Error('invalid path must not be fetched'); }, delays: [0], maxDurationMs: 1000, requestTimeoutMs: 1000, }); assert.equal(invalidDirect.url, ''); assert.equal(await invalidDirect.done, null); } // HTTP 202 is active and HTTP 200 is terminal. A status/body mismatch becomes // a visible protocol failure instead of another poll cycle. { const response = (status, body) => ({ status, ok: status >= 200 && status < 300, json: async () => body, }); const active = await readTask('/api/v1/tasks/1', { fetchImpl: async () => response(202, { id: '1', completed: false }), }); assert.equal(active.terminal, false); protocolFailure(await readTask('/api/v1/tasks/1', { fetchImpl: async () => response(200, { id: '1', completed: false }), })); protocolFailure(await readTask('/api/v1/tasks/1', { fetchImpl: async () => response(202, { id: '1', completed: true, status: 'succeeded' }), })); protocolFailure(await readTask('/api/v1/tasks/1', { fetchImpl: async () => response(200, { ret: 0, error: 'legacy envelope' }), })); } // Reproduce hidden -> visible before the aborted request's finally block. The // observer must resume exactly once, remain GET-only, and finish at terminal. { class Surface extends EventTarget { constructor() { super(); this.visibilityState = 'visible'; } setTimeout(callback, delay) { return setTimeout(callback, delay); } clearTimeout(id) { clearTimeout(id); } } const documentRef = new Surface(); const windowRef = new Surface(); const requests = []; const fetchImpl = (url, options) => { requests.push({ url, options }); if (requests.length > 1) { return Promise.resolve({ status: 200, ok: true, json: async () => ({ id: '91', completed: true, status: 'succeeded' }), }); } return new Promise((resolve, reject) => { options.signal.addEventListener('abort', () => { queueMicrotask(() => reject(new DOMException('Aborted', 'AbortError'))); }, { once: true }); }); }; const handle = observeTask({ task_id: '91', status_url: '/api/v1/tasks/91' }, { documentRef, windowRef, fetchImpl, delays: [0], maxDurationMs: 2000, requestTimeoutMs: 1000, }); for (let turn = 0; turn < 20 && requests.length < 1; turn += 1) { await new Promise(resolve => setTimeout(resolve, 1)); } assert.equal(requests.length, 1); documentRef.visibilityState = 'hidden'; documentRef.dispatchEvent(new Event('visibilitychange')); documentRef.visibilityState = 'visible'; documentRef.dispatchEvent(new Event('visibilitychange')); const result = await Promise.race([ handle.done, new Promise((_, reject) => setTimeout(() => reject(new Error('observer did not resume')), 500)), ]); assert.equal(result.status, 'succeeded'); assert.equal(requests.length, 2); assert.ok(requests.every(request => request.options.method === 'GET')); } // A long polling interval is clipped to the remaining absolute observation // budget. Stopping at the deadline must not wait for the full next interval. { class ClockSurface extends EventTarget { constructor(now) { super(); this.now = now; this.visibilityState = 'visible'; this.nextId = 1; this.timers = new Map(); } setTimeout(callback, delay) { const id = this.nextId++; this.timers.set(id, { callback, due: this.now + delay }); return id; } clearTimeout(id) { this.timers.delete(id); } async runNext() { const pending = [...this.timers.entries()] .sort((left, right) => left[1].due - right[1].due)[0]; assert.ok(pending, 'fake clock has no pending timer'); const [id, timer] = pending; this.timers.delete(id); this.now = timer.due; timer.callback(); await Promise.resolve(); await Promise.resolve(); } } const originalNow = Date.now; const clock = new ClockSurface(10_000); const documentRef = new ClockSurface(clock.now); Object.defineProperty(documentRef, 'now', { get: () => clock.now, set: () => {}, configurable: true, }); Date.now = () => clock.now; let requests = 0; let stopped = ''; try { const handle = observeTask({ task_id: '92', status_url: '/api/v1/tasks/92' }, { documentRef, windowRef: clock, fetchImpl: async () => { requests += 1; return { status: 202, ok: true, json: async () => ({ id: '92', completed: false }) }; }, delays: [30_000], maxDurationMs: 1000, requestTimeoutMs: 1000, onStop: reason => { stopped = reason; }, }); await clock.runNext(); await Promise.resolve(); await clock.runNext(); assert.equal(await handle.done, null); assert.equal(stopped, 'deadline'); assert.equal(clock.now, 11_000); assert.equal(requests, 1); } finally { Date.now = originalNow; } } // Task-center dates from PHP are Unix seconds, not date strings. { const seconds = 1_600_000_000; assert.equal( dateText(seconds), new Date(seconds * 1000).toLocaleString('zh-CN', { hour12: false }), ); } // Completed-task duration uses the immutable terminal timestamp rather than // later task updates made by recovery bookkeeping. { assert.equal(taskDurationText(100, 100), '0 秒'); assert.equal(taskDurationText(100, 165), '1 分钟 5 秒'); assert.equal(taskDurationText(100, 91061), '1 天 1 小时 16 分钟 1 秒'); assert.equal(taskDurationText(0, 100), ''); assert.equal(taskDurationText(200, 100), ''); assert.equal(taskDurationText(100, undefined), ''); } // Task titles must use the server-owned Chinese presentation label. Internal // protocol identifiers are useful for diagnostics, but must never leak into // the ordinary drawer title when the label is absent or malformed. { assert.equal(taskTitle({ kind: 'instance_settings', kind_label: '实例设置', }), '实例设置'); assert.equal(taskTitle({ kind: 'instance_settings', kind_label: '重置 root 密码', action: 'instance_settings', action_label: null, }), '重置 root 密码'); assert.equal(taskTitle({ kind: 'action', kind_label: '开机', action: 'start', action_label: '开机', }), '开机'); assert.equal(taskTitle({ kind: 'unknown_internal_job', action: 'unknown_internal_action', type: 'legacy_type', }), '后台任务'); } // Keep the integration contract visible in a small static guard: the task // center must query both partitions and acknowledge presentation explicitly. { const source = await readFile(centerUrl, 'utf8'); assert.match(source, /requestPage\('active'/); assert.match(source, /requestPage\('completed'/); assert.match(source, /state=active&limit=1/); assert.match(source, /fetch\('\/api\/v1\/tasks\/read'/); assert.match(source, /body:\s*JSON\.stringify\(\{ ids \}\)/); assert.match(source, /common\.tasks\.group\.running/); assert.match(source, /if \(group\.title\) groupNode\.append\(element\('h2', 'panel-task-group-title', group\.title\)\)/); assert.doesNotMatch(source, /panel-task-group-title', `\$\{group\.title\}(\$\{group\.items\.length\})`/); assert.match(source, /common\.tasks\.details\.id/); assert.doesNotMatch(source, /meta\.append\(element\('code', '', task\.id\)\)/); assert.match(source, /common\.tasks\.count\.visible/); assert.match(source, /byId\('panel-task-more'\)/); assert.match(source, /if \(task\.terminal && task\.id/); assert.match(source, /raw\?\.kind === 'host_storage_configure'/); assert.match(source, /common\.tasks\.warning\.storage_terminated/); assert.match(source, /resolvedTaskFailureNotice\(task\)/); assert.match(source, /recoveryTaskFailureNotice\(task\)/); assert.match(source, /'panel-task-warning', resolvedNotice/); assert.match(source, /recoveringCount/); assert.match(source, /recovering_count/); assert.match(source, /state\.activeCount \+ state\.recoveringCount/); assert.match(source, /state\.recoveringCount < 1 && Date\.now\(\) >= state\.deadline/); assert.match(source, /common\.tasks\.details\.last_error/); assert.match(source, /common\.tasks\.details\.next_check/); assert.match(source, /common\.tasks\.status\.ledger_error/); assert.match(source, /common\.tasks\.details\.duration/); assert.doesNotMatch(source, /复制任务编号|copyButton|panel-task-copy/); assert.doesNotMatch(source, /重试任务|重新提交任务|data-task-retry/); const observerSource = await readFile(observerUrl, 'utf8'); assert.match(observerSource, /common\.tasks\.resolved\.partial/); assert.match(observerSource, /common\.tasks\.resolved\.applied/); assert.match(observerSource, /common\.tasks\.resolved\.not_applied/); assert.doesNotMatch(observerSource, /finalization_error_code/); const appSource = await readFile(appUrl, 'utf8'); const clientCss = await readFile(clientCssUrl, 'utf8'); const layoutAssets = await readFile(layoutAssetsUrl, 'utf8'); const assetVersion = layoutAssets.match(/venix_asset_version value='([0-9]+)'/)?.[1]; assert.ok(assetVersion, 'The shared cloud asset version is missing.'); assert.match(appSource, /const assetVersion = new URL\(import\.meta\.url\)\.searchParams\.get\('v'\);/); assert.match(appSource, /function versionedModuleUrl\(path\)/); assert.match(appSource, /url\.searchParams\.set\('v', assetVersion\)/); assert.match(appSource, /import\(versionedModuleUrl\('\.\/task-center\.js'\)\)/); assert.doesNotMatch(appSource, /task-center\.js\?v=[0-9]+/); assert.match(clientCss, /\.panel-announcements-close\.button:focus,\s*\.panel-task-close\.button:focus,\s*\.panel-account-drawer-close\.button:focus\s*\{/, 'Touch-opened task drawers must match announcements without retaining a close-button frame.'); } // Host storage observation is finite, resumes from the persisted task receipt // when the drawer is reopened, and only refreshes with GET after it stops. { const source = await readFile(adminUrl, 'utf8'); assert.match(source, /payload\.state === 'applying' && payload\.task_id && payload\.status_url/); assert.match(source, /maxDurationMs:\s*300000/); assert.match(source, /reason !== 'deadline'/); assert.match(source, /refreshHostStorageAfterTask/); assert.match(source, /stopHostStorageObserver\('drawer-close'\)/); assert.match(source, /stopHostStorageObserver\('drawer-reopen'\)/); assert.doesNotMatch(source, /任务可能仍在后台执行;当前配置保持锁定/); } // A successful mutation receipt must be handled before any resource refresh, // and legacy mutation retry controls must not remain in the DOM. { const detailSource = await readFile(detailUrl, 'utf8'); assert.match(detailSource, /resolvedTaskFailureNotice\(task\)/); assert.match(detailSource, /resolvedTaskFailureNotice\(normalizeTask\(entry\)\)/); assert.match(detailSource, /recoveryTaskFailureNotice\(task\)/); assert.match(detailSource, /recoveryTaskFailureNotice\(normalizeTask\(entry\)\)/); assert.match(detailSource, /task\.effect_resolution === 'applied'/); assert.match(detailSource, /task\.effect_resolution === 'not_applied'/); const firewallReceipt = detailSource.indexOf('expectedStatus: 202', detailSource.indexOf('async function saveVmFirewall')); const firewallRefresh = detailSource.indexOf('loadVmFirewall(vmId, true, true)', detailSource.indexOf('async function saveVmFirewall')); assert.ok(firewallReceipt >= 0); assert.ok(firewallRefresh < 0 || firewallReceipt < firewallRefresh); assert.match(detailSource, /requireTaskReceipt: true/); assert.match(detailSource, /syncInstanceSettingForm\(form\)/); assert.match(detailSource, /form\?\.dataset\.taskObserving === 'true'/); assert.match(detailSource, /setInstanceSettingTaskObserving\(true\);[\s\S]*watchTask\(receipt, label/); assert.match(detailSource, /setInstanceSettingTaskObserving\(false\)/); assert.match(detailSource, /form\.dataset\.taskObserving === 'true'/); assert.match(detailSource, /snapshotMutation = null;[\s\S]*loadVmSnapshots\(vmId, true, false\)/); assert.match(detailSource, /taskSucceededWithoutRecovery\(task\)/); assert.doesNotMatch(detailSource, /task\.status === 'succeeded'/); const adminInstanceTransportSource = await readFile(adminInstanceTransportUrl, 'utf8'); const adminRequestRuntimeSource = await readFile( new URL('../public/cloud/admin-request-runtime.js', import.meta.url), 'utf8'); const adminInstancesSource = `${await readFile(adminInstancesUrl, 'utf8')}\n${adminInstanceTransportSource}\n${await readFile(adminInstanceConfigurationUrl, 'utf8')}\n${await readFile(adminInstanceBackupsUrl, 'utf8')}`; assert.doesNotMatch(adminInstancesSource, /state\.networkRequest \|\| activeJob/); assert.match(adminInstanceTransportSource, /taskReceiptValidator: tasks.taskUrl/); assert.match(adminInstanceTransportSource, /response: 'task'/); assert.match(adminRequestRuntimeSource, /response\.status !== 202 \|\| !taskReceiptValidator \|\| !taskReceiptValidator\(payload\)/); assert.match(adminInstancesSource, /await onRefresh\?\.\(vm\.id\)/); assert.match(adminInstancesSource, /tasks.recoveryTaskFailureNotice\(task\)/); assert.match(adminInstancesSource, /PHP 本地账本收尾尚未完成/); assert.match(adminInstancesSource, /tasks.taskSucceededWithoutRecovery\(task\)/); assert.doesNotMatch(adminInstancesSource, /task\.status === 'succeeded'/); const runtimeSource = await readFile(runtimeUrl, 'utf8'); assert.match(runtimeSource, /resolvedTaskFailureNotice\(task\)/); assert.match(runtimeSource, /recoveryTaskFailureNotice\(task\)/); assert.match(runtimeSource, /task\.effect_resolution === 'applied'/); assert.match(runtimeSource, /task\.effect_resolution === 'not_applied'/); assert.match(runtimeSource, /expectedStatus: 202, requireTaskReceipt: true/); assert.match(runtimeSource, /syncReinstallControls\(refreshed \|\| selectedVm\(\)\)/); assert.match(runtimeSource, /taskSucceededWithoutRecovery\(task\)/); assert.doesNotMatch(runtimeSource, /task\.status === 'succeeded'/); const isoImagesSource = await readFile(isoImagesUrl, 'utf8'); assert.doesNotMatch(isoImagesSource, /recoveryTaskFailureNotice\(task\)/); assert.doesNotMatch(isoImagesSource, /task\?\.error/); assert.match(isoImagesSource, /task\?\.recovery\?\.pending === true/); assert.match(isoImagesSource, /isos\.task\.failure\.resolved_partial/); assert.match(isoImagesSource, /isos\.task\.failure\.resolved_applied/); assert.match(isoImagesSource, /isos\.task\.failure\.resolved_not_applied/); assert.match(isoImagesSource, /isos\.task\.failure\.effect_unknown/); assert.match(isoImagesSource, /isos\.task\.failure\.locked/); assert.match(isoImagesSource, /method: 'DELETE', expectedStatus: 202, requireTaskReceipt: true/); assert.match(isoImagesSource, /const refreshed = await loadIsos\(\{ observeActive: false \}\)/); assert.match(isoImagesSource, /const canDelete = record\.can_delete === true/); assert.doesNotMatch(isoImagesSource, /const canDelete = String\(record\.state/); assert.match(isoImagesSource, /cleanupReason === 'quota_exceeded_after_import'/); assert.match(isoImagesSource, /isos\.item\.cleanup\.quota/); assert.match(isoImagesSource, /isos\.confirm\.cleanup_downloaded\.title/); assert.match(isoImagesSource, /isos\.confirm\.cleanup_downloaded\.body/); assert.match(isoImagesSource, /cleanupReason === 'partial_import'/); assert.match(isoImagesSource, /cleanupReason === 'partial_delete'/); assert.match(isoImagesSource, /isos\.item\.cleanup\.partial_import/); assert.match(isoImagesSource, /isos\.item\.cleanup\.partial_delete/); assert.match(isoImagesSource, /isos\.confirm\.cleanup_partial_import\.body/); assert.match(isoImagesSource, /isos\.confirm\.cleanup_partial_delete\.body/); assert.match(isoImagesSource, /taskSucceededWithoutRecovery\(task\)/); assert.doesNotMatch(isoImagesSource, /task\.status === 'succeeded'/); const adminOperationsSource = [ await readFile(new URL('../public/cloud/admin-operations.js', import.meta.url), 'utf8'), await readFile(new URL('../public/cloud/admin-operation-presentation.js', import.meta.url), 'utf8'), await readFile(new URL('../public/cloud/admin-operations-recovery.js', import.meta.url), 'utf8'), ].join('\n'); assert.match(adminOperationsSource, /recoveryTaskFailureNotice\(task\)/); assert.match(adminOperationsSource, /job\.recovery\?\.pending/); assert.match(adminOperationsSource, /最近异常/); assert.match(adminOperationsSource, /下次核对/); assert.match(adminOperationsSource, /派发账本修复/); assert.match(adminOperationsSource, /PHP 本地账本收尾/); assert.match(adminOperationsSource, /taskSucceededWithoutRecovery\(task\)/); assert.doesNotMatch(adminOperationsSource, /task\.status === 'succeeded'/); assert.match(sourceForSuccessGuard(await readFile(adminUrl, 'utf8')), /taskSucceededWithoutRecovery\(task\)/); const invoiceDetailRuntimeSource = await readFile(invoiceDetailRuntimeUrl, 'utf8'); assert.match(invoiceDetailRuntimeSource, /taskSucceededWithoutRecovery\(task\)/); assert.match(invoiceDetailRuntimeSource, /recoveryTaskFailureNotice\(task\)/); assert.doesNotMatch(invoiceDetailRuntimeSource, /task\.status === 'succeeded'/); const reinstallView = await readFile(reinstallViewUrl, 'utf8'); assert.doesNotMatch(reinstallView, /reinstall-(?:retry|forget)/); assert.doesNotMatch(reinstallView, />\s*重新查询任务\s*