diff --git a/web/resources/views/venix/admin/object_storage.tpl b/web/resources/views/venix/admin/object_storage.tpl index 7862d12c..7327da98 100644 --- a/web/resources/views/venix/admin/object_storage.tpl +++ b/web/resources/views/venix/admin/object_storage.tpl @@ -6,7 +6,7 @@

Storage Infrastructure

对象存储

同时启用最多两个独立 S3 兼容后端;可额外登记停用或替代后端,以保留历史对象的精确核对身份。

-
{$object_storage_backends|@count} / 2 个后端
+
目录 {$object_storage_backends|@count} 个 · 最多 2 个启用
{if $object_storage_error != ''}
{$object_storage_error|escape}
{/if} diff --git a/web/tests/CloudObjectStorageAdminContractTest.php b/web/tests/CloudObjectStorageAdminContractTest.php index 6f50f56f..d02581a9 100644 --- a/web/tests/CloudObjectStorageAdminContractTest.php +++ b/web/tests/CloudObjectStorageAdminContractTest.php @@ -63,6 +63,8 @@ $assert(str_contains($template, "admin_title value='对象存储'") && str_contains($template, 'data-os-tab="protection"') && str_contains($template, 'data-os-tab="cleanup"') && str_contains($template, '最多两个同时参与新写入') + && str_contains($template, '目录 {$object_storage_backends|@count} 个 · 最多 2 个启用') + && !str_contains($template, '$object_storage_backends|@count >= 2') && str_contains($template, '验证成功不会自动启用写入') && str_contains($template, '连接已验证不等于对象已有双副本') && str_contains($template, 'id="osConfigDrawer"') diff --git a/web/tests/CloudObjectStorageViewTest.php b/web/tests/CloudObjectStorageViewTest.php index b11e49f9..671e83e5 100644 --- a/web/tests/CloudObjectStorageViewTest.php +++ b/web/tests/CloudObjectStorageViewTest.php @@ -63,11 +63,11 @@ $summary = [ 'protected_artifact_count' => 0, 'degraded_artifact_count' => 0, 'replication_backlog_count' => 0, ]; -$render = static function (bool $canManage) use ( +$render = static function (bool $canManage, ?array $backends = null) use ( $smarty, $backend, $cleanup, $summary ): string { $smarty->assign('admin_can_manage', $canManage); - $smarty->assign('object_storage_backends', [$backend]); + $smarty->assign('object_storage_backends', $backends ?? [$backend]); $smarty->assign('object_storage_summary', $summary); $smarty->assign('object_storage_error', ''); $smarty->assign('cleanup_debt', $cleanup); @@ -76,6 +76,11 @@ $render = static function (bool $canManage) use ( }; $html = $render(true); $readonlyHtml = $render(false); +$replacementHtml = $render(true, [ + $backend, + array_replace($backend, ['id' => 8, 'name' => 'Secondary']), + array_replace($backend, ['id' => 9, 'name' => 'Replacement']), +]); $assert = static function (bool $condition, string $message): void { if (!$condition) { @@ -139,6 +144,11 @@ $assert($one($readonly, '//fieldset')->hasAttribute('disabled') && $one($readonly, '//*[@data-os-action="drain"]')->hasAttribute('disabled') && $one($readonly, '//*[@data-os-action="disable"]')->hasAttribute('disabled'), 'Ordinary administrator controls are not read-only.'); +$replacement = $parse($replacementHtml); +$assert(!$one($replacement, '//button[@id="osAddBackend"]') + ->hasAttribute('disabled') + && str_contains($replacementHtml, '目录 3 个 · 最多 2 个启用'), + 'A replacement backend cannot be registered beside two live backends.'); $assert(str_contains($html, 'window.ADMIN_CSRF_TOKEN ='), 'Shared administrator CSRF bootstrap is missing.');