mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-11-01 03:03:23 +01:00
RollingUpdate leaves its state file (rolling_update.json) on disk after a run finishes (finish() only removes the cancel file), so on every Servers page load pollRolling() -> showRolling() found a status and re-showed the progress card for a run that ended long ago — it never disappeared. Gate the card on a live run (or one being watched to its result this page view) with a rollingActive flag, instead of on a status merely existing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0152oDfaEcCQos4EcYJ2KJSk
27 lines
1.4 KiB
PHP
27 lines
1.4 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* The rolling-update progress card on the Servers page must not reappear for a
|
|
* run that finished before the page was opened: RollingUpdate leaves its state
|
|
* file on disk after a run, so `showRolling` has to gate the card on a live (or
|
|
* being-watched) run, not merely on a status existing. Guards the "rolling
|
|
* update message never disappears" bug.
|
|
*/
|
|
final class RollingUpdateCardGateTest extends TestCase {
|
|
|
|
public function testTheCardShowIsGatedByALiveRunNotJustAStatus(): void {
|
|
$rView = (string) file_get_contents(MAIN_HOME . 'Public/Views/admin/servers.php');
|
|
|
|
$this->assertSame(1, preg_match('/function showRolling\(d\)\s*\{(.*?)\$\(\x27#rolling-update-card\x27\)\.removeClass\(\x27d-none\x27\)/s', $rView, $rPre), 'found showRolling up to the card show');
|
|
$rBeforeShow = $rPre[1];
|
|
|
|
// Between entering showRolling and showing the card there must be a guard
|
|
// that keeps a non-live, not-being-watched (finished) run from showing.
|
|
$this->assertMatchesRegularExpression('/\blive\b/', $rBeforeShow, 'a liveness check gates the card');
|
|
$this->assertStringContainsString('rollingActive', $rBeforeShow, 'a per-view "seen a live run" flag gates the card');
|
|
$this->assertSame(2, preg_match_all('/\breturn;/', $rBeforeShow), 'two early returns: no state, and not-live-and-not-active — the card is not shown unconditionally');
|
|
}
|
|
}
|