From f11e36d21264c67ce47451b1f5dd00c08131aeda Mon Sep 17 00:00:00 2001 From: Zack Cuddy <zcuddy@gitlab.com> Date: Mon, 31 Aug 2020 00:23:46 +0000 Subject: [PATCH] Geo Statuses - Fix empty section bug There was an issue when there was NOTHING to show that it would omit the progress bars. This was not the desired behavior, we instead want to show the queued jobs. --- .../geo_nodes/store/geo_nodes_store.js | 12 +++++- .../unreleased/fix-geo-zero-truthy.yml | 5 +++ .../geo_nodes/store/geo_nodes_store_spec.js | 42 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 ee/changelogs/unreleased/fix-geo-zero-truthy.yml 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 78686a2d2c4b6..b5acf651e1b24 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 0000000000000..e67b28240733f --- /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 bdd180b8488d0..c463f3827a5e8 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); + }); + }); + }); }); }); -- GitLab