Skip to content

Commit

Permalink
[#222] don't emit error for empty version
Browse files Browse the repository at this point in the history
  • Loading branch information
pzadroga committed Oct 29, 2024
1 parent f82cabd commit 3cd6bf5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions webui/src/app/version-status/version-status.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
6 changes: 6 additions & 0 deletions webui/src/app/version-status/version-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3cd6bf5

Please sign in to comment.