π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π Fixes bug in continous status check rounding if less than 5
Alicia Sykesc38f4a4d47bf
diff --git a/src/mixins/ItemMixin.js b/src/mixins/ItemMixin.jsindex 26b601e4..51d39e11 100644--- a/src/mixins/ItemMixin.js+++ b/src/mixins/ItemMixin.js@@ -83,8 +83,8 @@ export default {if (!interval) interval = this.appConfig.pingCheckInterval;if (!interval) return 0;interval = Math.floor(interval);- if (interval < 0) interval = 0;- if (interval > 5) interval = 5;+ if (interval < 1) return 0;+ if (interval < 5) interval = 5;return interval;},/* Determine the number of ping icmp packets to send per check */@@ -99,10 +99,10 @@ export default {},/* Determine delay in milliseconds for a ping check to complete */pingCheckTimeout() {+ const maxTimeout = this.pingCheckCount * 1000;let timeout = this.item.pingCheckTimeout;if (!timeout) timeout = this.appConfig.pingCheckTimeout;- if (!timeout) return this.pingCheckInterval * 1000;- let maxTimeout = this.pingCheckCount * 1000;+ if (!timeout) return Math.min(this.pingCheckInterval * 1000, maxTimeout);if (timeout > maxTimeout) timeout = maxTimeout;if (timeout < 1) timeout = 0;return timeout;diff --git a/tests/components/item.test.js b/tests/components/item.test.jsindex 484fa486..b5e9bb43 100644--- a/tests/components/item.test.js+++ b/tests/components/item.test.js@@ -284,30 +284,39 @@ describe('Computed: pingCheckInterval', () => {it('reads from item', () => {const { wrapper } = mountItem({item: {- id: '1', title: 'X', url: '#', pingCheckInterval: 3,+ id: '1', title: 'X', url: '#', pingCheckInterval: 8,},});- expect(wrapper.vm.pingCheckInterval).toBe(3);+ expect(wrapper.vm.pingCheckInterval).toBe(8);});it('falls back to appConfig', () => {const { wrapper } = mountItem({item: { id: '1', title: 'X', url: '#' },- appConfig: { pingCheckInterval: 4 },+ appConfig: { pingCheckInterval: 20 },});- expect(wrapper.vm.pingCheckInterval).toBe(4);+ expect(wrapper.vm.pingCheckInterval).toBe(20);});- it('clamps to max 5', () => {+ it('does not cap large intervals', () => {const { wrapper } = mountItem({item: {- id: '1', title: 'X', url: '#', pingCheckInterval: 15,+ id: '1', title: 'X', url: '#', pingCheckInterval: 60,+ },+ });+ expect(wrapper.vm.pingCheckInterval).toBe(60);+ });++ it('clamps to a minimum of 5', () => {+ const { wrapper } = mountItem({+ item: {+ id: '1', title: 'X', url: '#', pingCheckInterval: 3,},});expect(wrapper.vm.pingCheckInterval).toBe(5);});- it('clamps values less than 1 to 0', () => {+ it('treats values below 1 as only-on-load (0)', () => {const { wrapper } = mountItem({item: {id: '1', title: 'X', url: '#', pingCheckInterval: 0.5,@@ -317,6 +326,27 @@ describe('Computed: pingCheckInterval', () => {});});+describe('Computed: pingCheckTimeout', () => {+ it('caps the interval-derived default at pingCheckCount * 1000', () => {+ const { wrapper } = mountItem({+ item: {+ id: '1', title: 'X', url: '#', pingCheckInterval: 60,+ },+ });+ // count defaults to 3, so the default timeout is capped at 3000ms, not 60000ms+ expect(wrapper.vm.pingCheckTimeout).toBe(3000);+ });++ it('clamps an explicit timeout to pingCheckCount * 1000', () => {+ const { wrapper } = mountItem({+ item: {+ id: '1', title: 'X', url: '#', pingCheckCount: 2, pingCheckTimeout: 99000,+ },+ });+ expect(wrapper.vm.pingCheckTimeout).toBe(2000);+ });+});+describe('Computed: accumulatedTarget', () => {it('uses item.target first', () => {const { wrapper } = mountItem({