Drop the restore points per day chart from Backups (#3771)

Drop the restore points per day chart from Backups

By date drew "Completed restore points per day" right below the Backup
jobs card, and the two read as the same chart. They are not: the restore
point chart counts only points that still exist, bucketed by creation
day, so pruned days fall to zero and retained weekly points spike. On a
real PBS its shape mostly showed the retention policy, not what ran.

Backup jobs already answers whether each day's backups ran, and the list
is grouped under day headings, so the chart, its Count/Volume toggle,
range picker and click-a-day filter go. BackupActivityChart and its
presentation module are deleted with their tests. An old bookmark's day
parameter is ignored, the undated-entry notice drops its chart clause,
and the empty states no longer mention a selected day.

The Recovery guide now explains why Backup jobs and the list can
disagree for a day, and the integration layout spec and the chronology
browser fixture no longer drive the chart.
This commit is contained in:
rcourtman
2026-11-02 15:31:44 +00:00
committed by GitHub
22 changed files with 207 additions and 2210 deletions
+26 -35
View File
@@ -58,37 +58,28 @@ answer different questions:
The **completed restore points** total in **Backup health** excludes both,
even when an incomplete entry has a size or a verification flag. The total
covers the loaded inventory, not just the rows matching your list filters.
- **Completed restore points per day** also requires a known, non-future date
within the selected chart range. An undated completed point can count in
Backup health but not in a daily column. A blank chart is not proof that
no backups exist; check any inventory loading or access warning first.
- **Known restore volume per day** adds only positive reported sizes for
those dated completed points. A point with no reported size can count as a
point without contributing volume. It remains selectable in **Volume** and
counts normally in **Count**. Amber marks days with unknown sizes, not zero
volume. When a day mixes known and unknown sizes, its known volume is a lower
bound, not a complete total. These are recorded artifact sizes, not
PBS datastore usage or deduplicated physical space. For a row marked
**Unknown size**, use the [individual size checks](#restore-point-sizes-and-unknown-values).
- Guest **snapshots** can contribute to completed-point and chart totals.
They are not independent backups and do not fill Coverage's **Last backup**.
If a completed backup's date is unavailable or in the future, the latest
backup age stays unknown rather than choosing an older dated backup.
For a row marked **Unknown size**, use the
[individual size checks](#restore-point-sizes-and-unknown-values).
- **Backup jobs** counts the Proxmox backup tasks Pulse has retained for
current workloads, including failed runs, and ignores the list filters. A
run's outcome is separate evidence from the restore points: a failed run
usually leaves none, and retention prunes older points from the list, so the
two need not agree for any day.
- Guest **snapshots** can contribute to completed-point totals. They are not
independent backups and do not fill Coverage's **Last backup**. If a
completed backup's date is unavailable or in the future, the latest backup
age stays unknown rather than choosing an older dated backup.
Both activity charts follow the **By date** list's search, **Node**, **Backup
location**, **Type** and **Source** filters, including Verified or Unverified.
The list follows the **By date** search, **Node**, **Backup location**,
**Type** and **Source** filters, including Verified or Unverified.
**Backup health** still covers the loaded inventory: a non-zero total there
can sit beside an empty filtered chart. An unresolved or ambiguous saved backup
can sit beside an empty filtered list. An unresolved or ambiguous saved backup
location shows no matching points; choose the intended location again or clear
that filter, rather than treating the empty view as missing backups.
Selecting a chart day filters the list only; the other scoped days remain
available in the chart. The chart's date range limits its activity columns, not
the list. **Clear date filter** removes only the selected day; clear search and
the other filter chips separately to inspect the wider inventory, including
undated and incomplete entries. None of these display controls changes
collection, permissions, retention or protection policy. Older versions may use
different labels or show unfiltered activity charts.
that filter, rather than treating the empty view as missing backups. An empty
list is not proof that no backups exist; check any inventory loading or access
warning first. None of these display controls changes collection, permissions,
retention or protection policy. Older versions may use different labels or
show a per-day restore point chart.
**Completed is not Verified, a tested restore or guest thaw.** Compare the same
provider, guest, location and time using existing records, not just a count.
@@ -96,7 +87,7 @@ Do not run a new backup, verification or restore, delete entries, or clear
History to make totals agree. For contradictory PBS verification or protection,
use the [PBS evidence checks](PBS.md#backups-are-visible-but-coverage-says-unprotected).
An unresponsive guest or uncertain freeze/thaw needs the
[backup safety precaution](VM_DISK_MONITORING.md#backup-safety), not a chart check.
[backup safety precaution](VM_DISK_MONITORING.md#backup-safety), not a count check.
## Restore-point sizes and unknown values
@@ -113,7 +104,7 @@ the measured order. On a phone, expand the restore-point row and read **Size**
under **Restore point**. A hidden column is not a missing reading. In
**Coverage**, expand the workload to see each point's size; narrow layouts
show it alongside the point's identity. One known size does not fill the gaps
for other points. For daily totals, see [why counts and volume differ](#why-proxmox-backup-counts-differ).
for other points. For totals, see [why backup counts differ](#why-proxmox-backup-counts-differ).
Compare the same workload, repository and time in existing provider records
before drawing a conclusion. Do not run another backup, verification or
@@ -368,11 +359,11 @@ A recent archive in PVE and an old or **Unprotected** Coverage row are
different observations, not proof that the archive failed or the workload is
protected. Compare one existing archive with the same workload in Pulse:
1. Open **Proxmox → Backups → By date**. Clear search and the selected chart
day, start with **All nodes** and **All backup locations**, then select
**PVE backup files** (**PVE files** on narrow screens). A chart range or
list filter is not the protection policy; widening it does not refresh
collection or change a backup's age.
1. Open **Proxmox → Backups → By date**. Clear search, start with
**All nodes** and **All backup locations**, then select
**PVE backup files** (**PVE files** on narrow screens). A list filter is
not the protection policy; widening it does not refresh collection or
change a backup's age.
2. Expand the archive to read **Source**, **Location**, **Created**, **State**
and **Identifier** under **Details**, including on a phone. Compare these
with the existing record in the owning PVE installation: connection,
@@ -537,6 +537,13 @@ desktop/narrow browser journeys cover the shared filter rail, keyboard/touch
day selection, metric switching, empty matches and recovery. No shared-filter,
route, navigation, access or backup operation changes.
### Backups By date carries no activity chart (2 November 2026)
The restore points no longer render `BackupActivityChart`; the component and
its presentation module are deleted. Backup jobs is the page's one daily bar
chart, so two look-alike bar charts never stack on one page. Earlier notes here
about the chart's tooltip portal and day-control focus are historical.
### Backup view tabs head the restore points, not the page (2 November 2026)
On the Backups page the shared `PlatformSectionTabs` ("Backup views": By date,
@@ -6472,8 +6479,7 @@ Enter/Space work through the native button, and lifecycle actions do not bubble
into collapse. Generic `Ask Assistant` and `Copy context` actions do not belong
in object drawer headers: raw context export must not compete with the
operational reading path.
`frontend-modern/src/components/Workloads/MetricMiniSparkline.tsx` and
`frontend-modern/src/features/proxmox/BackupActivityChart.tsx` render their
`frontend-modern/src/components/Workloads/MetricMiniSparkline.tsx` renders its
hover tooltips through `frontend-modern/src/components/shared/TooltipPortal.tsx`
rather than as HTML `foreignObject` shells inside the chart SVG; the mini
sparkline's SVG uses `preserveAspectRatio="none"`, where cross-browser scaling
@@ -8518,8 +8518,6 @@
"internal/recovery/"
],
"owned_files": [
"frontend-modern/src/features/proxmox/BackupActivityChart.tsx",
"frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts",
"frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
"frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx",
@@ -8629,8 +8627,6 @@
"label": "proxmox backup product surface proof",
"match_prefixes": [],
"match_files": [
"frontend-modern/src/features/proxmox/BackupActivityChart.tsx",
"frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts",
"frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
"frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx",
@@ -8644,7 +8640,6 @@
"allow_same_subsystem_tests": false,
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.branchcov.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts",
@@ -2274,23 +2274,21 @@ Compact Coverage age cells use the existing metadata-size text and reclaim numer
13. `frontend-modern/src/utils/storageSummaryCache.ts`
14. `frontend-modern/src/components/Storage/useStorageSummaryCharts.ts`
15. `frontend-modern/src/features/storageBackups/storageCapacityDeltaPresentation.ts`
16. `frontend-modern/src/features/proxmox/BackupActivityChart.tsx`
17. `frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts`
18. `frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts`
19. `frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx`
20. `frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx`
21. `frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx`
22. `frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx`
23. `frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx`
24. `frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx`
25. `frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts`
26. `internal/recovery/model/posture.go`
27. `internal/recovery/posture.go`
28. `internal/recovery/store/store_posture.go`
29. `frontend-modern/src/hooks/useProtectionPostures.ts`
30. `frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx`
31. `internal/mock/recovery_points.go`
33. `frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts`
16. `frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts`
17. `frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx`
18. `frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx`
19. `frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx`
20. `frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx`
21. `frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx`
22. `frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx`
23. `frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts`
24. `internal/recovery/model/posture.go`
25. `internal/recovery/posture.go`
26. `internal/recovery/store/store_posture.go`
27. `frontend-modern/src/hooks/useProtectionPostures.ts`
28. `frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx`
29. `internal/mock/recovery_points.go`
30. `frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts`
## Shared Boundaries
@@ -5068,13 +5066,29 @@ observed daily growth. The page owns the live alert store and passes a lookup
through `ProxmoxBackupsTable`'s `datastoreAlerts`, so the table renders without
an alerts provider and shows no forecast when none is given.
### Restore points drop the per-day chart (2 November 2026)
By date no longer draws "Completed restore points per day" (or its Volume
mode, range picker and day filter). Beside the Backup jobs card it read as the
same chart, yet it counted only points that still exist, bucketed by creation
day: pruned days fell to zero and retained weekly points spiked, so its shape
mostly showed the retention policy rather than what ran. Backup jobs reports
each day's retained backup task outcomes for current workloads; the list's day
headings already group restore points by date. `BackupActivityChart.tsx`, `proxmoxBackupActivityPresentation.ts`
and their tests are deleted, the undated-entry notice keeps only "remain
listed. Their ages are unknown." without its chart clause, and an old bookmark's
`day` parameter is ignored and cleared by Clear filters. Earlier notes in this
contract that describe the chart's sizing, tooltips, day focus or volume rules
are historical. `docs/RECOVERY.md` explains why Backup jobs and the list can
disagree for a day, and `completedBackupCountsDocs.test.ts` pins that copy and
that the table renders no activity chart.
### Backups page orders its answers: health, servers, restore points (2 November 2026)
The Backups page now reads in the order people ask: Backup health beside
Backup jobs (are my backups protected, did last night run), then the Backup
servers table (is my PBS reachable, is its datastore filling), then the
restore points: the By date / Coverage tabs, the activity chart, filters and
list. The view tabs head the restore points only; health and jobs belong to the
restore points: the By date / Coverage tabs, filters and list. The view tabs head the restore points only; health and jobs belong to the
page and render the same in either view.
The Backup servers table stays mounted through inventory loading, failure and
@@ -222,6 +222,14 @@ narrow browser proof exercises the same producer through the inventory consumer
with native interactions and inspected pixels. No API, provider, guest, polling,
auth, resource identity or protection-policy change, nor installed recovery claim.
### Backup empty states name only filters that exist (2 November 2026)
With the per-day restore point chart removed from Backups By date, no control
selects a day. The restore point and Coverage empty states now say "Adjust the
search or filters to see more artifacts / workloads." instead of naming a
selected day; Coverage had carried the stale day wording since its own day
filter was dropped. Which rows match is unchanged.
### Backup-server rows read host figures through the drawer resource (2 November 2026)
Backup servers rows no longer copy the PBS host's CPU, memory or uptime out of
@@ -52,7 +52,6 @@ const posture = {
};
const runtime = [
'src/features/proxmox/proxmoxBackupRecoveryModel.ts',
'src/features/proxmox/proxmoxBackupActivityPresentation.ts',
'src/features/proxmox/proxmoxBackupsTableShared.tsx',
'src/features/proxmox/ProxmoxCoverageTable.tsx',
'src/features/proxmox/ProxmoxBackupsTable.tsx',
@@ -354,8 +353,6 @@ const runtime = [
.filter({ hasText: 'Backup entries with unavailable or future dates remain listed' })
.waitFor();
assert.equal(await rows('recoverable').getByText('Unknown', { exact: true }).count(), 5);
const today = page.getByRole('button', { name: /: 1 backup$/ });
await today.waitFor();
await page.getByText('Running', { exact: true }).waitFor();
await page.getByText('Failed', { exact: true }).waitFor();
assert.equal(await page.getByText('not-a-date', { exact: true }).count(), 0);
@@ -397,30 +394,9 @@ const runtime = [
await capture('date-evidence');
checks.push({
check:
'PBS/PVE/guest snapshots keep unknown ages, running/failed/verified states and all artifacts; today counts one dated observation only',
'PBS/PVE/guest snapshots keep unknown ages, running/failed/verified states and all artifacts',
});
const beforeDay = requests.length;
if (phone) await today.tap();
else {
await today.focus();
await page.keyboard.press('Enter');
}
await page.waitForFunction(
() =>
document.querySelectorAll('[data-proxmox-backup-row="recoverable"]').length === 1 &&
new URLSearchParams(location.search).get('day') === '2026-10-04',
);
assert.equal(await rows('recoverable').getByText('Unknown', { exact: true }).count(), 0);
assert.equal(requests.length, beforeDay);
await page.getByRole('button', { name: 'Clear date filter', exact: true }).click();
await page.waitForFunction(
() => document.querySelectorAll('[data-proxmox-backup-row="recoverable"]').length === 6,
);
checks.push({
check:
'Keyboard/touch day selection omits unknown/future dates; clearing restores all six without another read',
});
assert.deepEqual(errors, []);
assert.deepEqual(offOrigin, []);
assert(requests.every((request) => request.method === 'GET'));
@@ -0,0 +1,45 @@
{
"version": 1,
"base_sha": "7bc1dd11583c4b393506d507f4e51af60c3204cf",
"verified_at": "2026-11-02T14:52:00Z",
"result": "passed",
"changed_paths": [
"frontend-modern/src/features/proxmox/BackupActivityChart.tsx",
"frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",
"frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx",
"frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx",
"frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts"
],
"content_sha256": {
"frontend-modern/src/features/proxmox/BackupActivityChart.tsx": "deleted",
"frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx": "416037f92500470a6061820d3b0a63967dd910e0576fd5e47a598e4885b28295",
"frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx": "dd01cbe4cae6d7425e4649ffd4ea36f4e814a23eb2e2978ed20c402b3448fb65",
"frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx": "dc1dfafeacb2c52cf588b61a5f740f40888d1d5a8682fb837eba95037c3486f5",
"frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts": "deleted"
},
"routes": [
"/proxmox/backups/date"
],
"viewports": [
{
"width": 1440,
"height": 1000
},
{
"width": 375,
"height": 812
}
],
"states": [
"private mock-mode backend built from this branch on pulse-dev",
"By date with a stale day bookmark at desktop and phone",
"dark theme, desktop and phone layouts"
],
"interactions": [
"built this branch and ran it in mock mode on pulse-dev, signed in and opened Proxmox > Backups > By date at 1440x1000 and 375x812, with an old ?day= bookmark",
"desktop: Backup health beside Backup jobs, the Backup servers table, then the By date / Coverage tabs followed directly by the search and the restore point list; no per-day restore point chart, no Count/Volume toggle, no date chip",
"the stale day parameter did not narrow the list: 139 rows on desktop and 35 on phone stayed visible",
"phone: same order, restore points start at the fold, no horizontal page overflow at either width",
"the same build also ran against a copy of the maintainer's real Proxmox and PBS config for the maintainer to inspect"
]
}
+26 -35
View File
@@ -58,37 +58,28 @@ answer different questions:
The **completed restore points** total in **Backup health** excludes both,
even when an incomplete entry has a size or a verification flag. The total
covers the loaded inventory, not just the rows matching your list filters.
- **Completed restore points per day** also requires a known, non-future date
within the selected chart range. An undated completed point can count in
Backup health but not in a daily column. A blank chart is not proof that
no backups exist; check any inventory loading or access warning first.
- **Known restore volume per day** adds only positive reported sizes for
those dated completed points. A point with no reported size can count as a
point without contributing volume. It remains selectable in **Volume** and
counts normally in **Count**. Amber marks days with unknown sizes, not zero
volume. When a day mixes known and unknown sizes, its known volume is a lower
bound, not a complete total. These are recorded artifact sizes, not
PBS datastore usage or deduplicated physical space. For a row marked
**Unknown size**, use the [individual size checks](#restore-point-sizes-and-unknown-values).
- Guest **snapshots** can contribute to completed-point and chart totals.
They are not independent backups and do not fill Coverage's **Last backup**.
If a completed backup's date is unavailable or in the future, the latest
backup age stays unknown rather than choosing an older dated backup.
For a row marked **Unknown size**, use the
[individual size checks](#restore-point-sizes-and-unknown-values).
- **Backup jobs** counts the Proxmox backup tasks Pulse has retained for
current workloads, including failed runs, and ignores the list filters. A
run's outcome is separate evidence from the restore points: a failed run
usually leaves none, and retention prunes older points from the list, so the
two need not agree for any day.
- Guest **snapshots** can contribute to completed-point totals. They are not
independent backups and do not fill Coverage's **Last backup**. If a
completed backup's date is unavailable or in the future, the latest backup
age stays unknown rather than choosing an older dated backup.
Both activity charts follow the **By date** list's search, **Node**, **Backup
location**, **Type** and **Source** filters, including Verified or Unverified.
The list follows the **By date** search, **Node**, **Backup location**,
**Type** and **Source** filters, including Verified or Unverified.
**Backup health** still covers the loaded inventory: a non-zero total there
can sit beside an empty filtered chart. An unresolved or ambiguous saved backup
can sit beside an empty filtered list. An unresolved or ambiguous saved backup
location shows no matching points; choose the intended location again or clear
that filter, rather than treating the empty view as missing backups.
Selecting a chart day filters the list only; the other scoped days remain
available in the chart. The chart's date range limits its activity columns, not
the list. **Clear date filter** removes only the selected day; clear search and
the other filter chips separately to inspect the wider inventory, including
undated and incomplete entries. None of these display controls changes
collection, permissions, retention or protection policy. Older versions may use
different labels or show unfiltered activity charts.
that filter, rather than treating the empty view as missing backups. An empty
list is not proof that no backups exist; check any inventory loading or access
warning first. None of these display controls changes collection, permissions,
retention or protection policy. Older versions may use different labels or
show a per-day restore point chart.
**Completed is not Verified, a tested restore or guest thaw.** Compare the same
provider, guest, location and time using existing records, not just a count.
@@ -96,7 +87,7 @@ Do not run a new backup, verification or restore, delete entries, or clear
History to make totals agree. For contradictory PBS verification or protection,
use the [PBS evidence checks](PBS.md#backups-are-visible-but-coverage-says-unprotected).
An unresponsive guest or uncertain freeze/thaw needs the
[backup safety precaution](VM_DISK_MONITORING.md#backup-safety), not a chart check.
[backup safety precaution](VM_DISK_MONITORING.md#backup-safety), not a count check.
## Restore-point sizes and unknown values
@@ -113,7 +104,7 @@ the measured order. On a phone, expand the restore-point row and read **Size**
under **Restore point**. A hidden column is not a missing reading. In
**Coverage**, expand the workload to see each point's size; narrow layouts
show it alongside the point's identity. One known size does not fill the gaps
for other points. For daily totals, see [why counts and volume differ](#why-proxmox-backup-counts-differ).
for other points. For totals, see [why backup counts differ](#why-proxmox-backup-counts-differ).
Compare the same workload, repository and time in existing provider records
before drawing a conclusion. Do not run another backup, verification or
@@ -368,11 +359,11 @@ A recent archive in PVE and an old or **Unprotected** Coverage row are
different observations, not proof that the archive failed or the workload is
protected. Compare one existing archive with the same workload in Pulse:
1. Open **Proxmox → Backups → By date**. Clear search and the selected chart
day, start with **All nodes** and **All backup locations**, then select
**PVE backup files** (**PVE files** on narrow screens). A chart range or
list filter is not the protection policy; widening it does not refresh
collection or change a backup's age.
1. Open **Proxmox → Backups → By date**. Clear search, start with
**All nodes** and **All backup locations**, then select
**PVE backup files** (**PVE files** on narrow screens). A list filter is
not the protection policy; widening it does not refresh collection or
change a backup's age.
2. Expand the archive to read **Source**, **Location**, **Created**, **State**
and **Identifier** under **Details**, including on a phone. Compare these
with the existing record in the owning PVE installation: connection,
@@ -2,10 +2,6 @@ import { readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import {
buildBackupActivityTimeline,
getBackupActivityUnknownCount,
} from '@/features/proxmox/proxmoxBackupActivityPresentation';
import { COVERAGE_COLUMNS } from '@/features/proxmox/proxmoxBackupsTablePresentation';
import {
isCompletedRecoveryArtifact,
@@ -48,32 +44,30 @@ const point = (id: string, overrides: Partial<RecoverableArtifact> = {}): Recove
});
describe('completed backup count guidance', () => {
it('ships the current visible labels and separates inventory, chart and list scope', () => {
it('ships the current labels and separates inventory, job and list scope', () => {
expect(read('frontend-modern/public/docs/RECOVERY.md')).toBe(read('docs/RECOVERY.md'));
const copy = text();
const tableSource = read('frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx');
// The restore points carry no per-day chart; the guide must not describe one.
expect(tableSource).not.toContain('BackupActivityChart');
for (const label of ['Completed restore points per day', 'Known restore volume per day']) {
expect(copy).toContain(label);
expect(tableSource).toContain(label);
expect(copy).not.toContain(label);
}
expect(copy).not.toContain('Completed restore volume per day');
expect(tableSource).toContain('aria-label="Clear date filter"');
expect(copy).toContain(
'covers the loaded inventory, not just the rows matching your list filters',
);
expect(copy).toContain(
"Both activity charts follow the By date list's search, Node, Backup location, Type and Source filters, including Verified or Unverified",
'Backup jobs counts the Proxmox backup tasks Pulse has retained for current workloads, including failed runs, and ignores the list filters',
);
expect(copy).toContain('a non-zero total there can sit beside an empty filtered chart');
expect(copy).toContain('so the two need not agree for any day');
expect(copy).toContain(
'The list follows the By date search, Node, Backup location, Type and Source filters, including Verified or Unverified',
);
expect(copy).toContain('a non-zero total there can sit beside an empty filtered list');
expect(copy).toContain(
'An unresolved or ambiguous saved backup location shows no matching points',
);
expect(copy).toContain('choose the intended location again or clear that filter');
expect(copy).toContain('Selecting a chart day filters the list only');
expect(copy).toContain('the other scoped days remain available in the chart');
expect(copy).toContain("The chart's date range limits its activity columns, not the list");
expect(copy).toContain('Clear date filter removes only the selected day');
expect(copy).toContain('clear search and the other filter chips separately');
expect(copy).toContain(
'None of these display controls changes collection, permissions, retention or protection policy',
);
@@ -91,30 +85,9 @@ describe('completed backup count guidance', () => {
const completed = entries.filter(isCompletedRecoveryArtifact);
expect(entries).toHaveLength(5);
expect(completed.map((entry) => entry.id)).toEqual(['completed', 'undated', 'snapshot']);
const classify = (entry: RecoverableArtifact) =>
isCompletedRecoveryArtifact(entry) ? entry.sourceKind : null;
const dated = buildBackupActivityTimeline(7, entries, (entry) => entry.createdMs, classify, {
now,
});
const volume = buildBackupActivityTimeline(7, entries, (entry) => entry.createdMs, classify, {
now,
getValue: (entry) => entry.size ?? 0,
});
expect(dated.points.reduce((sum, day) => sum + day.total, 0)).toBe(2);
expect(volume.points.reduce((sum, day) => sum + day.total, 0)).toBe(100);
expect(volume.points.reduce((sum, day) => sum + getBackupActivityUnknownCount(day), 0)).toBe(1);
const copy = text();
expect(copy).toContain(
expect(text()).toContain(
'excludes both, even when an incomplete entry has a size or a verification flag',
);
expect(copy).toContain(
'An undated completed point can count in Backup health but not in a daily column',
);
expect(copy).toContain('no reported size can count as a point without contributing volume');
expect(copy).toContain('It remains selectable in Volume and counts normally in Count');
expect(copy).toContain('Amber marks days with unknown sizes, not zero volume');
expect(copy).toContain('its known volume is a lower bound, not a complete total');
expect(copy).toContain('not PBS datastore usage or deduplicated physical space');
});
it('does not substitute a snapshot or older backup when chronology is unknown', () => {
@@ -137,7 +110,7 @@ describe('completed backup count guidance', () => {
it('keeps display checks passive and links to shipped safety and evidence sections', () => {
const copy = text();
expect(copy).toContain('A blank chart is not proof that no backups exist');
expect(copy).toContain('An empty list is not proof that no backups exist');
expect(copy).toContain('check any inventory loading or access warning first');
expect(copy).toContain('Completed is not Verified, a tested restore or guest thaw');
expect(copy).toContain(
@@ -998,11 +998,8 @@ describe('platform overview layout guardrails', () => {
const filterBarAt = proxmoxBackupsTableSource.indexOf('<FilterBar');
expect(sectionTabsAt).toBeGreaterThan(-1);
expect(filterBarAt).toBeGreaterThan(sectionTabsAt);
// Its activity day is route state; its chart range is component state.
expect(proxmoxBackupsTableSource).toMatch(
/setSearchParams\(\{\s*\[PROXMOX_BACKUPS_QUERY_PARAMS\.day\]: value \|\| null \}/,
);
expect(proxmoxBackupsTableSource).toContain('createSignal<BackupActivityRangeDays>(30)');
// The restore points carry no activity chart, so no day or range state.
expect(proxmoxBackupsTableSource).not.toContain('BackupActivityChart');
expect(proxmoxBackupsTableSource).not.toMatch(/PROXMOX_BACKUPS_QUERY_PARAMS\.range\b/);
for (const call of proxmoxBackupsTableSource.match(/setSearchParams\([^;]*/g) ?? []) {
expect(call).not.toMatch(/\brange\b|chartRange/);
@@ -1,461 +0,0 @@
import {
createComputed,
createEffect,
createMemo,
createSignal,
For,
Show,
untrack,
} from 'solid-js';
import { createStore, reconcile } from 'solid-js/store';
import type { Accessor, Component } from 'solid-js';
import { TooltipPortal } from '@/components/shared/TooltipPortal';
import {
SUMMARY_CHART_PLOT_AREA_CLASS,
SUMMARY_CHART_SLOT_COMPACT_CLASS,
} from '@/components/shared/summaryChartLayout';
import {
getRecoveryCompactAxisLabel,
getRecoveryPrettyDateLabel,
} from '@/utils/recoveryDatePresentation';
import {
getRecoveryTimelineAxisLabelClass,
getRecoveryTimelineAxisTicks,
getRecoveryTimelineChartGapPx,
getRecoveryTimelineChartMinWidthPx,
RECOVERY_TIMELINE_LEGEND_ITEM_CLASS,
} from '@/utils/recoveryTimelineChartPresentation';
import {
getRecoveryTimelineBarMarkerClass,
getRecoveryTimelineColumnButtonClass,
getRecoveryTimelineEmptyMarkerClass,
} from '@/utils/recoveryTimelinePresentation';
import {
BACKUP_ACTIVITY_RANGE_DAYS,
getBackupActivityAxisLabel,
getBackupActivityColumnAriaLabel,
getBackupActivityDayFilterStateLabel,
getBackupActivityPointTotalLabel,
getBackupActivitySegmentPresentation,
getBackupActivityTooltipRows,
getBackupActivityUnknownCount,
type BackupActivityMetricMode,
type BackupActivityNoun,
type BackupActivityPoint,
type BackupActivityRangeDays,
type BackupActivitySegmentKind,
type BackupActivityTimeline,
} from './proxmoxBackupActivityPresentation';
interface TooltipState {
key: string;
element: HTMLButtonElement;
x: number;
y: number;
}
export interface BackupActivityChartMetricToggle {
mode: Accessor<BackupActivityMetricMode>;
onChange: (mode: BackupActivityMetricMode) => void;
}
interface BackupActivityChartProps {
title: string;
noun: BackupActivityNoun;
segmentKinds: readonly BackupActivitySegmentKind[];
range: Accessor<BackupActivityRangeDays>;
onRangeChange: (days: BackupActivityRangeDays) => void;
timeline: Accessor<BackupActivityTimeline>;
selectedDateKey: Accessor<string | null>;
onToggleDay: (key: string) => void;
metricMode?: Accessor<BackupActivityMetricMode>;
metricToggle?: BackupActivityChartMetricToggle;
}
export const BackupActivityChart: Component<BackupActivityChartProps> = (props) => {
const [tooltip, setTooltip] = createSignal<TooltipState | null>(null);
let dayControls: HTMLDivElement | undefined;
let rangeControls: HTMLDivElement | undefined;
const [chart, setChart] = createStore<{ points: BackupActivityPoint[] }>({ points: [] });
// Inventory polling rebuilds every bucket. Reconcile by calendar day so a
// keyboard user's control survives; indexing would silently change its date
// when the window rolls over. Own the nested values, not the caller's DTOs.
createComputed(() => {
const next = props.timeline().points;
const target = untrack(tooltip);
if (target && !next.some((point) => point.key === target.key)) setTooltip(null);
const active = document.activeElement;
if (
active instanceof HTMLElement &&
dayControls?.contains(active) &&
!next.some((point) => point.key === active.dataset.backupActivityDay)
) {
// A retired day cannot keep focus. Return to the selected range without
// changing the saved day filter or stealing focus from another control.
untrack(() =>
rangeControls
?.querySelector<HTMLButtonElement>('[aria-pressed="true"]')
?.focus({ preventScroll: true }),
);
}
setChart(
'points',
reconcile(
next.map((point) => ({
...point,
counts: { ...point.counts },
unknownCounts: point.unknownCounts ? { ...point.unknownCounts } : undefined,
})),
{ key: 'key' },
),
);
});
const points = () => chart.points;
// Retain interaction identity, never a snapshot of the displayed reading.
// A disappearing day withdraws its tooltip rather than showing old evidence.
const activeTooltip = createMemo(() => {
const target = tooltip();
const point = target && points().find((point) => point.key === target.key);
return target && point
? { ...target, point, dateLabel: getRecoveryPrettyDateLabel(point.key) }
: null;
});
const axisMax = () => props.timeline().axisMax;
const hasSelection = () => props.selectedDateKey() !== null;
const metricMode = (): BackupActivityMetricMode =>
props.metricMode?.() ?? props.metricToggle?.mode() ?? 'count';
const unknownCount = (point: BackupActivityPoint) =>
metricMode() === 'volume' ? getBackupActivityUnknownCount(point) : 0;
const onlyUnknownVolume = () =>
metricMode() === 'volume' &&
points().some((point) => unknownCount(point) > 0) &&
!points().some((point) => point.total > 0);
const axisTicks = () =>
getRecoveryTimelineAxisTicks(points().length, false, props.timeline().labelEvery);
const chartMinWidthStyle = () => {
const minWidth = getRecoveryTimelineChartMinWidthPx(false, props.range(), points().length);
return minWidth > 0 ? `${minWidth}px` : '100%';
};
const chartGapStyle = () => `${getRecoveryTimelineChartGapPx(props.range())}px`;
const showTooltip = (target: HTMLButtonElement, key: string) => {
const rect = target.getBoundingClientRect();
setTooltip({
key,
element: target,
x: rect.left + rect.width / 2,
y: rect.top,
});
};
const hideTooltip = () => setTooltip(null);
// Retaining the control also retains its reading. After the DOM updates,
// follow the real anchor: inventory notices, metric labels and calendar
// rollover can move it even though its logical day and focus stay the same.
createEffect(() => {
props.timeline();
props.range();
metricMode();
const target = untrack(tooltip);
if (!target) return;
const rect = target.element.getBoundingClientRect();
setTooltip({ ...target, x: rect.left + rect.width / 2, y: rect.top });
});
return (
<div class="rounded-lg border border-border-subtle px-2 py-2">
<div class="mb-2 flex flex-col gap-1.5 lg:flex-row lg:items-center lg:justify-between">
<div class="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted">
<div class="font-semibold uppercase tracking-[0.18em] text-muted">{props.title}</div>
<Show when={props.segmentKinds.length > 1}>
<For each={props.segmentKinds}>
{(kind) => {
const presentation = getBackupActivitySegmentPresentation(kind);
return (
<span class={RECOVERY_TIMELINE_LEGEND_ITEM_CLASS}>
<span class={`h-2.5 w-2.5 rounded-sm ${presentation.swatchClassName}`} />
{presentation.label}
</span>
);
}}
</For>
</Show>
</div>
<div class="flex flex-wrap items-center gap-2 text-[11px]">
<Show when={props.metricToggle}>
<div
role="group"
aria-label="Activity metric"
class="inline-flex shrink-0 rounded-sm border border-border bg-surface p-0.5"
>
<For each={['count', 'volume'] as const}>
{(mode) => {
const selected = () => props.metricToggle?.mode() === mode;
return (
<button
type="button"
class={`rounded px-2 py-1 font-medium transition-colors ${
selected()
? 'bg-surface-hover text-base-content'
: 'text-muted hover:bg-surface-hover hover:text-base-content'
}`}
aria-pressed={selected() ? 'true' : 'false'}
onClick={() => props.metricToggle?.onChange(mode)}
>
{mode === 'count' ? 'Count' : 'Volume'}
</button>
);
}}
</For>
</div>
</Show>
<div
role="group"
aria-label="Activity range"
ref={rangeControls}
class="inline-flex shrink-0 rounded-sm border border-border bg-surface p-0.5"
>
<For each={BACKUP_ACTIVITY_RANGE_DAYS}>
{(days) => {
const selected = () => props.range() === days;
return (
<button
type="button"
class={`rounded px-2 py-1 font-medium transition-colors ${
selected()
? 'bg-surface-hover text-base-content'
: 'text-muted hover:bg-surface-hover hover:text-base-content'
}`}
aria-pressed={selected() ? 'true' : 'false'}
onClick={() => props.onRangeChange(days)}
>
{days === 365 ? '1y' : `${days}d`}
</button>
);
}}
</For>
</div>
</div>
</div>
<Show
when={points().length > 0}
fallback={
<div class="flex h-24 items-center justify-center text-xs text-muted">
No activity in the selected window.
</div>
}
>
<div class="relative">
<div class="grid grid-cols-[auto_minmax(0,1fr)] gap-2">
<div
class={`flex ${SUMMARY_CHART_PLOT_AREA_CLASS} flex-col justify-between text-[10px] text-muted tabular-nums`}
>
<For each={[0, 1, 2]}>
{(step) => {
const value = () => (axisMax() * (2 - step)) / 2;
return (
<span>
{onlyUnknownVolume()
? '—'
: getBackupActivityAxisLabel(value(), metricMode())}
</span>
);
}}
</For>
</div>
<div class="overflow-x-auto overscroll-x-contain pb-1">
<div
class={`relative ${SUMMARY_CHART_SLOT_COMPACT_CLASS}`}
style={{ 'min-width': chartMinWidthStyle() }}
>
<div
ref={dayControls}
class="absolute inset-x-0 bottom-4 top-0 flex items-stretch"
style={{ gap: chartGapStyle() }}
>
<For each={points()}>
{(point) => {
const total = () => point.total;
const heightPct = () =>
axisMax() > 0 ? Math.min(100, (total() / axisMax()) * 100) : 0;
const isSelected = () => props.selectedDateKey() === point.key;
const dateLabel = getRecoveryPrettyDateLabel(point.key);
return (
<div class="min-w-[3px] flex-1 self-stretch">
<button
type="button"
class={`h-full w-full ${getRecoveryTimelineColumnButtonClass(
isSelected(),
hasSelection(),
)}`}
aria-label={getBackupActivityColumnAriaLabel(
dateLabel,
total(),
isSelected(),
props.noun,
metricMode(),
unknownCount(point),
)}
aria-pressed={isSelected() ? 'true' : 'false'}
data-backup-activity-day={point.key}
onClick={() => props.onToggleDay(point.key)}
onMouseEnter={(event) => showTooltip(event.currentTarget, point.key)}
onMouseLeave={hideTooltip}
onFocus={(event) => showTooltip(event.currentTarget, point.key)}
onBlur={hideTooltip}
>
<div class="relative h-full w-full overflow-hidden rounded-xs">
<Show
when={total() > 0}
fallback={
<div
class={getRecoveryTimelineEmptyMarkerClass(
isSelected(),
hasSelection(),
)}
/>
}
>
<div
class={getRecoveryTimelineBarMarkerClass(
isSelected(),
hasSelection(),
)}
style={{ height: `${heightPct()}%` }}
>
<For each={props.segmentKinds}>
{(kind) => {
const count = () => point.counts[kind] ?? 0;
const segmentPct = () =>
total() > 0 ? (count() / total()) * 100 : 0;
return (
<Show when={segmentPct() > 0}>
<div
class={`w-full ${getBackupActivitySegmentPresentation(kind).segmentClassName}`}
style={{ height: `${segmentPct()}%` }}
/>
</Show>
);
}}
</For>
</div>
</Show>
<Show when={unknownCount(point) > 0}>
<div
data-unknown-volume
aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-1 rounded-xs bg-amber-500"
/>
</Show>
</div>
</button>
</div>
);
}}
</For>
</div>
<div class="pointer-events-none absolute inset-x-0 bottom-0 h-4">
<For each={axisTicks()}>
{(tick) => {
const point = points()[tick.index];
const isSelected = () =>
point ? props.selectedDateKey() === point.key : false;
const alignmentClass =
tick.align === 'start'
? 'left-0 text-left'
: tick.align === 'end'
? 'left-full -translate-x-full text-right'
: '-translate-x-1/2 text-center';
return (
<Show when={point}>
<span
class={`absolute bottom-0 whitespace-nowrap text-[9px] ${getRecoveryTimelineAxisLabelClass(isSelected())} ${alignmentClass}`}
style={{ left: `${tick.positionPct}%` }}
>
{getRecoveryCompactAxisLabel(point!.key, props.range())}
</span>
</Show>
);
}}
</For>
</div>
</div>
</div>
</div>
<TooltipPortal
when={activeTooltip() !== null}
x={activeTooltip()?.x ?? 0}
y={activeTooltip()?.y ?? 0}
align="center"
direction="up"
maxWidth={240}
>
<Show when={activeTooltip()}>
{(t) => (
<div class="min-w-[180px]">
<div class="flex items-start justify-between gap-3 border-b border-border pb-1">
<div class="min-w-0">
<div class="truncate text-[11px] font-semibold text-base-content">
{t().dateLabel}
</div>
<div class="mt-0.5 text-[10px] text-muted">
{getBackupActivityPointTotalLabel(
t().point.total,
props.noun,
metricMode(),
unknownCount(t().point),
)}
</div>
</div>
<div class="shrink-0 rounded-sm border border-border bg-surface-alt px-1.5 py-0.5 text-[9px] font-medium text-muted">
{getBackupActivityDayFilterStateLabel(
props.selectedDateKey() === t().point.key,
hasSelection(),
)}
</div>
</div>
<ul class="mt-1.5 space-y-1">
<For
each={getBackupActivityTooltipRows(
t().point,
props.segmentKinds,
metricMode(),
)}
>
{(row) => (
<li
class={`flex items-center justify-between gap-4 ${
row.muted ? '' : 'text-base-content'
}`}
>
<span class="flex min-w-0 items-center gap-1.5">
<span class={`h-2 w-2 shrink-0 rounded-xs ${row.segmentClassName}`} />
<span class="truncate">{row.label}</span>
</span>
<span class="shrink-0 font-mono tabular-nums">{row.value}</span>
</li>
)}
</For>
</ul>
</div>
)}
</Show>
</TooltipPortal>
</div>
</Show>
</div>
);
};
export default BackupActivityChart;
@@ -30,10 +30,6 @@ import {
PlatformSectionTabs,
PlatformTableLoadingState,
} from '@/features/platformPage/sharedPlatformPage';
import {
getRecoveryFilterDateLabel,
recoveryDateKeyFromTimestamp,
} from '@/utils/recoveryDatePresentation';
import type {
Alert,
BackupTask,
@@ -44,18 +40,9 @@ import type {
StorageBackup,
} from '@/types/api';
import type { Resource } from '@/types/resource';
import { BackupActivityChart } from './BackupActivityChart';
import {
buildBackupActivityTimeline,
getBackupActivityUnknownCount,
type BackupActivityMetricMode,
type BackupActivityRangeDays,
type BackupActivitySegmentKind,
} from './proxmoxBackupActivityPresentation';
import {
buildProxmoxBackupRecoveryModel,
coverageRowMatchesSearch,
isCompletedRecoveryArtifact,
selectWorkloadRecoveryArtifacts,
recoverableArtifactMatchesSearch,
type RecoverableArtifact,
@@ -279,13 +266,6 @@ export const ProxmoxBackupsTable: Component<{
},
{ replace: true },
);
const selectedDateKey = (): string | null => {
const value = queryValue(PROXMOX_BACKUPS_QUERY_PARAMS.day);
return /^\d{4}-\d{2}-\d{2}$/.test(value) ? value : null;
};
const setSelectedDateKey = (value: string | null): void =>
setSearchParams({ [PROXMOX_BACKUPS_QUERY_PARAMS.day]: value || null }, { replace: true });
const nodeFilter = (): string => queryValue(PROXMOX_BACKUPS_QUERY_PARAMS.node);
const setNodeFilter = (value: string): void =>
setSearchParams({ [PROXMOX_BACKUPS_QUERY_PARAMS.node]: value || null }, { replace: true });
@@ -337,14 +317,11 @@ export const ProxmoxBackupsTable: Component<{
// pile of unassigned artifacts sorted to the top.
const [showOrphaned, setShowOrphaned] = createSignal(false);
// Chronological feed sort and activity-chart controls.
// Chronological feed sort.
const [recoverableSortKey, setRecoverableSortKey] = createSignal<RecoverableSortKey>('created');
const [recoverableSortDirection, setRecoverableSortDirection] = createSignal<'asc' | 'desc'>(
'desc',
);
const [chartRange, setChartRange] = createSignal<BackupActivityRangeDays>(30);
const [recoverableMetricMode, setRecoverableMetricMode] =
createSignal<BackupActivityMetricMode>('count');
const handleCoverageSort = (key: CoverageSortKey) => {
if (coverageSortKey() === key) {
@@ -364,7 +341,6 @@ export const ProxmoxBackupsTable: Component<{
};
const toggleCoverageExpansion = (key: string) =>
setExpandedCoverageKey((current) => (current === key ? null : key));
const toggleDay = (key: string) => setSelectedDateKey(selectedDateKey() === key ? null : key);
// Retain readable observations while a retry is pending, but never treat a
// settled failed read as a complete inventory or expose its old artifacts.
@@ -618,15 +594,8 @@ export const ProxmoxBackupsTable: Component<{
BACKUP_VIEW_TABS.map((tab) => ({ ...tab, path: backupViewPath(tab.id) })),
);
// Recoverable artifact feed: PBS snapshots, PVE backup files, and guest snapshot rows.
const RECOVERABLE_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = [
'pbs',
'archive',
'snapshot',
];
// The chart and list share every inventory facet. Day selection narrows
// only the list so other days remain available to select in the chart.
// Recoverable artifact feed: PBS snapshots, PVE backup files, and guest
// snapshot rows, narrowed by every inventory facet.
const scopedRecoverableArtifacts = createMemo(() => {
const term = search().trim().toLowerCase();
const filter = recoverableFilter();
@@ -646,48 +615,8 @@ export const ProxmoxBackupsTable: Component<{
});
});
const recoverableTimeline = createMemo(() =>
buildBackupActivityTimeline<RecoverableArtifact>(
chartRange(),
scopedRecoverableArtifacts(),
(artifact) => artifact.createdMs,
(artifact) =>
!isCompletedRecoveryArtifact(artifact)
? null
: artifact.sourceKind === 'pbs'
? 'pbs'
: artifact.sourceKind === 'archive'
? 'archive'
: 'snapshot',
{
now: new Date(nowMs()),
getValue:
recoverableMetricMode() === 'volume'
? (artifact) => (artifact.size && artifact.size > 0 ? artifact.size : 0)
: undefined,
},
),
);
const hasRecoverableActivityInRange = createMemo(() =>
recoverableTimeline().points.some(
(point) => point.total > 0 || getBackupActivityUnknownCount(point) > 0,
),
);
const unknownVolumeCount = createMemo(() =>
recoverableTimeline().points.reduce(
(sum, point) => sum + getBackupActivityUnknownCount(point),
0,
),
);
const filteredRecoverableArtifacts = createMemo(() => {
const dateKey = selectedDateKey();
const list = scopedRecoverableArtifacts().filter(
(artifact) =>
!dateKey ||
(artifact.createdMs !== undefined &&
recoveryDateKeyFromTimestamp(artifact.createdMs) === dateKey),
);
const list = [...scopedRecoverableArtifacts()];
const sortKey = recoverableSortKey();
const direction = recoverableSortDirection();
list.sort((a, b) => {
@@ -786,8 +715,7 @@ export const ProxmoxBackupsTable: Component<{
typeFilter() ||
coverageFilter() !== 'all' ||
exceptionFilter() !== null ||
recoverableFilter() !== 'all' ||
selectedDateKey(),
recoverableFilter() !== 'all',
);
const resetBackupsFilters = (): void =>
setSearchParams(
@@ -984,76 +912,15 @@ export const ProxmoxBackupsTable: Component<{
</div>
</Show>
<Show when={view() === 'date' && recoveryModel().recoverableArtifacts.length > 0}>
<Show
when={scopedRecoverableArtifacts().some(
(artifact) => artifact.createdMs === undefined,
)}
>
<p class="text-xs text-amber-700 dark:text-amber-300" role="status">
Backup entries with unavailable or future dates remain listed. Their ages are
unknown. They are excluded from the activity chart and day filters.
</p>
</Show>
<Show
when={hasRecoverableActivityInRange()}
fallback={
<div
ref={retainEvidenceFocus}
class="flex flex-col gap-2 rounded-md border border-border-subtle px-3 py-3 text-xs text-muted sm:flex-row sm:items-center sm:justify-between"
>
<span>
No completed restore points with known dates in the selected {chartRange()}
-day window.
</span>
<div class="flex items-center gap-2">
<button
type="button"
class="font-medium text-blue-600 hover:underline dark:text-blue-300"
onClick={() => setChartRange(90)}
>
Show 90 days
</button>
<span aria-hidden="true">·</span>
<button
type="button"
class="font-medium text-blue-600 hover:underline dark:text-blue-300"
onClick={() => setChartRange(365)}
>
Show 1 year
</button>
</div>
</div>
}
>
<div ref={retainEvidenceFocus} class="space-y-1">
<Show when={recoverableMetricMode() === 'volume' && unknownVolumeCount() > 0}>
<p class="text-xs text-amber-700 dark:text-amber-300" role="status">
Sizes are unavailable for {unknownVolumeCount()} completed restore{' '}
{unknownVolumeCount() === 1 ? 'point' : 'points'} in this window. Bars show
known volume only. Amber marks days with unknown sizes, not zero volume.
</p>
</Show>
<BackupActivityChart
title={
recoverableMetricMode() === 'volume'
? 'Known restore volume per day'
: 'Completed restore points per day'
}
noun="restore point"
segmentKinds={RECOVERABLE_SEGMENT_KINDS}
range={chartRange}
onRangeChange={setChartRange}
timeline={recoverableTimeline}
selectedDateKey={selectedDateKey}
onToggleDay={toggleDay}
metricToggle={{
mode: recoverableMetricMode,
onChange: setRecoverableMetricMode,
}}
/>
</div>
</Show>
<Show
when={
view() === 'date' &&
scopedRecoverableArtifacts().some((artifact) => artifact.createdMs === undefined)
}
>
<p class="text-xs text-amber-700 dark:text-amber-300" role="status">
Backup entries with unavailable or future dates remain listed. Their ages are unknown.
</p>
</Show>
<FilterBar
@@ -1068,24 +935,6 @@ export const ProxmoxBackupsTable: Component<{
filters={buildBackupsFilters()}
showClearAll={hasActiveBackupsFilters}
onClearAll={resetBackupsFilters}
searchTrailing={
<Show when={view() === 'date' && selectedDateKey() !== null}>
<button
type="button"
onClick={() => setSelectedDateKey(null)}
class="inline-flex items-center gap-1 rounded-full border border-blue-300 bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700 transition-colors hover:bg-blue-100 dark:border-blue-700 dark:bg-blue-900/30 dark:text-blue-200 dark:hover:bg-blue-900/50"
aria-label="Clear date filter"
>
<span class="uppercase tracking-wide text-[9px] text-blue-600 dark:text-blue-300">
Date
</span>
<span class="font-mono tabular-nums">
{getRecoveryFilterDateLabel(selectedDateKey()!)}
</span>
<span aria-hidden="true">×</span>
</button>
</Show>
}
trailingControls={
<PlatformResourceCounter
visible={view() === 'date' ? visibleRecoverableCount() : visibleLiveCount()}
@@ -594,7 +594,7 @@ export function ProxmoxCoverageTable(props: {
description={
!props.hasAnyRows
? props.emptyDescription
: 'Adjust the search, posture filter, or selected day to see more workloads.'
: 'Adjust the search or filters to see more workloads.'
}
/>
}
@@ -459,7 +459,7 @@ export function ProxmoxRecoverableTable(props: {
description={
!props.hasAnyArtifacts
? props.emptyDescription
: 'Adjust the search, source filter, or selected day to see more artifacts.'
: 'Adjust the search or filters to see more artifacts.'
}
/>
}
@@ -1,170 +0,0 @@
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { getRecoveryPrettyDateLabel } from '@/utils/recoveryDatePresentation';
import { BackupActivityChart } from '../BackupActivityChart';
import type {
BackupActivityMetricMode,
BackupActivityPoint,
BackupActivityTimeline,
} from '../proxmoxBackupActivityPresentation';
vi.mock('@/components/shared/hoverCapability', () => ({ supportsHoverTooltips: () => true }));
const point = (key: string, total: number, unknown = 0): BackupActivityPoint => ({
key,
total,
counts: { archive: total, pbs: 0, snapshot: 0, ok: 0, failed: 0, running: 0 },
...(unknown ? { unknownCounts: { pbs: unknown } } : {}),
});
const timeline = (points: BackupActivityPoint[]): BackupActivityTimeline => ({
points,
axisMax: Math.max(2, ...points.map((point) => point.total)),
labelEvery: 1,
});
const day = (key: string): HTMLButtonElement =>
document.querySelector(`[data-backup-activity-day="${key}"]`)!;
const tooltip = () => document.querySelector<HTMLElement>('[data-tooltip-portal]');
function mount() {
const [data, setData] = createSignal(timeline([point('2026-10-27', 1), point('2026-10-28', 2)]));
const [selected, setSelected] = createSignal<string | null>(null);
const [mode, setMode] = createSignal<BackupActivityMetricMode>('count');
const onToggleDay = vi.fn((key: string) => setSelected(selected() === key ? null : key));
render(() => (
<>
<button type="button">Outside chart</button>
<BackupActivityChart
title="Restore points"
noun="restore point"
segmentKinds={['archive', 'pbs', 'snapshot']}
range={() => 30}
onRangeChange={() => {}}
timeline={data}
selectedDateKey={selected}
onToggleDay={onToggleDay}
metricToggle={{ mode, onChange: setMode }}
/>
</>
));
return { data, setData, selected, setMode, onToggleDay };
}
afterEach(() => {
cleanup();
vi.restoreAllMocks();
});
describe('backup activity interaction continuity', () => {
it('keeps the exact focused day across fresh inventory objects and updates its reading', () => {
const { setData, selected } = mount();
const target = day('2026-10-28');
target.focus();
expect(tooltip()).toHaveTextContent('2 restore points');
setData(timeline([point('2026-10-27', 1), point('2026-10-28', 5)]));
expect(day('2026-10-28')).toBe(target);
expect(target).toHaveFocus();
expect(target).toHaveAccessibleName(/5 restore points/);
expect(tooltip()).toHaveTextContent('5 restore points');
expect(tooltip()).not.toHaveTextContent('2 restore points');
fireEvent.click(target);
expect(selected()).toBe('2026-10-28');
expect(target).toHaveFocus();
expect(target).toHaveAttribute('aria-pressed', 'true');
fireEvent.click(target);
expect(selected()).toBeNull();
expect(target).toHaveAttribute('aria-pressed', 'false');
});
it('updates a hovered day to mixed, unknown-only and known volume without retaining old counts', () => {
const { setData, setMode } = mount();
const target = day('2026-10-28');
fireEvent.mouseEnter(target);
expect(tooltip()).toHaveTextContent('2 restore points');
setMode('volume');
setData(timeline([point('2026-10-27', 1), point('2026-10-28', 2048, 1)]));
expect(day('2026-10-28')).toBe(target);
expect(tooltip()).toHaveTextContent('2.00 KB known · 1 size unknown');
expect(target).toHaveAccessibleName(/2.00 KB known · 1 size unknown/);
expect(target.querySelector('[data-unknown-volume]')).not.toBeNull();
setData(timeline([point('2026-10-27', 1), point('2026-10-28', 0, 2)]));
expect(tooltip()).toHaveTextContent('2 sizes unknown');
expect(tooltip()).not.toHaveTextContent('2.00 KB');
setData(timeline([point('2026-10-27', 1), point('2026-10-28', 4096)]));
expect(tooltip()).toHaveTextContent('4.00 KB');
expect(tooltip()).not.toHaveTextContent('unknown');
expect(target.querySelector('[data-unknown-volume]')).toBeNull();
fireEvent.mouseLeave(target);
expect(tooltip()).toBeNull();
});
it('reanchors the retained reading after inventory layout changes', async () => {
const { setData } = mount();
const target = day('2026-10-28');
let top = 200;
vi.spyOn(target, 'getBoundingClientRect').mockImplementation(
() => new DOMRect(100, top, 20, 80),
);
target.focus();
const portal = () => document.querySelector('foreignObject');
await waitFor(() => expect(portal()).toHaveAttribute('y', '192'));
top = 250;
setData(timeline([point('2026-10-27', 1), point('2026-10-28', 3)]));
await waitFor(() => expect(portal()).toHaveAttribute('y', '242'));
expect(target).toHaveFocus();
expect(tooltip()).toHaveTextContent('3 restore points');
});
it('keeps a surviving calendar day, not its array index, when the window rolls over', () => {
const { setData } = mount();
const target = day('2026-10-28');
target.focus();
setData(timeline([point('2026-10-28', 3), point('2026-10-29', 1)]));
expect(day('2026-10-28')).toBe(target);
expect(target).toHaveFocus();
expect(target).toHaveAccessibleName(
`${getRecoveryPrettyDateLabel('2026-10-28')}: 3 restore points`,
);
expect(day('2026-10-29')).not.toBe(target);
});
it.each([false, true])(
'returns a retired focused day to the selected range (empty=%s)',
(empty) => {
const { setData, selected, onToggleDay } = mount();
const target = day('2026-10-27');
target.focus();
fireEvent.click(target);
setData(timeline(empty ? [] : [point('2026-10-28', 2), point('2026-10-29', 1)]));
expect(target).not.toBeInTheDocument();
expect(
within(screen.getByRole('group', { name: 'Activity range' })).getByRole('button', {
name: '30d',
}),
).toHaveFocus();
expect(tooltip()).toBeNull();
expect(selected()).toBe('2026-10-27');
expect(onToggleDay).toHaveBeenCalledTimes(1);
},
);
it('withdraws a retired hover reading without stealing focus or mutating the caller data', () => {
const { setData } = mount();
const outside = screen.getByRole('button', { name: 'Outside chart' });
outside.focus();
fireEvent.mouseEnter(day('2026-10-27'));
expect(tooltip()).toHaveTextContent('1 restore point');
const incoming = timeline([point('2026-10-28', 9), point('2026-10-29', 1)]);
const saved = JSON.stringify(incoming);
setData(incoming);
expect(tooltip()).toBeNull();
expect(outside).toHaveFocus();
setData(timeline([point('2026-10-28', 4), point('2026-10-29', 1)]));
expect(JSON.stringify(incoming)).toBe(saved);
expect(outside).toHaveFocus();
});
});
@@ -24,10 +24,7 @@ import { TABLE_CARD_FRAME_CLASS } from '@/components/shared/TableCard';
import type { Resource } from '@/types/resource';
import type { ProtectionPosturesResponse } from '@/types/recovery';
import { protectionPolicy, protectionPosture } from '@/utils/__fixtures__/protectionPosture';
import {
getRecoveryFullDateLabel,
getRecoveryPrettyDateLabel,
} from '@/utils/recoveryDatePresentation';
import { getRecoveryFullDateLabel } from '@/utils/recoveryDatePresentation';
import { eventBus } from '@/stores/events';
import { setKioskMode } from '@/utils/url';
import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
@@ -646,7 +643,7 @@ describe('ProxmoxBackupsTable', () => {
window.history.replaceState(
{},
'',
'/?view=date&q=pbs-docker&source=pbs&location=pbs%3Apbs-main%3Amain&node=pve-a&type=ct&day=2026-05-25',
'/?view=date&q=pbs-docker&source=pbs&location=pbs%3Apbs-main%3Amain&node=pve-a&type=ct&day=2026-01-01',
);
renderInRouter(() => (
@@ -660,7 +657,8 @@ describe('ProxmoxBackupsTable', () => {
'aria-pressed',
'true',
);
expect(screen.getByRole('button', { name: /clear date filter/i })).toBeInTheDocument();
// An old bookmark's day no longer narrows the list; Clear filters drops it.
expect(screen.queryByRole('button', { name: /clear date filter/i })).not.toBeInTheDocument();
expect(
screen.getByRole('button', { name: 'Backup location: PBS · pbs-main / main' }),
).toBeInTheDocument();
@@ -1139,7 +1137,7 @@ describe('ProxmoxBackupsTable', () => {
});
expect(emptyStateHeading).toBeInTheDocument();
expect(
screen.getByText('Adjust the search, source filter, or selected day to see more artifacts.'),
screen.getByText('Adjust the search or filters to see more artifacts.'),
).toBeInTheDocument();
expectClassTokens(
emptyStateHeading.closest(`.${TABLE_CARD_FRAME_CLASS}`),
@@ -1963,11 +1961,6 @@ describe('backup-date-evidence connected inventory', () => {
const panel = screen.getByTestId('proxmox-recoverable-detail');
expect(within(panel).getByText('Reported date').closest('tr')).toHaveTextContent(date);
expect(within(panel).getByText('Created').closest('tr')).toHaveTextContent('Unknown');
const notice = screen.getByText(
/Backup entries with unavailable or future dates remain listed/,
);
expect(notice).toHaveTextContent('Their ages are unknown.');
expect(notice).toHaveTextContent('excluded from the activity chart and day filters');
expect(apiFetchMock).toHaveBeenCalledTimes(2);
},
);
@@ -2011,19 +2004,13 @@ describe('backup-date-evidence connected inventory', () => {
await waitFor(() => expect(lastBackupCell()).toHaveTextContent('Unknown'));
});
it('[regression] By date retains future artifacts but excludes them from today activity and day filtering', async () => {
it('[regression] By date retains future artifacts with an unknown age', async () => {
window.history.replaceState({}, '', '/?view=date');
supply('2026-10-04T12:00:01Z', true);
mount();
await waitFor(() =>
expect(document.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(2),
);
const warning = screen.getByText(
/Backup entries with unavailable or future dates remain listed/,
);
expect(warning).toHaveAttribute('role', 'status');
expect(warning).toHaveTextContent('excluded from the activity chart and day filters');
expect(screen.getByText(/No completed restore points with known dates/)).toBeInTheDocument();
const future = [...document.querySelectorAll('[data-proxmox-backup-row="recoverable"]')].find(
(row) => row.textContent?.includes('PBS'),
)! as HTMLElement;
@@ -2450,7 +2437,7 @@ describe('Coverage withdraws failed protection assessments', () => {
});
});
describe('completed restore-point summary and activity', () => {
describe('completed restore-point summary', () => {
afterEach(() => vi.restoreAllMocks());
const mountInventory = (incompleteOnly = false) => {
@@ -2487,60 +2474,33 @@ describe('completed restore-point summary and activity', () => {
));
};
it('counts completed points and volume separately while retaining running and failed rows for inspection', async () => {
it('counts completed points while retaining running and failed rows for inspection', async () => {
const { container } = mountInventory();
await screen.findByText(/3 completed restore points · 1 running · 1 failed/);
expect(container.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(5);
expect(
screen.getByRole('cell', { name: `${getRecoveryFullDateLabel('2026-10-04')} 5 entries` }),
).toBeInTheDocument();
const day = screen.getByRole('button', { name: /: 3 restore points$/ });
expect(day).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /: 5 restore points$/ })).not.toBeInTheDocument();
expect(screen.getByText('Completed restore points per day')).toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: 'Volume' }));
expect(screen.getByText('Known restore volume per day')).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /: 3.00 KB known · 1 size unknown$/ }),
).toBeInTheDocument();
expect(screen.getAllByText('Running').length).toBeGreaterThan(0);
expect(screen.getAllByText('Failed').length).toBeGreaterThan(0);
});
it('does not draw completed activity or claim PBS restore coverage for an incomplete-only inventory', async () => {
it('does not claim PBS restore coverage for an incomplete-only inventory', async () => {
const { container } = mountInventory(true);
const summary = await screen.findByText(/0 completed restore points · 1 running · 1 failed/);
expect(summary).not.toHaveTextContent('with PBS snapshots');
expect(screen.getByText(/No completed restore points with known dates/)).toBeInTheDocument();
expect(screen.queryByRole('group', { name: 'Activity metric' })).not.toBeInTheDocument();
expect(container.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(2);
expect(
screen.getByRole('cell', { name: `${getRecoveryFullDateLabel('2026-10-04')} 2 entries` }),
).toBeInTheDocument();
await fireEvent.click(screen.getByRole('link', { name: 'Coverage' }));
expect(screen.queryByText(/completed restore points with known dates/)).not.toBeInTheDocument();
expect(
screen.getByText(/0 completed restore points · 1 running · 1 failed/),
).toBeInTheDocument();
});
it('keeps incomplete entries available under a completed day filter and when it is cleared', async () => {
const { container } = mountInventory();
await screen.findByText(/3 completed restore points/);
await fireEvent.click(screen.getByRole('button', { name: /: 3 restore points$/ }));
await waitFor(() => expect(window.location.search).toContain('day=2026-10-04'));
expect(container.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(5);
await fireEvent.click(screen.getByRole('button', { name: 'Clear date filter' }));
await waitFor(() => expect(window.location.search).not.toContain('day='));
expect(screen.getByRole('button', { name: /: 3 restore points$/ })).toHaveAttribute(
'aria-pressed',
'false',
);
expect(container.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(5);
});
});
describe('restore volume with unavailable sizes', () => {
describe('restore points with unavailable sizes', () => {
afterEach(() => vi.restoreAllMocks());
const mountVolumeInventory = (mixed = false) => {
@@ -2584,60 +2544,6 @@ describe('restore volume with unavailable sizes', () => {
));
};
it('[volume-size] keeps unknown-only activity and the Count control instead of claiming no restore points', async () => {
mountVolumeInventory();
await screen.findByRole('button', { name: /: 3 restore points$/ });
await fireEvent.click(screen.getByRole('button', { name: 'Volume' }));
expect(screen.getByRole('button', { name: 'Count' })).toBeInTheDocument();
expect(screen.getByText('Known restore volume per day')).toBeInTheDocument();
expect(
screen.queryByText(/No completed restore points with known dates/),
).not.toBeInTheDocument();
expect(
screen.getByText(/Sizes are unavailable for 3 completed restore points in this window/),
).toBeInTheDocument();
const day = screen.getByRole('button', { name: /: 3 sizes unknown$/ });
expect(day.querySelector('[data-unknown-volume]')).not.toBeNull();
await fireEvent.click(day);
expect(
screen.getByRole('button', { name: /: 3 sizes unknown, selected$/ }),
).toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: 'Count' }));
expect(
screen.getByRole('button', { name: /: 3 restore points, selected$/ }),
).toBeInTheDocument();
expect(screen.queryByText(/Sizes are unavailable for/)).not.toBeInTheDocument();
});
it('[volume-size] distinguishes known bytes, unknown-only days and genuinely empty days', async () => {
mountVolumeInventory(true);
await screen.findByRole('button', { name: /: 3 restore points$/ });
await fireEvent.click(screen.getByRole('button', { name: 'Volume' }));
expect(
screen.getByText(/Sizes are unavailable for 2 completed restore points in this window/),
).toBeInTheDocument();
const today = screen.getByRole('button', { name: /: 3.00 KB known · 1 size unknown$/ });
const yesterday = screen.getByRole('button', { name: /: 1 size unknown$/ });
expect(screen.getAllByRole('button', { name: /: 0 B$/ }).length).toBeGreaterThan(0);
await fireEvent.focus(today);
expect(screen.getByText('3.00 KB known · 1 size unknown')).toBeInTheDocument();
expect(
within(document.querySelector<HTMLElement>('[data-tooltip-portal]')!).getByText(
'Unknown size',
),
).toBeInTheDocument();
expect(screen.queryByText('1.00 KB (33%)')).not.toBeInTheDocument();
await fireEvent.click(yesterday);
expect(document.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(1);
expect(
screen.getByRole('button', { name: /: 3.00 KB known · 1 size unknown$/ }),
).toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: 'Count' }));
expect(
screen.getByRole('button', { name: /: 1 restore point, selected$/ }),
).toBeInTheDocument();
});
it('[point-size] keeps unavailable size explicit without changing verification or completed counts', async () => {
mountVolumeInventory();
const toggle = await screen.findByRole('button', {
@@ -2656,20 +2562,6 @@ describe('restore volume with unavailable sizes', () => {
expect(document.body).toHaveTextContent('5 completed restore points');
expect(document.body).toHaveTextContent('1 running');
});
it('[volume-size] follows source scope without counting incomplete or out-of-window unknown sizes', async () => {
mountVolumeInventory(true);
await screen.findByRole('button', { name: /: 3 restore points$/ });
await fireEvent.click(screen.getByRole('button', { name: 'Volume' }));
await fireEvent.click(
within(screen.getByRole('group', { name: 'Source' })).getByRole('button', {
name: 'PVE backup files found on Proxmox VE storage',
}),
);
expect(screen.getByRole('button', { name: /: 1.00 KB$/ })).toBeInTheDocument();
expect(screen.queryByText(/Sizes are unavailable for/)).not.toBeInTheDocument();
expect(document.querySelector('[data-unknown-volume]')).toBeNull();
});
});
describe('mounted Proxmox backup inventory refresh', () => {
@@ -3081,7 +2973,7 @@ describe('location-scoped evidence keeps workload-wide protection explicit', ()
});
});
describe('backup activity follows the consuming inventory scope', () => {
describe('restore point list follows the consuming inventory scope', () => {
afterEach(() => vi.restoreAllMocks());
const mountScopedInventory = (query = '') => {
@@ -3138,143 +3030,30 @@ describe('backup activity follows the consuming inventory scope', () => {
/>
));
};
const day = (date: string, value: string, selected = false) =>
screen.getByRole('button', {
name: `${getRecoveryPrettyDateLabel(date)}: ${value}${selected ? ', selected' : ''}`,
});
const rows = () => document.querySelectorAll('[data-proxmox-backup-row="recoverable"]');
it.each([
['source', 'source=archive', 3, '1 restore point', '2 restore points', '1.00 KB', '12.0 KB'],
['verified', 'source=verified', 1, '1 restore point', '0 restore points', '2.00 KB', '0 B'],
['unverified', 'source=unverified', 1, '0 restore points', '1 restore point', '0 B', '16.0 KB'],
['node', 'node=pve-2', 1, '0 restore points', '1 restore point', '0 B', '8.00 KB'],
['type', 'type=ct', 1, '0 restore points', '1 restore point', '0 B', '8.00 KB'],
['search', 'q=west-200', 1, '0 restore points', '1 restore point', '0 B', '8.00 KB'],
[
'combined',
'node=pve-1&type=vm&source=archive',
2,
'1 restore point',
'1 restore point',
'1.00 KB',
'4.00 KB',
],
[
'case-sensitive location',
`location=${encodeURIComponent('["pbs","pbs-server","Main"]')}`,
1,
'0 restore points',
'1 restore point',
'0 B',
'16.0 KB',
],
])(
'keeps %s-filtered count and volume in agreement with the list',
async (_label, query, count, today, yesterday, todayBytes, yesterdayBytes) => {
mountScopedInventory(String(query));
await waitFor(() => expect(rows()).toHaveLength(Number(count)));
expect(day('2026-10-04', String(today))).toBeInTheDocument();
expect(day('2026-10-03', String(yesterday))).toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: 'Volume' }));
expect(day('2026-10-04', String(todayBytes))).toBeInTheDocument();
expect(day('2026-10-03', String(yesterdayBytes))).toBeInTheDocument();
},
);
['source', 'source=archive', 3],
['verified', 'source=verified', 1],
['unverified', 'source=unverified', 1],
['node', 'node=pve-2', 1],
['type', 'type=ct', 1],
['search', 'q=west-200', 1],
['combined', 'node=pve-1&type=vm&source=archive', 2],
['case-sensitive location', `location=${encodeURIComponent('["pbs","pbs-server","Main"]')}`, 1],
])('narrows the list by %s', async (_label, query, count) => {
mountScopedInventory(String(query));
await waitFor(() => expect(rows()).toHaveLength(Number(count)));
});
it.each(['q=no-such-workload', 'location=missing', 'location=pbs%3Apbs-server%3Amain'])(
'does not show another scope activity for empty or unresolved %s',
'shows no restore points for empty or unresolved %s',
async (query) => {
mountScopedInventory(query);
await screen.findByText(/7 backup entries/);
expect(rows()).toHaveLength(0);
expect(screen.queryByRole('group', { name: 'Activity metric' })).not.toBeInTheDocument();
expect(screen.getByText(/No completed restore points with known dates/)).toBeInTheDocument();
},
);
it('keeps other scoped days available while selecting, clearing and changing filters', async () => {
mountScopedInventory('source=archive');
await waitFor(() => expect(rows()).toHaveLength(3));
const calls = apiFetchMock.mock.calls.length;
await fireEvent.click(day('2026-10-04', '1 restore point'));
await waitFor(() => expect(rows()).toHaveLength(1));
expect(day('2026-10-04', '1 restore point', true)).toBeInTheDocument();
expect(day('2026-10-03', '2 restore points')).toBeInTheDocument();
await fireEvent.click(day('2026-10-03', '2 restore points'));
await waitFor(() => expect(rows()).toHaveLength(2));
await fireEvent.click(screen.getByRole('button', { name: 'Clear date filter' }));
await waitFor(() => expect(rows()).toHaveLength(3));
await fireEvent.click(
within(screen.getByRole('group', { name: 'Source' })).getByRole('button', { name: 'All' }),
);
await waitFor(() => expect(rows()).toHaveLength(7));
expect(day('2026-10-04', '3 restore points')).toBeInTheDocument();
expect(day('2026-10-03', '3 restore points')).toBeInTheDocument();
expect(apiFetchMock).toHaveBeenCalledTimes(calls);
});
});
describe('backup activity day controls survive ordinary inventory polling', () => {
afterEach(() => vi.useRealTimers());
it('retains the same focused date, updates its count and toggles the current parsed entries', async () => {
vi.useFakeTimers({
now: BACKUP_IDENTITY_NOW,
toFake: ['Date', 'setInterval', 'clearInterval'],
});
let archives = [identityArchive()];
apiFetchMock.mockImplementation((url: string) =>
Promise.resolve(
jsonResponse({
data: url.endsWith('/pbs')
? { backups: [] }
: {
backupTasks: [],
guestSnapshots: [],
storageBackups: archives,
},
}),
),
);
apiFetchJSONMock.mockResolvedValue({ data: [], policy: protectionPolicy });
window.history.replaceState({}, '', '/proxmox/backups/date');
renderInRouter(() => (
<ProxmoxBackupsTable
emptyIcon={<span />}
workloads={[identityGuest('east-100', 'east', 'pve-1')]}
/>
));
const target = await screen.findByRole('button', {
name: `${getRecoveryPrettyDateLabel('2026-10-04')}: 1 restore point`,
});
target.focus();
archives = [identityArchive(), identityArchive({ id: 'second', time: '2026-10-04T10:00:00Z' })];
await vi.advanceTimersByTimeAsync(30_000);
expect(
screen.getByRole('button', {
name: `${getRecoveryPrettyDateLabel('2026-10-04')}: 2 restore points`,
}),
).toBe(target);
expect(target).toHaveFocus();
expect(apiFetchMock).toHaveBeenCalledTimes(4);
expect(apiFetchJSONMock).toHaveBeenCalledTimes(2);
// Like the existing saved-view/navigation regressions, keep the router's
// scheduling live during input. The inventory poll above stays controlled.
vi.useRealTimers();
vi.useFakeTimers({ now: BACKUP_IDENTITY_NOW + 30_000, toFake: ['Date'] });
fireEvent.click(target);
await waitFor(() => expect(target).toHaveAttribute('aria-pressed', 'true'));
expect(document.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(2);
await waitFor(() =>
expect(new URLSearchParams(window.location.search).get('day')).toBe('2026-10-04'),
);
fireEvent.click(target);
await waitFor(() => expect(target).toHaveAttribute('aria-pressed', 'false'));
expect(target).toHaveFocus();
await waitFor(() => expect(new URLSearchParams(window.location.search).has('day')).toBe(false));
expect(apiFetchMock).toHaveBeenCalledTimes(4);
});
});
describe('bare Backups entry retains its assessed workspace', () => {
@@ -159,23 +159,6 @@ describe('retiring backup evidence retains a usable keyboard position', () => {
expect(screen.getByPlaceholderText(searchLabel)).toHaveValue('pbs-100');
});
it.each([true, false])(
'retains focus when a PBS-filtered activity chart is withdrawn (PVE empty: %s)',
async (pveEmpty) => {
window.history.replaceState({}, '', '/proxmox/backups/date?source=pbs');
mount({ pveEmpty });
await point();
const day = document.querySelector<HTMLButtonElement>(
'[data-backup-activity-day="2026-10-04"]',
)!;
expect(day).not.toBeNull();
day.focus();
const retry = await fail('pbs');
await waitFor(() => expect(retry).toHaveFocus());
expect(day).not.toBeInTheDocument();
},
);
it('retains focus when a failed source removes the unmatched-evidence disclosure', async () => {
window.history.replaceState({}, '', '/proxmox/backups/coverage');
mount({ pbsOrphaned: true });
@@ -118,7 +118,7 @@ describe('malformed timestamp evidence through the parsed HTTP consumer', () =>
});
it.each([1200, 390, 320])(
'retains every undated restore point without chart activity at %ipx',
'retains every undated restore point with an unknown age at %ipx',
async (width) => {
window.history.replaceState({}, '', '/proxmox/backups/date');
api.width = width;
@@ -133,7 +133,6 @@ describe('malformed timestamp evidence through the parsed HTTP consumer', () =>
);
for (const row of rows)
expect(within(row).getByText('Unknown', { exact: true })).toBeInTheDocument();
expect(document.body).toHaveTextContent('No completed restore points with known dates');
expect(document.body).toHaveTextContent('Their ages are unknown.');
fireEvent.click(within(rows[0]).getByRole('button', { name: /Expand details/ }));
const panel = await screen.findByTestId('proxmox-recoverable-detail');
@@ -1,684 +0,0 @@
import { describe, expect, it, vi } from 'vitest';
import { recoveryDateKeyFromTimestamp } from '@/utils/recoveryDatePresentation';
import { getRecoveryTimelineDayFilterStateLabel } from '@/utils/recoveryTimelinePresentation';
import {
BACKUP_ACTIVITY_RANGE_DAYS,
buildBackupActivityTimeline,
getBackupActivityAxisLabel,
getBackupActivityColumnAriaLabel,
getBackupActivityDayFilterStateLabel,
getBackupActivityPointTotalLabel,
getBackupActivitySegmentPresentation,
getBackupActivityTooltipRows,
getBackupActivityUnknownCount,
type BackupActivityMetricMode,
type BackupActivityNoun,
type BackupActivityPoint,
type BackupActivityRangeDays,
type BackupActivitySegmentKind,
} from '../proxmoxBackupActivityPresentation';
import { getProxmoxBackupSourcePresentation } from '../proxmoxBackupSourcePresentation';
const DAY_MS = 24 * 60 * 60 * 1000;
// Anchor "now" at a February date so the window never crosses a DST
// transition (DST never changes in February in either hemisphere). Every
// timestamp below is built with the local Date constructor, matching the
// module's local-day bucketing, so the assertions are timezone-independent.
// Observe after the same-day mixed-outcome/value fixtures below (up to 14:00).
const NOW = new Date(2026, 1, 13, 15, 30, 0);
const localMs = (year: number, month: number, day: number, hours = 0, minutes = 0): number =>
new Date(year, month, day, hours, minutes, 0).getTime();
const dateKey = (year: number, month: number, day: number): string =>
recoveryDateKeyFromTimestamp(localMs(year, month, day));
interface ActivityItem {
ts?: number;
kind: BackupActivitySegmentKind | null;
bytes?: number;
}
const itemMs = (item: ActivityItem): number | undefined => item.ts;
const classify = (item: ActivityItem): BackupActivitySegmentKind | null => item.kind;
const emptyCounts = (): Record<BackupActivitySegmentKind, number> => ({
archive: 0,
pbs: 0,
ok: 0,
failed: 0,
running: 0,
snapshot: 0,
});
describe('proxmoxBackupActivityPresentation', () => {
describe('BACKUP_ACTIVITY_RANGE_DAYS', () => {
it('exposes the canonical backup activity ranges in ascending order', () => {
expect(BACKUP_ACTIVITY_RANGE_DAYS).toEqual([7, 30, 90, 365]);
});
it.each([...BACKUP_ACTIVITY_RANGE_DAYS])('supports the %s-day range', (days) => {
expect(BACKUP_ACTIVITY_RANGE_DAYS).toContain(days);
});
});
describe('getBackupActivitySegmentPresentation', () => {
it.each([
['archive', 'PVE backup files', 'bg-blue-500', 'bg-blue-500'],
['pbs', 'PBS snapshots', 'bg-cyan-500', 'bg-cyan-500'],
['snapshot', 'Guest snapshots', 'bg-violet-500', 'bg-violet-500'],
['ok', 'OK', 'bg-emerald-500', 'bg-emerald-500'],
['failed', 'Failed', 'bg-red-500', 'bg-red-500'],
['running', 'Running', 'bg-amber-500', 'bg-amber-500'],
])(
'returns the canonical presentation for %s',
(kind, label, segmentClassName, swatchClassName) => {
expect(getBackupActivitySegmentPresentation(kind as BackupActivitySegmentKind)).toEqual({
label,
segmentClassName,
swatchClassName,
});
},
);
it('returns a stable reference for repeated lookups', () => {
expect(getBackupActivitySegmentPresentation('ok')).toBe(
getBackupActivitySegmentPresentation('ok'),
);
});
it('delegates source kinds to the proxmox backup source vocabulary', () => {
for (const kind of ['pbs', 'archive', 'snapshot'] as const) {
const source = getProxmoxBackupSourcePresentation(kind);
const segment = getBackupActivitySegmentPresentation(kind);
expect(segment.label).toBe(source.timelineLabel);
expect(segment.segmentClassName).toBe(source.timelineSegmentClassName);
expect(segment.swatchClassName).toBe(source.timelineSwatchClassName);
}
});
it('returns undefined for an unknown segment kind at runtime', () => {
expect(
getBackupActivitySegmentPresentation('unknown' as BackupActivitySegmentKind),
).toBeUndefined();
});
});
describe('buildBackupActivityTimeline', () => {
it('creates one empty bucket per day in chronological order', () => {
const timeline = buildBackupActivityTimeline(7, [], itemMs, classify, { now: NOW });
expect(timeline.points).toHaveLength(7);
expect(timeline.points.map((point) => point.key)).toEqual([
dateKey(2026, 1, 7),
dateKey(2026, 1, 8),
dateKey(2026, 1, 9),
dateKey(2026, 1, 10),
dateKey(2026, 1, 11),
dateKey(2026, 1, 12),
dateKey(2026, 1, 13),
]);
for (const point of timeline.points) {
expect(point.total).toBe(0);
expect(point.counts).toEqual(emptyCounts());
}
expect(timeline.axisMax).toBe(2);
expect(timeline.labelEvery).toBe(1);
});
it.each<[BackupActivityRangeDays, string, string, number]>([
[7, '2026-02-07', '2026-02-13', 1],
[30, '2026-01-15', '2026-02-13', 5],
[90, '2025-11-16', '2026-02-13', 10],
[365, '2025-02-14', '2026-02-13', 30],
])(
'sizes a %s-day window from %s to %s with labelEvery %s when empty',
(days, firstKey, lastKey, labelEvery) => {
const timeline = buildBackupActivityTimeline(days, [], itemMs, classify, { now: NOW });
expect(timeline.points).toHaveLength(days);
expect(timeline.points.at(0)!.key).toBe(firstKey);
expect(timeline.points.at(-1)!.key).toBe(lastKey);
expect(timeline.axisMax).toBe(2);
expect(timeline.labelEvery).toBe(labelEvery);
},
);
it('keeps bucket keys strictly increasing and unique across long ranges', () => {
const timeline = buildBackupActivityTimeline(365, [], itemMs, classify, { now: NOW });
const keys = timeline.points.map((point) => point.key);
const asTimestamps = keys.map((key) => new Date(`${key}T00:00:00`).getTime());
expect(new Set(keys).size).toBe(keys.length);
for (let i = 1; i < asTimestamps.length; i += 1) {
expect(asTimestamps[i]).toBeGreaterThan(asTimestamps[i - 1]);
}
});
it('buckets items by their local-day timestamp and accumulates per-kind counts', () => {
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok' },
{ ts: localMs(2026, 1, 12, 23, 30), kind: 'failed' },
{ ts: localMs(2026, 1, 7, 0, 0), kind: 'pbs' },
{ ts: localMs(2026, 1, 10, 12, 0), kind: 'archive' },
{ ts: localMs(2026, 1, 10, 18, 0), kind: 'snapshot' },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, { now: NOW });
const byKey = new Map(timeline.points.map((point) => [point.key, point]));
expect(byKey.get(dateKey(2026, 1, 13))!.counts.ok).toBe(1);
expect(byKey.get(dateKey(2026, 1, 13))!.total).toBe(1);
expect(byKey.get(dateKey(2026, 1, 12))!.counts.failed).toBe(1);
expect(byKey.get(dateKey(2026, 1, 7))!.counts.pbs).toBe(1);
const feb10 = byKey.get(dateKey(2026, 1, 10))!;
expect(feb10.counts.archive).toBe(1);
expect(feb10.counts.snapshot).toBe(1);
expect(feb10.total).toBe(2);
});
it('includes the window-start and exactly-now edges but excludes future activity even within today', () => {
const todayStart = localMs(2026, 1, 13);
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 6, 23, 59), kind: 'ok' },
{ ts: localMs(2026, 1, 7, 0, 0), kind: 'ok' },
{ ts: todayStart, kind: 'failed' },
{ ts: NOW.getTime(), kind: 'running' },
{ ts: todayStart + DAY_MS - 1, kind: 'running' },
{ ts: todayStart + DAY_MS, kind: 'ok' },
{ ts: localMs(2026, 1, 14, 12, 0), kind: 'ok' },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, { now: NOW });
const totals = new Map(timeline.points.map((point) => [point.key, point.total]));
expect(totals.get(dateKey(2026, 1, 7))).toBe(1);
expect(totals.get(dateKey(2026, 1, 13))).toBe(2);
expect(
timeline.points.find((point) => point.key === dateKey(2026, 1, 13))!.counts.running,
).toBe(1);
expect(totals.get(dateKey(2026, 1, 6))).toBeUndefined();
expect(totals.get(dateKey(2026, 1, 14))).toBeUndefined();
});
it.each([
['undefined', undefined],
['NaN', Number.NaN],
['Infinity', Number.POSITIVE_INFINITY],
['-Infinity', Number.NEGATIVE_INFINITY],
])('drops items whose timestamp is %s', (_label, ts) => {
const items: ActivityItem[] = [{ ts, kind: 'ok' }];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, { now: NOW });
expect(timeline.points.every((point) => point.total === 0)).toBe(true);
});
it('skips in-window items classified as null without classifying out-of-window items', () => {
const classifySpy = vi.fn((item: ActivityItem) => item.kind);
const getValueSpy = vi.fn(() => 1);
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 6, 12, 0), kind: 'ok' },
{ ts: localMs(2026, 1, 13, 9, 0), kind: null },
{ ts: localMs(2026, 1, 13, 10, 0), kind: 'ok' },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classifySpy, {
now: NOW,
getValue: getValueSpy,
});
expect(classifySpy).toHaveBeenCalledTimes(2);
expect(getValueSpy).toHaveBeenCalledExactlyOnceWith(items[2]);
expect(timeline.points.at(-1)!.total).toBe(1);
});
it('counts one per item when no getValue is supplied', () => {
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok' },
{ ts: localMs(2026, 1, 13, 10, 0), kind: 'ok' },
{ ts: localMs(2026, 1, 13, 11, 0), kind: 'failed' },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, { now: NOW });
expect(timeline.points.at(-1)!.counts.ok).toBe(2);
expect(timeline.points.at(-1)!.counts.failed).toBe(1);
expect(timeline.points.at(-1)!.total).toBe(3);
});
it('keeps known byte totals separate from non-positive/non-finite sizes', () => {
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 1073741824 },
{ ts: localMs(2026, 1, 13, 10, 0), kind: 'failed', bytes: 2147483648 },
{ ts: localMs(2026, 1, 13, 11, 0), kind: 'ok', bytes: 0 },
{ ts: localMs(2026, 1, 13, 12, 0), kind: 'ok', bytes: -100 },
{ ts: localMs(2026, 1, 13, 13, 0), kind: 'ok', bytes: Number.NaN },
{ ts: localMs(2026, 1, 13, 14, 0), kind: 'ok', bytes: Number.POSITIVE_INFINITY },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, {
now: NOW,
getValue: (item) => item.bytes ?? 0,
});
const today = timeline.points.at(-1)!;
expect(today.counts.ok).toBe(1073741824);
expect(today.counts.failed).toBe(2147483648);
expect(today.total).toBe(1073741824 + 2147483648);
expect(today.unknownCounts).toEqual({ ok: 4 });
expect(getBackupActivityUnknownCount(today)).toBe(4);
});
it('retains unknown-only days without inventing byte volume or counting excluded entries', () => {
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 13, 9), kind: 'pbs' },
{ ts: localMs(2026, 1, 13, 10), kind: 'snapshot', bytes: 0 },
{ ts: localMs(2026, 1, 12, 10), kind: 'archive', bytes: 2048 },
{ ts: localMs(2026, 1, 13, 11), kind: null },
{ ts: localMs(2026, 1, 6), kind: 'pbs' },
{ ts: NOW.getTime() + 1, kind: 'pbs' },
{ kind: 'pbs' },
];
const volume = buildBackupActivityTimeline(7, items, itemMs, classify, {
now: NOW,
getValue: (item) => item.bytes ?? 0,
});
expect(volume.points.at(-1)!.total).toBe(0);
expect(volume.points.at(-1)!.unknownCounts).toEqual({ pbs: 1, snapshot: 1 });
expect(
volume.points.reduce((sum, point) => sum + getBackupActivityUnknownCount(point), 0),
).toBe(2);
expect(volume.points.reduce((sum, point) => sum + point.total, 0)).toBe(2048);
const counts = buildBackupActivityTimeline(7, items, itemMs, classify, { now: NOW });
expect(counts.points.reduce((sum, point) => sum + point.total, 0)).toBe(3);
expect(counts.points.every((point) => getBackupActivityUnknownCount(point) === 0)).toBe(true);
});
it('keeps fractional positive values in volume mode', () => {
const items: ActivityItem[] = [
{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 0.5 },
{ ts: localMs(2026, 1, 13, 10, 0), kind: 'ok', bytes: 1.25 },
];
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, {
now: NOW,
getValue: (item) => item.bytes ?? 0,
});
expect(timeline.points.at(-1)!.counts.ok).toBeCloseTo(1.75);
expect(timeline.points.at(-1)!.total).toBeCloseTo(1.75);
});
it.each<[string, ActivityItem[], number]>([
['empty stays at the floor of 2', [], 2],
[
'a max of 1 stays at the floor of 2',
[{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 1 }],
2,
],
['a max of 2 maps to 2', [{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 2 }], 2],
['a max of 5 maps to 5', [{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 5 }], 5],
[
'a max of 6 rounds up to 10',
[{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 6 }],
10,
],
['a max of 50 maps to 50', [{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 50 }], 50],
[
'a max of 100 maps to 100',
[{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 100 }],
100,
],
[
'a max of 1000 maps to 1000',
[{ ts: localMs(2026, 1, 13, 9, 0), kind: 'ok', bytes: 1000 }],
1000,
],
])('axisMax %s', (_label, items, axisMax) => {
const timeline = buildBackupActivityTimeline(7, items, itemMs, classify, {
now: NOW,
getValue: (item) => item.bytes ?? 0,
});
expect(timeline.axisMax).toBe(axisMax);
});
it('defaults `now` to the current wall-clock time', () => {
vi.useFakeTimers();
vi.setSystemTime(new Date(2026, 1, 13, 10, 30, 0));
try {
const timeline = buildBackupActivityTimeline(7, [], itemMs, classify);
expect(timeline.points).toHaveLength(7);
expect(timeline.points.at(0)!.key).toBe('2026-02-07');
expect(timeline.points.at(-1)!.key).toBe('2026-02-13');
} finally {
vi.useRealTimers();
}
});
});
describe('getBackupActivityTooltipRows', () => {
const point = (
overrides: Partial<Record<BackupActivitySegmentKind, number>> & { total?: number },
): BackupActivityPoint => ({
key: '2026-02-13',
total: overrides.total ?? 0,
counts: { ...emptyCounts(), ...overrides },
});
it('omits the percentage when a single kind is requested', () => {
const rows = getBackupActivityTooltipRows(point({ total: 5, ok: 5 }), ['ok']);
expect(rows).toEqual([
{
kind: 'ok',
label: 'OK',
count: 5,
value: '5',
segmentClassName: 'bg-emerald-500',
muted: false,
},
]);
});
it('appends rounded percentages when multiple kinds are requested', () => {
const rows = getBackupActivityTooltipRows(point({ total: 10, ok: 6, failed: 4 }), [
'ok',
'failed',
]);
expect(rows.map((row) => [row.value, row.muted])).toEqual([
['6 (60%)', false],
['4 (40%)', false],
]);
});
it('mutes zero-count kinds and shows no percentage for them', () => {
const rows = getBackupActivityTooltipRows(point({ total: 5, ok: 5 }), ['ok', 'failed']);
expect(rows[0]).toMatchObject({ value: '5 (100%)', muted: false });
expect(rows[1]).toMatchObject({ value: '0', muted: true });
});
it('rounds the displayed count while keeping the raw count field', () => {
const rows = getBackupActivityTooltipRows(point({ total: 3, ok: 2.6 }), ['ok']);
expect(rows[0].count).toBe(2.6);
expect(rows[0].value).toBe('3');
});
it('clamps negative totals and counts to zero', () => {
const rows = getBackupActivityTooltipRows(point({ total: -5, ok: -3, failed: -2 }), [
'ok',
'failed',
]);
expect(rows.map((row) => row.value)).toEqual(['0', '0']);
expect(rows.every((row) => row.count === 0 && row.muted)).toBe(true);
});
it('reads missing count keys as zero', () => {
const partial = {
key: '2026-02-13',
total: 2,
counts: { ok: 2 },
} as unknown as BackupActivityPoint;
const rows = getBackupActivityTooltipRows(partial, ['ok', 'failed']);
expect(rows[1].count).toBe(0);
expect(rows[1].muted).toBe(true);
});
it('returns no rows for an empty kind list', () => {
expect(getBackupActivityTooltipRows(point({ total: 5, ok: 5 }), [])).toEqual([]);
});
it('formats volume-mode values as bytes with percentages', () => {
const rows = getBackupActivityTooltipRows(
point({ total: 3221225472, ok: 1073741824, failed: 2147483648 }),
['ok', 'failed'],
'volume',
);
expect(rows[0].value).toBe('1.00 GB (33%)');
expect(rows[1].value).toBe('2.00 GB (67%)');
});
it('formats a single volume-mode row without a percentage', () => {
const rows = getBackupActivityTooltipRows(
point({ total: 1073741824, ok: 1073741824 }),
['ok'],
'volume',
);
expect(rows[0].value).toBe('1.00 GB');
});
it('shows 0 B for zero-count volume rows', () => {
const rows = getBackupActivityTooltipRows(point({}), ['ok'], 'volume');
expect(rows[0].value).toBe('0 B');
expect(rows[0].muted).toBe(true);
});
it('defaults to count mode when mode is omitted', () => {
expect(getBackupActivityTooltipRows(point({ total: 1, ok: 1 }), ['ok'])[0].value).toBe('1');
});
});
describe('getBackupActivityPointTotalLabel', () => {
it('never presents unavailable sizes as a zero or a complete volume', () => {
expect(getBackupActivityPointTotalLabel(0, 'restore point', 'volume', 1)).toBe(
'1 size unknown',
);
expect(getBackupActivityPointTotalLabel(1024, 'restore point', 'volume', 2)).toBe(
'1.00 KB known · 2 sizes unknown',
);
expect(getBackupActivityPointTotalLabel(3, 'restore point', 'count', 2)).toBe(
'3 restore points',
);
expect(
getBackupActivityColumnAriaLabel('Feb 13', 0, true, 'restore point', 'volume', 2),
).toBe('Feb 13: 2 sizes unknown, selected');
});
it('does not give unknown-only sources zero or partial-byte sources exact percentages', () => {
const point: BackupActivityPoint = {
key: '2026-02-13',
total: 3072,
counts: { ...emptyCounts(), pbs: 2048, archive: 1024 },
unknownCounts: { archive: 1, snapshot: 1 },
};
const rows = getBackupActivityTooltipRows(point, ['pbs', 'archive', 'snapshot'], 'volume');
expect(rows.map((row) => row.value)).toEqual(['2.00 KB', '≥ 1.00 KB', 'Unknown size']);
expect(rows.every((row) => !row.muted)).toBe(true);
expect(getBackupActivityTooltipRows(point, ['snapshot'], 'count')[0].value).toBe('0');
});
it.each([
[0, 'backup', '0 backups'],
[1, 'backup', '1 backup'],
[2, 'backup', '2 backups'],
[1, 'restore point', '1 restore point'],
[3, 'restore point', '3 restore points'],
[1, 'snapshot', '1 snapshot'],
[5, 'task', '5 tasks'],
[2, 'archive', '2 archives'],
[-3, 'backup', '0 backups'],
[2.6, 'backup', '3 backups'],
[2.4, 'backup', '2 backups'],
])('count mode: total %s %s -> %s', (total, noun, expected) => {
expect(getBackupActivityPointTotalLabel(total, noun as BackupActivityNoun)).toBe(expected);
});
it.each([
[0, '0 B'],
[1073741824, '1.00 GB'],
[2147483648, '2.00 GB'],
[-5, '0 B'],
])('volume mode: total %s -> %s', (total, expected) => {
expect(getBackupActivityPointTotalLabel(total, 'backup', 'volume')).toBe(expected);
});
it('defaults to count mode when mode is omitted', () => {
expect(getBackupActivityPointTotalLabel(1, 'backup')).toBe('1 backup');
});
});
describe('getBackupActivityColumnAriaLabel', () => {
it.each([
['Feb 13, 2026', 5, false, 'backup', 'Feb 13, 2026: 5 backups'],
['Feb 13, 2026', 5, true, 'backup', 'Feb 13, 2026: 5 backups, selected'],
['Feb 13, 2026', 1, false, 'snapshot', 'Feb 13, 2026: 1 snapshot'],
['Feb 13, 2026', 0, true, 'backup', 'Feb 13, 2026: 0 backups, selected'],
])('builds aria label for %s/%s/%s/%s', (dateLabel, total, selected, noun, expected) => {
expect(
getBackupActivityColumnAriaLabel(dateLabel, total, selected, noun as BackupActivityNoun),
).toBe(expected);
});
it('formats volume totals in the aria label', () => {
expect(
getBackupActivityColumnAriaLabel('Feb 13, 2026', 1073741824, false, 'backup', 'volume'),
).toBe('Feb 13, 2026: 1.00 GB');
});
});
describe('getBackupActivityAxisLabel', () => {
it.each([
[0, 'count', '0'],
[1, 'count', '1'],
[2.6, 'count', '3'],
[100, 'count', '100'],
[-5, 'count', '0'],
])('count axis label for %s is %s', (value, mode, expected) => {
expect(getBackupActivityAxisLabel(value, mode as BackupActivityMetricMode)).toBe(expected);
});
it.each([
[0, '0 B'],
[1073741824, '1.00 GB'],
[-5, '0 B'],
])('volume axis label for %s is %s', (value, expected) => {
expect(getBackupActivityAxisLabel(value, 'volume')).toBe(expected);
});
});
describe('getBackupActivityDayFilterStateLabel', () => {
it.each([
[true, true, 'Day filter'],
[false, true, 'Outside day filter'],
[false, false, 'Timeline day'],
[true, false, 'Day filter'],
])('selected=%s hasDayFilter=%s -> %s', (selected, hasDayFilter, expected) => {
expect(getBackupActivityDayFilterStateLabel(selected, hasDayFilter)).toBe(expected);
});
it('is a re-export of the recovery timeline day filter state label', () => {
expect(getBackupActivityDayFilterStateLabel).toBe(getRecoveryTimelineDayFilterStateLabel);
});
});
});
describe('backup-date-evidence timeline', () => {
it.each(['count', 'volume'] as const)(
'[regression] does not count future same-day activity in %s mode',
(mode) => {
const now = new Date('2026-10-04T12:00:00Z');
const timeline = buildBackupActivityTimeline(
7,
[
{ ts: now.getTime() - 1000, kind: 'pbs' as const, bytes: 2 },
{ ts: now.getTime() + 1000, kind: 'pbs' as const, bytes: 5 },
],
itemMs,
classify,
{ now, getValue: mode === 'volume' ? (item) => item.bytes ?? 0 : undefined },
);
expect(timeline.points.reduce((total, point) => total + point.total, 0)).toBe(
mode === 'volume' ? 2 : 1,
);
},
);
it('[control] counts exactly observed now and leaves invalid/unavailable dates out', () => {
const now = new Date('2026-10-04T12:00:00Z');
const timeline = buildBackupActivityTimeline(
7,
[
{ ts: now.getTime(), kind: 'pbs' as const },
{ ts: NaN, kind: 'pbs' as const },
{ ts: undefined, kind: 'pbs' as const },
],
itemMs,
classify,
{ now },
);
expect(timeline.points.reduce((total, point) => total + point.total, 0)).toBe(1);
});
});
// These dates deliberately cross clock changes, unlike the stable February
// fixtures above. Each test restores TZ before the next one and runs under the
// repository's ordinary test command, not a separately maintained proof script.
describe('backup activity uses local calendar days across clock changes', () => {
const cases = [
['Europe/London', '2026-03-30T23:45:00'],
['Europe/London', '2026-10-25T23:45:00'],
['Europe/London', '2026-10-26T23:45:00'],
['America/New_York', '2026-03-09T23:45:00'],
['America/New_York', '2026-11-01T23:45:00'],
['America/New_York', '2026-11-02T23:45:00'],
['Australia/Lord_Howe', '2026-04-05T23:45:00'],
['Australia/Lord_Howe', '2026-04-06T23:45:00'],
['Australia/Lord_Howe', '2026-10-05T23:45:00'],
['UTC', '2026-10-26T23:45:00'],
['Asia/Kolkata', '2026-10-26T23:45:00'],
] as const;
for (const [zone, localNow] of cases) {
it.each([...BACKUP_ACTIVITY_RANGE_DAYS])(
`${zone} at ${localNow} has exactly %s local days and includes both boundaries`,
(days) => {
vi.stubEnv('TZ', zone);
try {
const now = new Date(localNow);
// Use UTC only as an independent calendar-date oracle. The product
// must still classify actual instants in the operator's local zone.
const calendarDay = (offset: number) =>
new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate() + offset))
.toISOString()
.slice(0, 10);
const expectedKeys = Array.from({ length: days }, (_, i) => calendarDay(i - days + 1));
const dayMs = (offset: number, hours: number, minutes = 0) =>
new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + offset,
hours,
minutes,
).getTime();
const items: ActivityItem[] = [
...Array.from({ length: days }, (_, i) => ({
ts: dayMs(i - days + 1, 12),
kind: 'archive' as const,
bytes: 1024,
})),
// The first quarter hour of the oldest day must not disappear
// after a backward clock change (including a half-hour change).
{ ts: dayMs(1 - days, 0, 15), kind: 'pbs', bytes: 2048 },
{ ts: now.getTime(), kind: 'snapshot', bytes: 4096 },
{ ts: dayMs(-days, 23, 59), kind: 'pbs', bytes: 8192 },
{ ts: now.getTime() + 1, kind: 'snapshot', bytes: 8192 },
{ kind: 'archive', bytes: 8192 },
];
for (const mode of ['count', 'volume'] as const) {
const timeline = buildBackupActivityTimeline(days, items, itemMs, classify, {
now,
getValue: mode === 'volume' ? (item) => item.bytes ?? 0 : undefined,
});
expect(timeline.points.map((point) => point.key)).toEqual(expectedKeys);
expect(new Set(timeline.points.map((point) => point.key)).size).toBe(days);
expect(
timeline.points.every(
(point) => point.counts.archive === (mode === 'volume' ? 1024 : 1),
),
).toBe(true);
expect(timeline.points[0].counts.pbs).toBe(mode === 'volume' ? 2048 : 1);
expect(timeline.points.at(-1)!.counts.snapshot).toBe(mode === 'volume' ? 4096 : 1);
expect(timeline.points.reduce((total, point) => total + point.total, 0)).toBe(
mode === 'volume' ? days * 1024 + 2048 + 4096 : days + 2,
);
}
} finally {
vi.unstubAllEnvs();
}
},
);
}
});
@@ -119,11 +119,6 @@ describe('restore-point identity without hover', () => {
expect(created).toHaveTextContent('2026');
} else {
expect(created).toHaveTextContent('Unknown');
const notice = screen.getByText(
/Backup entries with unavailable or future dates remain listed/,
);
expect(notice).toHaveTextContent('Their ages are unknown.');
expect(notice).toHaveTextContent('excluded from the activity chart and day filters');
}
expect(panel.querySelector('img')).toBeNull();
}
@@ -1,231 +0,0 @@
import { formatBytes } from '@/utils/format';
import {
getRecoveryNiceAxisMax,
recoveryDateKeyFromTimestamp,
} from '@/utils/recoveryDatePresentation';
import { getRecoveryTimelineLabelEvery } from '@/utils/recoveryTimelineChartPresentation';
import { getRecoveryTimelineDayFilterStateLabel } from '@/utils/recoveryTimelinePresentation';
import { getProxmoxBackupSourcePresentation } from './proxmoxBackupSourcePresentation';
export type BackupActivityRangeDays = 7 | 30 | 90 | 365;
export const BACKUP_ACTIVITY_RANGE_DAYS = [
7, 30, 90, 365,
] as const satisfies readonly BackupActivityRangeDays[];
// count accumulates one item per day; volume accumulates bytes per day.
export type BackupActivityMetricMode = 'count' | 'volume';
export type BackupActivitySegmentKind =
'archive' | 'pbs' | 'ok' | 'failed' | 'running' | 'snapshot';
interface BackupActivitySegmentPresentation {
label: string;
segmentClassName: string;
swatchClassName: string;
}
const SEGMENT_PRESENTATION: Record<BackupActivitySegmentKind, BackupActivitySegmentPresentation> = {
archive: {
label: getProxmoxBackupSourcePresentation('archive').timelineLabel,
segmentClassName: getProxmoxBackupSourcePresentation('archive').timelineSegmentClassName,
swatchClassName: getProxmoxBackupSourcePresentation('archive').timelineSwatchClassName,
},
pbs: {
label: getProxmoxBackupSourcePresentation('pbs').timelineLabel,
segmentClassName: getProxmoxBackupSourcePresentation('pbs').timelineSegmentClassName,
swatchClassName: getProxmoxBackupSourcePresentation('pbs').timelineSwatchClassName,
},
ok: {
label: 'OK',
segmentClassName: 'bg-emerald-500',
swatchClassName: 'bg-emerald-500',
},
failed: {
label: 'Failed',
segmentClassName: 'bg-red-500',
swatchClassName: 'bg-red-500',
},
running: {
label: 'Running',
segmentClassName: 'bg-amber-500',
swatchClassName: 'bg-amber-500',
},
snapshot: {
label: getProxmoxBackupSourcePresentation('snapshot').timelineLabel,
segmentClassName: getProxmoxBackupSourcePresentation('snapshot').timelineSegmentClassName,
swatchClassName: getProxmoxBackupSourcePresentation('snapshot').timelineSwatchClassName,
},
};
export function getBackupActivitySegmentPresentation(
kind: BackupActivitySegmentKind,
): BackupActivitySegmentPresentation {
return SEGMENT_PRESENTATION[kind];
}
export interface BackupActivityPoint {
key: string;
total: number;
counts: Record<BackupActivitySegmentKind, number>;
/** In-window completed entries without a positive finite metric value. Not zero volume. */
unknownCounts?: Partial<Record<BackupActivitySegmentKind, number>>;
}
export function getBackupActivityUnknownCount(point: BackupActivityPoint): number {
return Object.values(point.unknownCounts ?? {}).reduce((sum, count) => sum + count, 0);
}
export interface BackupActivityTimeline {
points: BackupActivityPoint[];
axisMax: number;
labelEvery: number;
}
function emptyCounts(): Record<BackupActivitySegmentKind, number> {
return { archive: 0, pbs: 0, ok: 0, failed: 0, running: 0, snapshot: 0 };
}
export function buildBackupActivityTimeline<T>(
days: BackupActivityRangeDays,
items: readonly T[],
getTimestampMs: (item: T) => number | undefined,
classify: (item: T) => BackupActivitySegmentKind | null,
options?: {
now?: Date;
// Per-item contribution to the bucket total. Defaults to count mode.
getValue?: (item: T) => number;
},
): BackupActivityTimeline {
const now = options?.now ?? new Date();
const getValue = options?.getValue ?? (() => 1);
const buckets = new Map<string, BackupActivityPoint>();
const orderedKeys: string[] = [];
for (let i = 0; i < days; i += 1) {
// Labels and day filters are local calendar dates, not 24-hour intervals.
// Construct each date independently so clock changes cannot skip a date,
// duplicate a bucket or exclude the oldest day's first hour.
const day = new Date(now.getFullYear(), now.getMonth(), now.getDate() - days + 1 + i);
const key = recoveryDateKeyFromTimestamp(day.getTime());
orderedKeys.push(key);
buckets.set(key, { key, total: 0, counts: emptyCounts() });
}
for (const item of items) {
const ts = getTimestampMs(item);
if (ts === undefined || !Number.isFinite(ts)) continue;
// A future time on today's date is still not observed past activity.
if (ts > now.getTime()) continue;
const key = recoveryDateKeyFromTimestamp(ts);
// Membership in the calendar window includes the entire first local day
// and today's observed hours even when a day lasts 23, 25 or 24.5 hours.
const bucket = buckets.get(key);
if (!bucket) continue;
const kind = classify(item);
if (!kind) continue;
const value = getValue(item);
if (!Number.isFinite(value) || value <= 0) {
bucket.unknownCounts ??= {};
bucket.unknownCounts[kind] = (bucket.unknownCounts[kind] ?? 0) + 1;
continue;
}
bucket.counts[kind] += value;
bucket.total += value;
}
const points = orderedKeys.map((key) => buckets.get(key)!);
const rawMax = points.reduce((max, p) => (p.total > max ? p.total : max), 0);
const axisMax = Math.max(2, getRecoveryNiceAxisMax(rawMax));
const labelEvery = getRecoveryTimelineLabelEvery(points.length);
return { points, axisMax, labelEvery };
}
export interface BackupActivityTooltipRow {
kind: BackupActivitySegmentKind;
label: string;
count: number;
value: string;
segmentClassName: string;
muted: boolean;
}
export type BackupActivityNoun =
'archive' | 'artifact' | 'backup' | 'task' | 'snapshot' | 'restore point';
function formatActivityValue(value: number, mode: BackupActivityMetricMode): string {
if (mode === 'volume') return formatBytes(Math.max(0, value));
return String(Math.max(0, Math.round(value)));
}
export function getBackupActivityTooltipRows(
point: BackupActivityPoint,
kinds: readonly BackupActivitySegmentKind[],
mode: BackupActivityMetricMode = 'count',
): BackupActivityTooltipRow[] {
const total = Math.max(0, point.total);
return kinds.map((kind) => {
const presentation = SEGMENT_PRESENTATION[kind];
const count = Math.max(0, point.counts[kind] ?? 0);
const unknown = mode === 'volume' ? (point.unknownCounts?.[kind] ?? 0) : 0;
const percentage = total > 0 && count > 0 ? Math.round((count / total) * 100) : 0;
const formatted = formatActivityValue(count, mode);
return {
kind,
label: presentation.label,
count,
value:
unknown > 0
? count > 0
? `≥ ${formatted}`
: 'Unknown size'
: percentage > 0 &&
kinds.length > 1 &&
!(mode === 'volume' && getBackupActivityUnknownCount(point) > 0)
? `${formatted} (${percentage}%)`
: formatted,
segmentClassName: presentation.segmentClassName,
muted: count === 0 && unknown === 0,
};
});
}
export function getBackupActivityPointTotalLabel(
total: number,
noun: BackupActivityNoun,
mode: BackupActivityMetricMode = 'count',
unknownCount = 0,
): string {
if (mode === 'volume') {
if (unknownCount > 0) {
const unknown = `${unknownCount} ${unknownCount === 1 ? 'size' : 'sizes'} unknown`;
return total > 0 ? `${formatBytes(total)} known · ${unknown}` : unknown;
}
return formatBytes(Math.max(0, total));
}
const normalized = Math.max(0, Math.round(total));
if (normalized === 1) return `1 ${noun}`;
return `${normalized} ${noun}s`;
}
export function getBackupActivityColumnAriaLabel(
dateLabel: string,
total: number,
selected: boolean,
noun: BackupActivityNoun,
mode: BackupActivityMetricMode = 'count',
unknownCount = 0,
): string {
const countLabel = getBackupActivityPointTotalLabel(total, noun, mode, unknownCount);
return selected ? `${dateLabel}: ${countLabel}, selected` : `${dateLabel}: ${countLabel}`;
}
export function getBackupActivityAxisLabel(value: number, mode: BackupActivityMetricMode): string {
if (mode === 'volume') return formatBytes(Math.max(0, value));
return String(Math.max(0, Math.round(value)));
}
export { getRecoveryTimelineDayFilterStateLabel as getBackupActivityDayFilterStateLabel };
@@ -45,12 +45,9 @@ async function openProxmoxBackups(page: Page) {
// The route commits before the Proxmox snapshot finishes loading. CI can
// take more than a minute while all E2E shards share the runner, so wait for
// the destination surface rather than the URL alone.
await expect(
page.getByText("Completed restore points per day", { exact: true }),
).toBeVisible({ timeout: 120_000 });
await expect(page.getByRole("group", { name: "Activity range" })).toBeVisible(
{ timeout: 60_000 },
);
await expect(page.getByText(/^\d+ backup entries$/).first()).toBeVisible({
timeout: 120_000,
});
}
// Layout guards for the Proxmox Backups section, which replaced the retired
@@ -59,7 +56,7 @@ async function openProxmoxBackups(page: Page) {
test.describe("Proxmox backups layout guards", () => {
test.setTimeout(180_000);
test("activity day selection filters the backups table in place", async ({
test("the Backups page stays inside the horizontal viewport", async ({
page,
}, testInfo) => {
test.skip(
@@ -72,62 +69,7 @@ test.describe("Proxmox backups layout guards", () => {
await skipUnlessManagedRuntimeIsMock(page);
await openProxmoxBackups(page);
// The Backups section now opens the date view directly.
// The chart counts completed restore points, while the inventory keeps
// running and failed backup entries available for inspection.
const dayButtons = page.getByRole("button", {
name: /: \d+ restore points?$/,
});
await expect.poll(() => dayButtons.count()).toBeGreaterThanOrEqual(7);
const totalCopy = page.getByText(/^\d+ backup entries$/).first();
await expect(totalCopy).toBeVisible();
const unfilteredCount = await totalCopy.innerText();
// Picking a day narrows the table without navigating away.
const activeDay = page
.getByRole("button", { name: /: [1-9]\d* restore points?$/ })
.last();
await activeDay.click();
await expect(
page.getByRole("button", { name: /: [1-9]\d* restore points?, selected$/ }),
).toHaveAttribute("aria-pressed", "true");
await expect(page).toHaveURL(/\/proxmox\/backups/);
await expect(
page.getByText(/^\d+ of \d+ backup entries$/).first(),
).toBeVisible();
await page
.getByRole("button", { name: "Clear date filter", exact: true })
.click();
await expect(totalCopy).toHaveText(unfilteredCount);
});
test("long-range activity keeps the page inside the horizontal viewport", async ({
page,
}, testInfo) => {
test.skip(
testInfo.project.name.startsWith("mobile-"),
"Desktop-only backups layout coverage",
);
await page.setViewportSize(DESKTOP_VIEWPORT);
await ensureAuthenticated(page);
await skipUnlessManagedRuntimeIsMock(page);
await openProxmoxBackups(page);
await page
.getByRole("group", { name: "Activity range" })
.getByRole("button", { name: "1y" })
.click();
const dayButtons = page.getByRole("button", {
name: /: \d+ restore points?$/,
});
await expect.poll(() => dayButtons.count()).toBe(365);
// A year of bars must stay contained: the chart may scroll internally but
// the page itself must not overflow horizontally.
// The page itself must not overflow horizontally.
const pageOverflow = await page.evaluate(() => ({
scrollWidth: document.documentElement.scrollWidth,
clientWidth: document.documentElement.clientWidth,