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/AuthVisualContractTest.php

45 lines
2.1 KiB
PHP

<?php
$root = dirname(__DIR__);
$views = $root . '/resources/views/venix';
$assert = static function ($condition, $message) {
if (!$condition) throw new RuntimeException($message);
};
$login = file_get_contents($views . '/auth/login.tpl');
$register = file_get_contents($views . '/auth/register.tpl');
$layout = file_get_contents($views . '/auth/layout_header.tpl');
$story = file_get_contents($views . '/auth/virsh_story.tpl');
$styles = file_get_contents($root . '/public/cloud/account.css');
$assets = file_get_contents($views . '/layout_assets.tpl');
foreach ([$login, $register] as $template) {
$assert(str_contains($template, 'auth-shell auth-shell-virsh'),
'Authentication page is missing the virsh-cloud shell.');
$assert(str_contains($template, "include file='auth/virsh_story.tpl'"),
'Authentication page is missing the shared virsh-cloud artwork.');
$assert(str_contains($template, 'class="auth-security-hint"'),
'Authentication page is missing the secure-access hint.');
}
$assert(str_contains($layout, 'venix-auth{if isset($auth_page)} virsh-auth{/if}'),
'Authentication layout does not scope the migrated visual treatment.');
$assert(str_contains($story, '{$auth_app_name|escape:"html"}')
&& !str_contains($story, 'VirtPilot'),
'Virsh-cloud artwork must use the configured site name.');
$assert(str_contains($styles, 'grid-template-columns: minmax(390px, 48%) minmax(0, 1fr);')
&& str_contains($styles, '.auth-story-virsh')
&& str_contains($styles, '.virsh-auth-art-grid')
&& str_contains($styles, '@media (max-width: 740px)')
&& str_contains($styles, '.auth-story-virsh { display: none; }'),
'Responsive virsh-cloud authentication styles are incomplete.');
$assert(str_contains($login, "VenixAuth.post('/auth/login'")
&& str_contains($register, "VenixAuth.post('/auth/register'"),
'Authentication endpoints changed while migrating visual styles.');
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $version) === 1
&& (int) $version[1] >= 2026102413,
'Shared asset version was not advanced for the authentication stylesheet.');
echo "Auth visual contract passed.\n";