Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix race in mock mode and address frontend type checks

rcourtman61b492e93b4a
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index c0b84a0a61..36c838ecd1 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -12,11 +12,11 @@ import {
pathForTab,
tabFromPath,
} from '../Alerts';
+import type { RawOverrideConfig } from '@/types/alerts';
describe('normalizeMetricDelayMap', () => {
it('returns empty object when input is nullish', () => {
expect(normalizeMetricDelayMap(undefined)).toEqual({});
- // @ts-expect-error - testing runtime null handling
expect(normalizeMetricDelayMap(null)).toEqual({});
});
@@ -139,17 +139,19 @@ describe('threshold helper utilities', () => {
it('extracts trigger values and ignores non-threshold keys', () => {
const result = extractTriggerValues({
cpu: { trigger: 80, clear: 70 },
- memory: 85,
+ memory: { trigger: 85, clear: 75 },
disabled: true,
poweredOffSeverity: 'warning',
- networkIn: false,
+ customFlag: true,
+ customLegacy: 42,
label: 'ignored',
- });
+ } as RawOverrideConfig);
expect(result).toEqual({
cpu: 80,
memory: 85,
- networkIn: 0,
+ customFlag: 0,
+ customLegacy: 42,
});
});
diff --git a/internal/mock/integration.go b/internal/mock/integration.go
index c48d4b7753..8205873637 100644
--- a/internal/mock/integration.go
+++ b/internal/mock/integration.go
@@ -120,29 +120,31 @@ func disableMockMode() {
func startUpdateLoopLocked() {
stopUpdateLoopLocked()
- stopUpdatesCh = make(chan struct{})
- updateTicker = time.NewTicker(updateInterval)
+ stopCh := make(chan struct{})
+ ticker := time.NewTicker(updateInterval)
+ stopUpdatesCh = stopCh
+ updateTicker = ticker
- go func() {
+ go func(stop <-chan struct{}, tick *time.Ticker) {
for {
select {
- case <-updateTicker.C:
+ case <-tick.C:
cfg := GetConfig()
updateMetrics(cfg)
- case <-stopUpdatesCh:
+ case <-stop:
return
}
}
- }()
+ }(stopCh, ticker)
}
func stopUpdateLoopLocked() {
- if updateTicker != nil {
- updateTicker.Stop()
+ if ticker := updateTicker; ticker != nil {
+ ticker.Stop()
updateTicker = nil
}
- if stopUpdatesCh != nil {
- close(stopUpdatesCh)
+ if ch := stopUpdatesCh; ch != nil {
+ close(ch)
stopUpdatesCh = nil
}
}