diff options
author | Ben Rohlfs <brohlfs@google.com> | 2022-09-28 09:40:18 +0200 |
---|---|---|
committer | Ben Rohlfs <brohlfs@google.com> | 2022-09-28 07:44:18 +0000 |
commit | dad31e431a639ce649abf5822f401d38d40cfff7 (patch) | |
tree | 3d5a9d1d6b32afc9302c95cd538e3a3e91aa29bd | |
parent | caa004431f4fca09abad7bdeeee3047d9d87f7c3 (diff) |
Ignore check runs without name or status
Release-Notes: skip
Google-Bug-Id: b/249128220
Change-Id: I1be1f49d1d4b1ad89078eda722fa13c1dfa31e3d
-rw-r--r-- | polygerrit-ui/app/models/checks/checks-model.ts | 2 | ||||
-rw-r--r-- | polygerrit-ui/app/models/checks/checks-model_test.ts | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/polygerrit-ui/app/models/checks/checks-model.ts b/polygerrit-ui/app/models/checks/checks-model.ts index 61c2f77ad7..ad3f4449de 100644 --- a/polygerrit-ui/app/models/checks/checks-model.ts +++ b/polygerrit-ui/app/models/checks/checks-model.ts @@ -568,6 +568,8 @@ export class ChecksModel extends Model<ChecksState> implements Finalizable { 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 f3fc665824..88fbebc736 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 @@ suite('checks-model tests', () => { 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( |