Dashboard: hide archived sessions from the All-sites list (hc-7vo)
Follow-up to the archive feature: archived healthchecks showed in both the main All-sites list and the Archived section. allSitesSummary() now excludes archived sessions from the aggregate (and from the per-site "latest session" detail), so a site whose sessions are all archived drops off the main list and appears only under "Archived". A site with a mix keeps its row, counting only its live sessions. The per-site page still lists every session. Also bumps the server version baseline in config.php.example to 0.1.8. 2 new tests (51 total). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+33
-3
@@ -125,6 +125,12 @@ function archived_section(string $html): string {
|
||||
return $pos === false ? '' : substr($html, $pos);
|
||||
}
|
||||
|
||||
/** The home page up to (not including) the Archived section — i.e. the All-sites list. */
|
||||
function main_site_list(string $html): string {
|
||||
$pos = strpos($html, '<h2 class="archived-heading"');
|
||||
return $pos === false ? $html : substr($html, 0, $pos);
|
||||
}
|
||||
|
||||
/** The <tr> from a dashboard table that mentions $needle — for precise assertions. */
|
||||
function row_containing(string $html, string $needle): string {
|
||||
if (preg_match_all('#<tr>.*?</tr>#s', $html, $m)) {
|
||||
@@ -475,9 +481,10 @@ test('the per-site page marks an archived session and offers Unarchive', functio
|
||||
assert_contains('status-archived', $page, 'the row should carry the archived badge');
|
||||
});
|
||||
|
||||
test('an unarchived session still shows the normal listing (not hidden)', function () {
|
||||
// "No need to hide them" — an archived session stays in its site's session list.
|
||||
$site = unique_site('archive-not-hidden');
|
||||
test('an archived session still shows on its own per-site page', function () {
|
||||
// Hiding is only from the home page's All-sites list — a site's own page
|
||||
// still lists every session (archived ones just carry the badge).
|
||||
$site = unique_site('archive-persite-visible');
|
||||
$hc = create_hc($site, ['next_due' => '2027-01-01']);
|
||||
$token = dash_csrf('/dashboard?site=' . rawurlencode($site));
|
||||
archive_hc($hc['id'], true, $token);
|
||||
@@ -486,6 +493,29 @@ test('an unarchived session still shows the normal listing (not hidden)', functi
|
||||
assert_contains('2027-01-01', $page, 'the archived session is still in the per-site table');
|
||||
});
|
||||
|
||||
test('a site with only archived sessions drops off the All sites list', function () {
|
||||
$site = unique_site('archive-hidden-main');
|
||||
$hc = create_hc($site);
|
||||
$token = dash_csrf('/dashboard?site=' . rawurlencode($site));
|
||||
archive_hc($hc['id'], true, $token);
|
||||
|
||||
$home = dash('/dashboard')['body'];
|
||||
assert_not_contains($site, main_site_list($home), 'gone from the All sites list');
|
||||
assert_contains($site, archived_section($home), 'but still under Archived');
|
||||
});
|
||||
|
||||
test('a site keeps its All sites row while it still has a live session', function () {
|
||||
$site = unique_site('archive-mixed');
|
||||
create_hc($site); // stays active
|
||||
$stale = create_hc($site); // gets archived
|
||||
$token = dash_csrf('/dashboard?site=' . rawurlencode($site));
|
||||
archive_hc($stale['id'], true, $token);
|
||||
|
||||
$home = dash('/dashboard')['body'];
|
||||
assert_contains($site, main_site_list($home), 'still has a live session, so still listed');
|
||||
assert_contains($site, archived_section($home), 'and its archived session shows under Archived');
|
||||
});
|
||||
|
||||
test('archiving an unknown healthcheck reports not found', function () {
|
||||
$site = unique_site('archive-unknown');
|
||||
create_hc($site); // gives us a page to read a CSRF token from
|
||||
|
||||
Reference in New Issue
Block a user