Merge "Submit Requirements - undefined value in approvalinfo is neutral status"
diff --git a/polygerrit-ui/app/utils/label-util.ts b/polygerrit-ui/app/utils/label-util.ts
index a8a2719..918d2ab 100644
--- a/polygerrit-ui/app/utils/label-util.ts
+++ b/polygerrit-ui/app/utils/label-util.ts
@@ -94,7 +94,7 @@
label: DetailedLabelInfo,
approvalInfo?: ApprovalInfo
) {
- if (!approvalInfo) return true;
+ if (approvalInfo?.value === undefined) return true;
return getLabelStatus(label, approvalInfo.value) === LabelStatus.NEUTRAL;
}
diff --git a/polygerrit-ui/app/utils/label-util_test.ts b/polygerrit-ui/app/utils/label-util_test.ts
index 1004aac..9360688 100644
--- a/polygerrit-ui/app/utils/label-util_test.ts
+++ b/polygerrit-ui/app/utils/label-util_test.ts
@@ -24,6 +24,7 @@
getRepresentativeValue,
getVotingRange,
getVotingRangeOrDefault,
+ hasNeutralStatus,
labelCompare,
LabelStatus,
} from './label-util';
@@ -193,6 +194,15 @@
assert.equal(getLabelStatus(labelInfo), LabelStatus.NEUTRAL);
});
+ test('hasNeutralStatus', () => {
+ const labelInfo: DetailedLabelInfo = {all: [], values: VALUES_2};
+ assert.isTrue(hasNeutralStatus(labelInfo));
+ assert.isTrue(hasNeutralStatus(labelInfo, {}));
+ assert.isTrue(hasNeutralStatus(labelInfo, {value: 0}));
+ assert.isFalse(hasNeutralStatus(labelInfo, {value: -1}));
+ assert.isFalse(hasNeutralStatus(labelInfo, {value: 1}));
+ });
+
test('getRepresentativeValue', () => {
let labelInfo: DetailedLabelInfo = {all: []};
assert.equal(getRepresentativeValue(labelInfo), 0);