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.
virt/web/tests/UserFormControlVisualContra...

58 lines
3.0 KiB
PHTML

<?php
$root = dirname(__DIR__);
$assert = static function ($condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$read = static fn (string $path): string => file_get_contents($root . '/' . $path);
$clientStyles = $read('public/cloud/client.css');
$accountStyles = $read('public/cloud/account.css');
$cloudStyles = $read('public/cloud/styles.css');
$cloudLayout = $read('resources/views/venix/cloud/page.tpl');
$userLayout = $read('resources/views/venix/user/layout_header.tpl');
$authLayout = $read('resources/views/venix/auth/layout_header.tpl');
$adminLayout = $read('resources/views/venix/admin/static_header.tpl');
$assets = $read('resources/views/venix/layout_assets.tpl');
$assert(str_contains($cloudLayout, '/cloud/client.css')
&& str_contains($userLayout, '/cloud/client.css')
&& str_contains($userLayout, '/cloud/account.css')
&& str_contains($authLayout, '/cloud/account.css'),
'Every customer-facing shell must load the borderless form-control styles.');
$assert(!str_contains($adminLayout, '/cloud/client.css')
&& !str_contains($adminLayout, '/cloud/account.css'),
'Customer form-control styling must not leak into administrator pages.');
$assert(!preg_match('/body\[data-cloud-page\][^{]*\{[^}]*border-color:\s*transparent/s',
$clientStyles),
'Cloud customer controls must not lose their own visible borders.');
$assert(str_contains($cloudStyles,
'.vm-settings-field input[type=text],.vm-settings-field select{width:100%;min-width:0;height:44px}')
&& !preg_match('/\.vm-settings-field input\[type=text\],\.vm-settings-field select\{[^}]*border:\s*0/',
$cloudStyles),
'Instance-setting text and select controls must retain their visible native control frame.');
$assert(preg_match('/\.vm-snapshot-create-form\{(?=[^}]*padding:0)(?=[^}]*border:0)(?=[^}]*background:transparent)[^}]*\}/',
$cloudStyles) === 1
&& !str_contains($cloudStyles, '.vm-snapshot-create-form{padding:14px}'),
'The unnecessary outer snapshot-form card must be removed on desktop and mobile.');
$assert(str_contains($accountStyles, 'border: 1px solid var(--vu-border-strong);')
&& str_contains($accountStyles, 'box-shadow: inset 0 1px 1px rgba(21, 42, 63, .015);')
&& str_contains($accountStyles,
'body.venix-auth.virsh-auth .auth-field :where(input, select, textarea)')
&& str_contains($accountStyles, 'border-color: #dce4eb;'),
'Account and authentication controls must retain their required visible borders.');
$assert(str_contains($clientStyles,
'.panel-user-dialog-verification.is-matched input { border-color: #76b99a; }')
&& str_contains($accountStyles, 'box-shadow: 0 0 0 4px rgba(25, 179, 187, .11);'),
'Visible control borders must retain semantic validation and accessible focus feedback.');
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $version) === 1
&& (int) $version[1] >= 2026102702,
'Shared asset version must advance when customer form styles change.');
echo "User form-control visual contract passed.\n";