You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
8.4 KiB
PHP
141 lines
8.4 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$servicePath = $root . '/app/Services/Cloud/CloudAdminOverviewService.php';
|
|
$controllerPath = $root . '/app/Controllers/AdminController.php';
|
|
$templatePath = $root . '/resources/views/venix/admin/index.tpl';
|
|
$headerPath = $root . '/resources/views/venix/admin/static_header.tpl';
|
|
$footerPath = $root . '/resources/views/venix/admin/static_footer.tpl';
|
|
$assetsPath = $root . '/resources/views/venix/layout_assets.tpl';
|
|
$sharedStylePath = $root . '/public/theme/venix/css/admin-home.css';
|
|
$removedStylePath = $root . '/public/cloud/admin-overview.css';
|
|
$schemaPath = $root . '/sql/cloud.sql';
|
|
$baseSchemaPath = $root . '/sql/ss.sql';
|
|
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$assert(is_file($servicePath) && is_file($sharedStylePath) && !is_file($removedStylePath),
|
|
'Administrator overview must use the shared legacy administrator stylesheet.');
|
|
|
|
$service = file_get_contents($servicePath);
|
|
$controller = file_get_contents($controllerPath);
|
|
$template = file_get_contents($templatePath);
|
|
$header = file_get_contents($headerPath);
|
|
$footer = file_get_contents($footerPath);
|
|
$assets = file_get_contents($assetsPath);
|
|
$styles = file_get_contents($sharedStylePath);
|
|
$schema = file_get_contents($schemaPath);
|
|
$baseSchema = file_get_contents($baseSchemaPath);
|
|
|
|
$assert(str_contains($controller, 'CloudAdminOverviewService::snapshot()')
|
|
&& str_contains($controller, 'CloudAdminOverviewService::unavailable()')
|
|
&& str_contains($controller, "'overview_error' => \$overviewError"),
|
|
'Administrator landing page must render a database snapshot with a safe fallback.');
|
|
|
|
$assert(str_contains($service, 'CloudInvoice')
|
|
&& str_contains($service, 'CloudInstance')
|
|
&& str_contains($service, 'CloudJob')
|
|
&& str_contains($service, 'CloudHost')
|
|
&& !str_contains($service, 'App\\Models\\Code')
|
|
&& !str_contains($service, 'Bought')
|
|
&& !str_contains($service, 'CloudEngineClient')
|
|
&& !str_contains($service, 'CloudEngineSession'),
|
|
'Overview metrics must use cloud business tables without legacy ledgers or engine calls.');
|
|
|
|
$assert(str_contains($service, "where('status', 'paid')")
|
|
&& str_contains($service, "whereNotNull('paid_at')")
|
|
&& str_contains($service, "where('status', '<>', 'deleted')")
|
|
&& str_contains($service, "where('kind', 'create')")
|
|
&& str_contains($service, "whereNotNull('order_id')")
|
|
&& str_contains($service, "whereIn('status', ['queued', 'running', 'uncertain'])")
|
|
&& str_contains($service, "status = 'failed' AND updated_at")
|
|
&& str_contains($service, "status = 'active' AND (service_status = 'exempt'")
|
|
&& str_contains($service, 'updated_at >= {$todayStart}')
|
|
&& str_contains($service, "modify('+1 day')"),
|
|
'Financial, instance and job overview boundaries are incomplete.');
|
|
|
|
$assert(str_contains($service, "foreach (\$window['trend'] as \$index => \$day)")
|
|
&& substr_count($service, 'CloudInvoice::where') <= 3,
|
|
'Revenue trend must use bounded aggregate queries rather than one query per day.');
|
|
|
|
$assert(str_contains($schema, 'cloud_invoice_overview_paid (status, paid_at, purpose, plan_id)')
|
|
&& str_contains($schema, 'cloud_job_overview_status_updated (status, updated_at)')
|
|
&& str_contains($schema, 'cloud_job_overview_kind_created (kind, created_at)')
|
|
&& str_contains($schema, 'ticket_overview_root_status (rootid, status)')
|
|
&& str_contains($baseSchema, '`ticket_overview_root_status` (`rootid`,`status`)'),
|
|
'Overview range queries must have bounded operational indexes.');
|
|
|
|
$assert(str_contains($template, 'card overflow-hidden admin-stat-card')
|
|
&& str_contains($template, 'admin-progress-list')
|
|
&& str_contains($template, 'admin-live-grid mb-0')
|
|
&& str_contains($template, 'admin-report-list')
|
|
&& str_contains($template, 'admin-log-links')
|
|
&& str_contains($template, 'admin-shortcuts')
|
|
&& str_contains($template, '数据库快照')
|
|
&& str_contains($template, '已启用宿主机配置')
|
|
&& str_contains($template, '不推断真实开关机状态')
|
|
&& str_contains($template, '退款后会从历史有效实收中移除')
|
|
&& substr_count($template, 'card overflow-hidden admin-stat-card') === 4
|
|
&& !preg_match('/text-bg-(?:success|info|warning|danger)/', $template)
|
|
&& str_contains($template, 'bg-danger-subtle text-danger-emphasis')
|
|
&& str_contains($template, 'bg-warning-subtle text-warning-emphasis')
|
|
&& !str_contains($template, 'admin-overview.css')
|
|
&& !str_contains($template, 'class="vo-')
|
|
&& !str_contains($template, '$sts->')
|
|
&& !str_contains($template, '在线宿主机'),
|
|
'Overview template must reuse legacy administrator components, state its data source and avoid invented live state.');
|
|
|
|
foreach (['/admin/cloud/instances', '/admin/billing', '/admin/hosts', '/admin/ticket'] as $href) {
|
|
$assert(str_contains($template, 'href="' . $href),
|
|
'Overview shortcut missing: ' . $href);
|
|
}
|
|
|
|
$assert(str_contains($header, '/theme/venix/css/admin-home.css')
|
|
&& !str_contains($header, 'admin_extra_css_href')
|
|
&& str_contains($styles, '.admin-stat-card .card-body')
|
|
&& preg_match('/\.admin-live-grid\s*\{[^}]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\)/s', $styles)
|
|
&& str_contains($styles, '.admin-progress-list')
|
|
&& str_contains($styles, '.admin-shortcuts')
|
|
&& str_contains($styles, '.admin-log-links')
|
|
&& str_contains($styles, '@media (max-width: 991.98px)')
|
|
&& str_contains($styles, '@media (max-width: 575.98px)'),
|
|
'Overview must inherit the existing administrator component and responsive rules.');
|
|
|
|
$assert(preg_match('/\.admin-template-body\s*\{(?=[^}]*--admin-viewport-height:\s*100vh)(?=[^}]*padding-bottom:\s*0\s*!important)[^}]*\}/s', $styles)
|
|
&& preg_match('/@supports\s*\(height:\s*100dvh\)\s*\{\s*\.admin-template-body\s*\{[^}]*--admin-viewport-height:\s*100dvh/s', $styles)
|
|
&& preg_match('/\.admin-template#app-layout\s*\{(?=[^}]*height:\s*auto\s*!important)(?=[^}]*overflow:\s*visible\s*!important)[^}]*\}/s', $styles)
|
|
&& preg_match('/\.admin-template \.content-page\s*\{(?=[^}]*display:\s*flex)(?=[^}]*flex-direction:\s*column)[^}]*\}/s', $styles)
|
|
&& preg_match('/\.admin-template \.content\s*\{(?=[^}]*flex:\s*1 0 auto)[^}]*\}/s', $styles)
|
|
&& preg_match('/\.admin-template \.footer\s*\{(?=[^}]*position:\s*static)[^}]*\}/s', $styles)
|
|
&& preg_match('/\.admin-template \.app-sidebar-menu\s*\{(?=[^}]*inset:\s*0 auto auto 0)(?=[^}]*height:\s*var\(--admin-viewport-height,\s*100dvh\))[^}]*\}/s', $styles)
|
|
&& preg_match('/\.admin-template-body\.admin-sidebar-open \.admin-sidebar-backdrop\s*\{(?=[^}]*inset:\s*0 0 auto)(?=[^}]*height:\s*var\(--admin-viewport-height,\s*100dvh\))[^}]*\}/s', $styles)
|
|
&& str_contains($styles, '.admin-template-body.admin-sidebar-no-transition .app-sidebar-menu')
|
|
&& str_contains($footer, 'function measureViewportHeight()')
|
|
&& str_contains($footer, 'window.visualViewport')
|
|
&& str_contains($footer, "window.visualViewport.addEventListener('resize', scheduleViewportHeight")
|
|
&& str_contains($footer, "window.visualViewport.addEventListener('scroll', scheduleViewportHeight")
|
|
&& !str_contains($footer, "window.addEventListener('pagehide', closeSidebar)")
|
|
&& str_contains($footer, "window.addEventListener('pageshow'")
|
|
&& str_contains($footer, 'event.persisted')
|
|
&& str_contains($footer, 'closeSidebarImmediately();')
|
|
&& substr_count($footer, 'window.requestAnimationFrame(function ()') >= 2
|
|
&& str_contains($footer, "document.body.classList.toggle('admin-sidebar-open');\n scheduleViewportHeight();")
|
|
&& str_contains($footer, 'target.pathname === current.pathname')
|
|
&& str_contains($footer, 'target.search === current.search')
|
|
&& str_contains($footer, 'target.hash === current.hash')
|
|
&& str_contains($footer, 'event.preventDefault();')
|
|
&& !preg_match('/link\.addEventListener\(\'click\'.*?window\.innerWidth <= 991.*?closeSidebar\(\);/s', $footer),
|
|
'Mobile administrator navigation must cover the measured viewport and keep its overlay during cross-page navigation.');
|
|
|
|
$assetVersion = [];
|
|
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $assetVersion) === 1
|
|
&& (int) $assetVersion[1] >= 2026092904
|
|
&& str_contains($assets, 'cache key'),
|
|
'This administrator asset release must use cache key 2026092904 or newer.');
|
|
|
|
echo 'Administrator operational overview contracts passed.' . PHP_EOL;
|