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.
75 lines
3.7 KiB
PHP
75 lines
3.7 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$read = static function (string $path) use ($root): string {
|
|
$contents = file_get_contents($root . '/' . $path);
|
|
if (!is_string($contents)) {
|
|
throw new RuntimeException('Unable to read ' . $path);
|
|
}
|
|
return $contents;
|
|
};
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$template = $read('resources/views/venix/admin/hosts/index.tpl');
|
|
$script = $read('public/cloud/admin-hosts.js');
|
|
$styles = $read('public/cloud/admin.css');
|
|
$assets = $read('resources/views/venix/layout_assets.tpl');
|
|
|
|
$assert(str_contains($template, 'id="host-summary"')
|
|
&& str_contains($template, 'id="host-search"')
|
|
&& str_contains($template, 'id="host-region-filter"')
|
|
&& str_contains($template, 'id="host-state-filter"')
|
|
&& str_contains($template, 'aria-controls="host-list"')
|
|
&& str_contains($template, 'id="host-config-drawer"')
|
|
&& str_contains($template, 'data-admin-host-config-drawer')
|
|
&& str_contains($template, 'id="host-config-overview"')
|
|
&& str_contains($template, 'id="host-config-scheduling"')
|
|
&& str_contains($template, 'id="host-config-network-pools"')
|
|
&& str_contains($template, 'id="host-config-vpc"')
|
|
&& str_contains($template, 'form="host-form"')
|
|
&& substr_count($template, 'id="host-new"') === 1
|
|
&& str_contains($template, '>计算节点</h4>')
|
|
&& str_contains($template, '>Agent API</a>'),
|
|
'Compute-node page is missing its summary, filters or primary actions.');
|
|
|
|
$assert(str_contains($script, 'state.hostRegions = collection(payload, \'regions\')')
|
|
&& str_contains($script, 'state.hostSummary = payload?.summary')
|
|
&& str_contains($script, 'function hostRegionKey(')
|
|
&& str_contains($script, "element('details', 'cloud-admin-host-region')")
|
|
&& str_contains($script, 'function hostMatchesFilter(')
|
|
&& str_contains($script, "host?.readiness?.placement_ready")
|
|
&& str_contains($script, "host?.needs_attention")
|
|
&& str_contains($script, "host.enabled ? '服务启用' : '服务停用'")
|
|
&& str_contains($script, 'agentLabel(host?.agent?.state)')
|
|
&& str_contains($script, 'schedulerLabel(host.scheduler_state)')
|
|
&& str_contains($script, 'function openHostConfig(')
|
|
&& str_contains($script, 'function renderHostConfigOverview(')
|
|
&& str_contains($script, 'function openHostConfigTool(')
|
|
&& !str_contains($script, "openHostScheduling(host.id, scheduling)")
|
|
&& !str_contains($script, "openHostNetworkPools(host.id, networkPools)")
|
|
&& str_contains($script, "closeHostDrawer('host-config-drawer', 'config')")
|
|
&& str_contains($script, 'openNewHostConfig(event.currentTarget)')
|
|
&& str_contains($script, 'window.VenixDrawerMotion.openDrawerWithMotion'),
|
|
'Region rendering must keep Agent, service and scheduling state separate.');
|
|
|
|
$assert(str_contains($styles, '.cloud-admin-host-summary')
|
|
&& str_contains($styles, '.cloud-admin-host-region')
|
|
&& str_contains($styles, '.cloud-admin-host-node')
|
|
&& str_contains($styles, '.cloud-admin-host-tool-grid')
|
|
&& str_contains($styles, '.cloud-admin-host-config-metrics')
|
|
&& str_contains($styles, '.cloud-admin-host-summary-card:last-child:nth-child(odd)')
|
|
&& str_contains($styles, 'grid-template-columns: repeat(2, minmax(0, 1fr))')
|
|
&& str_contains($styles, '.cloud-admin-host-badge.is-success')
|
|
&& str_contains($styles, '@media (max-width: 767.98px)'),
|
|
'Compute-node region layout is missing desktop or responsive styles.');
|
|
|
|
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets,
|
|
$match) === 1 && (int) $match[1] >= 2026103104,
|
|
'Compute-node region UI changes require a new shared asset version.');
|
|
|
|
echo "Administrator compute-node region UI contracts passed.\n";
|