invokeArgs($target, $arguments); }; $payload = [ 'invoice' => [ 'id' => '17', 'purpose' => 'renewal', 'title' => '实例续费', 'created_at' => 2_000_000_000, 'amount' => '12.51', 'status' => 'open', 'renews_expires_at' => 2_000_100_000, 'payment_deadline_at' => 2_000_359_200, 'payable' => true, 'validity_days' => 30, 'traffic_quota_bytes' => 0, 'items' => [ [ 'id' => '31', 'code' => 'instance', 'label' => '实例套餐续费', 'amount' => '10.00', 'currency' => 'USD', ], [ 'id' => '32', 'code' => 'automatic_backup', 'label' => '自动备份', 'amount' => '2.50', 'currency' => 'USD', ], ], ], 'balance_payment_allowed' => false, 'payment_methods' => [], ]; $controller = new CloudPageController(); $view = $invoke($controller, 'invoiceDetailView', [$payload]); $assert(($view['show_line_items'] ?? false) === true, 'Invoice first paint does not expose its frozen line items.'); $assert(($view['line_items'] ?? null) === [ ['label' => '实例套餐续费', 'amount_display' => '$10.00'], [ 'label' => '自动备份', 'amount_display' => '$2.50', ], ], 'Invoice line-item projection changed labels or frozen amounts.'); $assert(($view['amount_display'] ?? null) === '$12.51', 'Invoice presentation recomputed the authoritative total from line items.'); $resumePayload = $payload; $resumePayload['invoice']['payable'] = false; $resumePayload['active_payment'] = [ 'status' => 'review', 'task_id' => '91', 'payment' => null, 'can_submit' => false, ]; $resumeView = $invoke($controller, 'invoiceDetailView', [$resumePayload]); $assert(($resumeView['show_payment'] ?? false) === true && ($resumeView['payment_title'] ?? null) === '当前支付状态' && str_contains( (string) ($resumeView['active_payment_message'] ?? ''), '请勿再次提交' ) && ($resumeView['payment_methods'] ?? null) === [], 'Invoice first paint exposed retry instead of an active-payment fence.'); $gracePayload = $payload; $gracePayload['invoice']['status'] = 'overdue'; $gracePayload['invoice']['display_status'] = 'renewal_grace'; $gracePayload['invoice']['payable'] = true; $graceView = $invoke($controller, 'invoiceDetailView', [$gracePayload]); $assert(($graceView['status_label'] ?? null) === '已到期,宽限期内可续费' && ($graceView['status_class'] ?? null) === 'warning', 'Payable renewal grace was presented as a failed overdue invoice.'); $detailRuntime = file_get_contents( dirname(__DIR__) . '/public/cloud/invoice-detail-runtime.js' ); $listRuntime = file_get_contents(dirname(__DIR__) . '/public/cloud/invoices.js'); $assert(is_string($detailRuntime) && is_string($listRuntime) && str_contains($detailRuntime, "renewal_grace: ['已到期,宽限期内可续费', 'warning']") && str_contains($detailRuntime, 'invoice.display_status ?? invoice.status') && str_contains($listRuntime, "renewal_grace: ['已到期,宽限期内可续费', 'warning']") && str_contains($listRuntime, 'invoice.display_status ?? invoiceStatus'), 'Invoice client rendering does not consume the canonical grace status.'); echo "Cloud invoice SSR presentation checks passed.\n";