Ignore check runs without name or status
Release-Notes: skip
Google-Bug-Id: b/249128220
Change-Id: I1be1f49d1d4b1ad89078eda722fa13c1dfa31e3d
diff --git a/polygerrit-ui/app/models/checks/checks-model.ts b/polygerrit-ui/app/models/checks/checks-model.ts
index 61c2f77..ad3f444 100644
--- a/polygerrit-ui/app/models/checks/checks-model.ts
+++ b/polygerrit-ui/app/models/checks/checks-model.ts
@@ -568,6 +568,8 @@
summaryMessage: string | undefined,
patchset: ChecksPatchset
) {
+ // Protect against plugins not respecting required fields.
+ runs = runs.filter(run => !!run.checkName && !!run.status);
const attemptMap = createAttemptMap(runs);
for (const attemptInfo of attemptMap.values()) {
attemptInfo.attempts.sort(sortAttemptDetails);
diff --git a/polygerrit-ui/app/models/checks/checks-model_test.ts b/polygerrit-ui/app/models/checks/checks-model_test.ts
index f3fc665..88fbebc 100644
--- a/polygerrit-ui/app/models/checks/checks-model_test.ts
+++ b/polygerrit-ui/app/models/checks/checks-model_test.ts
@@ -147,6 +147,35 @@
assert.lengthOf(current.runs[0].results!, 1);
});
+ test('model.updateStateSetResults ignore empty name or status', () => {
+ model.updateStateSetProvider(PLUGIN_NAME, ChecksPatchset.LATEST);
+ model.updateStateSetResults(
+ PLUGIN_NAME,
+ [
+ {
+ checkName: 'test-check-name',
+ status: RunStatus.COMPLETED,
+ },
+ // Will be ignored, because the checkName is empty.
+ {
+ checkName: undefined as unknown as string,
+ status: RunStatus.COMPLETED,
+ },
+ // Will be ignored, because the status is empty.
+ {
+ checkName: 'test-check-name',
+ status: undefined as unknown as RunStatus,
+ },
+ ],
+ [],
+ [],
+ undefined,
+ ChecksPatchset.LATEST
+ );
+ // 2 out of 3 runs are ignored.
+ assert.lengthOf(current.runs, 1);
+ });
+
test('model.updateStateUpdateResult', () => {
model.updateStateSetProvider(PLUGIN_NAME, ChecksPatchset.LATEST);
model.updateStateSetResults(