diff --git a/ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js b/ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js index 78686a2d2c4b6cad0b515a60be58f9e1393cd580..b5acf651e1b24f05d44c33c7d704b2cfc9f3732c 100644 --- a/ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js +++ b/ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js @@ -1,3 +1,5 @@ +import { isNil } from 'lodash'; + export default class GeoNodesStore { constructor(primaryVersion, primaryRevision, replicableTypes) { this.state = {}; @@ -84,11 +86,17 @@ export default class GeoNodesStore { }; }); + // Adds replicable to array as long as value is defined const verificationStatuses = syncStatuses.filter(s => - Boolean(s.itemValue.verificationSuccessCount || s.itemValue.verificationFailureCount), + Boolean( + !isNil(s.itemValue.verificationSuccessCount) || + !isNil(s.itemValue.verificationFailureCount), + ), ); + + // Adds replicable to array as long as value is defined const checksumStatuses = syncStatuses.filter(s => - Boolean(s.itemValue.checksumSuccessCount || s.itemValue.checksumFailureCount), + Boolean(!isNil(s.itemValue.checksumSuccessCount) || !isNil(s.itemValue.checksumFailureCount)), ); return { diff --git a/ee/changelogs/unreleased/fix-geo-zero-truthy.yml b/ee/changelogs/unreleased/fix-geo-zero-truthy.yml new file mode 100644 index 0000000000000000000000000000000000000000..e67b28240733f0b5c1fa1fe3bb16dbdd66599e6c --- /dev/null +++ b/ee/changelogs/unreleased/fix-geo-zero-truthy.yml @@ -0,0 +1,5 @@ +--- +title: Geo Statuses - Fix empty section bug +merge_request: 40443 +author: +type: fixed diff --git a/ee/spec/frontend/geo_nodes/store/geo_nodes_store_spec.js b/ee/spec/frontend/geo_nodes/store/geo_nodes_store_spec.js index bdd180b8488d0d382f3b741cc079361061ad2133..c463f3827a5e8eea6e8edd305404a0faeaf7efe4 100644 --- a/ee/spec/frontend/geo_nodes/store/geo_nodes_store_spec.js +++ b/ee/spec/frontend/geo_nodes/store/geo_nodes_store_spec.js @@ -85,5 +85,47 @@ describe('GeoNodesStore', () => { expect(syncStatusNames).toEqual(replicableTypesNames); }); + + describe.each` + description | hasReplicable | mockVerificationDetails + ${'null values'} | ${false} | ${{ test_type_count: null, test_type_verified_count: null, test_type_verification_failed_count: null }} + ${'string values'} | ${true} | ${{ test_type_count: '10', test_type_verified_count: '5', test_type_verification_failed_count: '5' }} + ${'number values'} | ${true} | ${{ test_type_count: 10, test_type_verified_count: 5, test_type_verification_failed_count: 5 }} + ${'0 string values'} | ${true} | ${{ test_type_count: '0', test_type_verified_count: '0', test_type_verification_failed_count: '0' }} + ${'0 number values'} | ${true} | ${{ test_type_count: 0, test_type_verified_count: 0, test_type_verification_failed_count: 0 }} + `(`verificationStatuses`, ({ description, hasReplicable, mockVerificationDetails }) => { + describe(`when node verification details contains ${description}`, () => { + it(`does ${hasReplicable ? '' : 'not'} contain replicable test_type`, () => { + const nodeDetails = GeoNodesStore.formatNodeDetails(mockVerificationDetails, [ + { namePlural: 'test_type' }, + ]); + + expect( + nodeDetails.verificationStatuses.some(({ namePlural }) => namePlural === 'test_type'), + ).toBe(hasReplicable); + }); + }); + }); + + describe.each` + description | hasReplicable | mockChecksumDetails + ${'null values'} | ${false} | ${{ test_type_count: null, test_type_checksummed_count: null, test_type_checksum_failed_count: null }} + ${'string values'} | ${true} | ${{ test_type_count: '10', test_type_checksummed_count: '5', test_type_checksum_failed_count: '5' }} + ${'number values'} | ${true} | ${{ test_type_count: 10, test_type_checksummed_count: 5, test_type_checksum_failed_count: 5 }} + ${'0 string values'} | ${true} | ${{ test_type_count: '0', test_type_checksummed_count: '0', test_type_checksum_failed_count: '0' }} + ${'0 number values'} | ${true} | ${{ test_type_count: 0, test_type_checksummed_count: 0, test_type_checksum_failed_count: 0 }} + `(`checksumStatuses`, ({ description, hasReplicable, mockChecksumDetails }) => { + describe(`when node checksum details contains ${description}`, () => { + it(`does ${hasReplicable ? '' : 'not'} contain replicable test_type`, () => { + const nodeDetails = GeoNodesStore.formatNodeDetails(mockChecksumDetails, [ + { namePlural: 'test_type' }, + ]); + + expect( + nodeDetails.checksumStatuses.some(({ namePlural }) => namePlural === 'test_type'), + ).toBe(hasReplicable); + }); + }); + }); }); });