|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
// Static contract: invoice first paint must remain a single server-rendered
|
|
|
|
|
// request and the list bundle must not regress to the all-feature VM runtime.
|
|
|
|
|
$root = dirname(__DIR__);
|
|
|
|
|
$assert = static function ($condition, $message) {
|
|
|
|
|
if (!$condition) {
|
|
|
|
|
throw new RuntimeException($message);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$controller = file_get_contents($root . '/app/Controllers/CloudPageController.php');
|
|
|
|
|
$apiController = file_get_contents($root . '/app/Controllers/CloudApiController.php');
|
|
|
|
|
$service = file_get_contents($root . '/app/Services/Cloud/CloudInvoicePageService.php');
|
|
|
|
|
$shell = file_get_contents($root . '/resources/views/venix/cloud/page.tpl');
|
|
|
|
|
$template = file_get_contents($root . '/resources/views/venix/cloud/pages/invoices.tpl');
|
|
|
|
|
$topbar = file_get_contents($root . '/resources/views/venix/user/panel_topbar.tpl');
|
|
|
|
|
$module = file_get_contents($root . '/public/cloud/invoices.js');
|
|
|
|
|
|
|
|
|
|
$assert(str_contains($controller, 'CloudAccess::actor(false)')
|
|
|
|
|
&& str_contains($controller, "getAttribute('auth_user')")
|
|
|
|
|
&& str_contains($controller, 'CloudInvoicePageService::queryForUser')
|
|
|
|
|
&& str_contains($controller, 'JSON_HEX_TAG')
|
|
|
|
|
&& str_contains($controller, "'cloud_invoice_bootstrap_json'")
|
|
|
|
|
&& str_contains($controller, "withHeader('Cache-Control', 'private, no-store')"),
|
|
|
|
|
'Invoice page controller must safely embed an owner-scoped first page without a cloud session.');
|
|
|
|
|
$assert(str_contains($service, "CloudInvoice::where('user_id', \$userId)")
|
|
|
|
|
&& str_contains($service, "->where('purpose', \$purpose)")
|
|
|
|
|
&& str_contains($service, 'normalizePurpose(')
|
|
|
|
|
&& str_contains($service, 'public const USER_PAGE_SIZE = 25;')
|
|
|
|
|
&& str_contains($service, 'public static function normalizeQuery(')
|
|
|
|
|
&& str_contains($service, 'public static function queryForUser(')
|
|
|
|
|
&& str_contains($service, 'CloudInvoiceService::listSummaries')
|
|
|
|
|
&& str_contains($service, "'per_page' => \$perPage")
|
|
|
|
|
&& str_contains($service, "->orderByDesc('created_at')")
|
|
|
|
|
&& str_contains($service, "->orderByDesc('id')")
|
|
|
|
|
&& !str_contains($service, 'orderByRaw(')
|
|
|
|
|
&& str_contains($service, "Config::get(")
|
|
|
|
|
&& str_contains($service, "->modify('+1 day')")
|
|
|
|
|
&& str_contains($service, "->limit(\$perPage)"),
|
|
|
|
|
'Shared invoice pagination must remain owner scoped and bounded.');
|
|
|
|
|
$assert(str_contains($controller, 'CloudInvoicePageService::queryForUser(')
|
|
|
|
|
&& str_contains($apiController, 'CloudInvoicePageService::queryForUser(')
|
|
|
|
|
&& !str_contains($apiController, '账单页码无效'),
|
|
|
|
|
'Invoice HTML and JSON endpoints must share one safe query normalizer.');
|
|
|
|
|
$assert(str_contains($template, 'id="invoices-bootstrap"')
|
|
|
|
|
&& str_contains($template, '{foreach $cloud_invoice_rows as $invoice}')
|
|
|
|
|
&& str_contains($template, 'id="invoices-purpose-filter"')
|
|
|
|
|
&& str_contains($template, 'id="invoices-status-filter"')
|
|
|
|
|
&& str_contains($template, 'id="invoices-keyword-filter"')
|
|
|
|
|
&& str_contains($template, 'id="invoices-date-from-filter"')
|
|
|
|
|
&& str_contains($template, 'id="invoices-date-to-filter"')
|
|
|
|
|
&& str_contains($template, 'id="invoices-filter-submit"')
|
|
|
|
|
&& str_contains($template, '<select')
|
|
|
|
|
&& str_contains($template, 'value="renewal"')
|
|
|
|
|
&& !str_contains($template, 'href="/user/cloud/invoices?purpose=renewal"')
|
|
|
|
|
&& str_contains($template, 'cloud-invoice-context')
|
|
|
|
|
&& str_contains($controller, "'对应实例到期 '")
|
|
|
|
|
&& !str_contains($template, '正在加载…'),
|
|
|
|
|
'Invoice HTML must contain the first records instead of a client-only loading placeholder.');
|
|
|
|
|
$assert(!str_contains($module, '/cloud/runtime.js')
|
|
|
|
|
&& !str_contains($module, '/api/v1/session')
|
|
|
|
|
&& str_contains($module, 'function hydrate()')
|
|
|
|
|
&& str_contains($module, 'invoiceQueryString(requestedPage, requestedFilters)')
|
|
|
|
|
&& str_contains($module, "byId('invoices-purpose-filter')")
|
|
|
|
|
&& str_contains($module, 'new AbortController()')
|
|
|
|
|
&& str_contains($module, 'readSequence')
|
|
|
|
|
&& str_contains($module, "byId('invoices-filter-form')")
|
|
|
|
|
&& str_contains($module, 'function invoiceQueryString(')
|
|
|
|
|
&& str_contains($module, "addEventListener('submit'")
|
|
|
|
|
&& str_contains($module, 'function invoiceContext(')
|
|
|
|
|
&& str_contains($module, 'invoice?.renews_expires_at ?? invoice?.due_at')
|
|
|
|
|
&& str_contains($module, 'state.invoices.some(invoiceNeedsPolling)')
|
|
|
|
|
&& str_contains($module,
|
|
|
|
|
"if (['open', 'overdue'].includes(status)) return true;")
|
|
|
|
|
&& !str_contains($module, 'needs_attention')
|
|
|
|
|
&& !str_contains($module, 'setInterval('),
|
|
|
|
|
'Invoice list module must be lightweight and stop polling terminal records.');
|
|
|
|
|
$assert(str_contains($service, 'public const USER_PAGE_SIZE = 25;'),
|
|
|
|
|
'The user invoice list must retain its bounded default page size.');
|
|
|
|
|
$assert(!str_contains($shell, '/theme/venix/js/qrcode.min.js'),
|
|
|
|
|
'The shared cloud shell must not block first paint on the QR code library.');
|
|
|
|
|
$assert(str_contains($topbar, "\$user->user_name|default:'账户'")
|
|
|
|
|
&& !str_contains($topbar, '{if $panel_cloud_mode}账户{else}'),
|
|
|
|
|
'Cloud pages must render the authenticated account name without a session API request.');
|
|
|
|
|
|
|
|
|
|
echo "Invoice server-rendered first-page performance contract passed.\n";
|