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.
109 lines
5.2 KiB
PHP
109 lines
5.2 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$read = static function (string $path): string {
|
|
$source = file_get_contents($path);
|
|
if (!is_string($source)) {
|
|
throw new RuntimeException('Unable to read ' . $path);
|
|
}
|
|
return $source;
|
|
};
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$resourceService = $read(
|
|
$root . '/app/Services/Cloud/CloudAdminResourceService.php'
|
|
);
|
|
$trafficService = $read(
|
|
$root . '/app/Services/Cloud/CloudAdminTrafficPoolService.php'
|
|
);
|
|
$template = $read(
|
|
$root . '/resources/views/venix/admin/cloud/resources.tpl'
|
|
);
|
|
$script = $read($root . '/public/cloud/admin-traffic-pools.js');
|
|
$styles = $read($root . '/public/theme/venix/css/admin-home.css');
|
|
$assets = $read($root . '/resources/views/venix/layout_assets.tpl');
|
|
|
|
$assert(str_contains($resourceService,
|
|
"private const VIEWS = ['topology', 'capacity', 'reservations', 'traffic']")
|
|
&& str_contains($resourceService,
|
|
"'traffic_pools' => CloudAdminTrafficPoolService::page(\$query)")
|
|
&& str_contains($template, 'href="/admin/resources?view=traffic"')
|
|
&& str_contains($template,
|
|
'<script id="admin-resources-bootstrap" type="application/json">')
|
|
&& str_contains($template,
|
|
'/cloud/admin-traffic-pools.js?v={$venix_asset_version}'),
|
|
'Traffic-pool administration must have a database-owned SSR first paint inside resources.');
|
|
|
|
$assert(str_contains($trafficService, 'private const BLOCKER_LABELS = [')
|
|
&& str_contains($trafficService, "'label' => self::BLOCKER_LABELS[\$code]")
|
|
&& str_contains($template, '{$blocker.label|escape}')
|
|
&& str_contains($template, '{$blocker.code|escape}'),
|
|
'Readiness blockers must have human labels while preserving technical codes.');
|
|
|
|
$assert(str_contains($trafficService, "use App\\Models\\CloudRegion;")
|
|
&& str_contains($trafficService, "'region_name' =>")
|
|
&& str_contains($trafficService, "'region_count' => \$regionCount")
|
|
&& str_contains($template,
|
|
'{$line.region_name|escape} · {$line.name|escape}')
|
|
&& str_contains($template,
|
|
'{$group.region_count|default:0|escape} / {$group.line_count|default:0|escape}')
|
|
&& str_contains($template, '强制执行状态存在'),
|
|
'Line choices must disambiguate duplicate regional codes and enforced faults must be described as incidents.');
|
|
|
|
$assert(str_contains($template, '{if $admin_can_manage|default:false}<button')
|
|
&& str_contains($template, 'data-traffic-create')
|
|
&& str_contains($template, 'data-traffic-rename=')
|
|
&& str_contains($template, 'data-traffic-lines=')
|
|
&& str_contains($template, 'data-target-mode="enforced"')
|
|
&& str_contains($template, '>线路流量池</a>')
|
|
&& str_contains($template, '地区只表示覆盖范围,不拆分额度')
|
|
&& str_contains($template,
|
|
'{if $traffic_line_region_id != $line.region_id}<h3>')
|
|
&& !str_contains($template, 'data-traffic-delete'),
|
|
'Only authorized administrators may receive traffic-pool mutation controls and no delete control may exist.');
|
|
|
|
$assert(str_contains($script,
|
|
"window.VenixAdminRequestRuntime.create()")
|
|
&& str_contains($script,
|
|
'`/api/v1/admin/traffic-pool-groups${groupId ?')
|
|
&& str_contains($script,
|
|
'`/api/v1/admin/traffic-pool-groups/${groupId}/lines`')
|
|
&& str_contains($script, "method: groupId ? 'PATCH' : 'POST'")
|
|
&& str_contains($script, "method: 'PUT'")
|
|
&& str_contains($script, 'expected_revision: Number(item.revision)')
|
|
&& !str_contains($script, "method: 'DELETE'")
|
|
&& !str_contains($script, 'setInterval('),
|
|
'Mutations must use the shared runtime, exact revisions, and no replay or delete path.');
|
|
|
|
$assert(str_contains($script,
|
|
"body: { mode: targetMode, expected_revision: Number(item.revision) }")
|
|
&& str_contains($script, "targetMode === 'enforced'")
|
|
&& str_contains($script, 'requiredText: item.name')
|
|
&& str_contains($script, "requiredLabel: '输入完整线路池名称以确认'")
|
|
&& str_contains($script, 'window.VenixAdminDangerDialog.confirm(config)')
|
|
&& str_contains($script, '不能回退、停用或调整线路'),
|
|
'Enforced rollout must require the shared typed danger confirmation and an exact revision.');
|
|
|
|
$assert(str_contains($script,
|
|
'checkbox.disabled = owner > 0 && owner !== Number(item.id)')
|
|
&& str_contains($template, 'data-line-owner=')
|
|
&& str_contains($template, '只有停用且尚未形成持久账本引用的线路池可以调整覆盖线路'),
|
|
'Line assignment must visibly reject lines owned by a different group.');
|
|
|
|
$assert(str_contains($styles,
|
|
'grid-template-columns: repeat(4, minmax(0, 1fr));')
|
|
&& str_contains($styles, '.admin-traffic-group-list')
|
|
&& str_contains($styles, '.admin-traffic-metrics')
|
|
&& str_contains($styles, '[data-admin-traffic-drawer]')
|
|
&& str_contains($styles,
|
|
'.admin-traffic-line-options > h3')
|
|
&& str_contains($styles, '@media (max-width: 767.98px)')
|
|
&& preg_match("/venix_asset_version value='2026110401'/", $assets) === 1,
|
|
'Traffic-pool administration must remain responsive and use a new shared asset version.');
|
|
|
|
echo "Administrator shared traffic-pool UI contracts passed.\n";
|