diff --git a/webui/src/app/version-status/version-status.component.spec.ts b/webui/src/app/version-status/version-status.component.spec.ts index 6ea3500e..61134efe 100644 --- a/webui/src/app/version-status/version-status.component.spec.ts +++ b/webui/src/app/version-status/version-status.component.spec.ts @@ -220,4 +220,17 @@ describe('VersionStatusComponent', () => { let messagesDiv = fixture.nativeElement.querySelector('div.p-messages') expect(messagesDiv).toBeTruthy() }) + + it('should not display feedback when version undefined', () => { + // Arrange + fixture.componentRef.setInput('version', undefined) + fixture.componentRef.setInput('app', 'kea') + fixture.detectChanges() + + // Act & Assert + // No feedback messages are expected. + expect(component.feedbackMessages.length).toEqual(0) + // No error message should be emitted. + expect(messageAddSpy).toHaveBeenCalledTimes(0) + }) }) diff --git a/webui/src/app/version-status/version-status.component.ts b/webui/src/app/version-status/version-status.component.ts index 8f1ef369..bbd761cb 100644 --- a/webui/src/app/version-status/version-status.component.ts +++ b/webui/src/app/version-status/version-status.component.ts @@ -101,6 +101,12 @@ export class VersionStatusComponent implements OnInit, OnDestroy { ngOnInit(): void { this._appName = this.app === 'bind9' ? this.app.toUpperCase() : this.app[0].toUpperCase() + this.app.slice(1) this._appName += this.app === 'stork' ? ' agent' : '' + if (!this.version) { + // Version is a mandatory input. In case it is falsy (undefined, null, empty string), + // simply return. No feedback will be displayed. + return + } + let sanitizedSemver = this.versionService.sanitizeSemver(this.version) if (sanitizedSemver) { this.version = sanitizedSemver