Commit 1cf394e9 authored by Simon Knox's avatar Simon Knox

Merge branch 'fix-geo-zero-truthy' into 'master'

Geo Statuses - Fix empty section bug

See merge request gitlab-org/gitlab!40443
parents deb0a4ea f11e36d2
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 {
......
---
title: Geo Statuses - Fix empty section bug
merge_request: 40443
author:
type: fixed
......@@ -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);
});
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment